scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | List of all members
scifir::size_nd< T > Class Template Reference

#include <size_nd.hpp>

Public Member Functions

 size_nd ()
 
 size_nd (const size_nd< T > &x)
 
 size_nd (size_nd< T > &&x)
 
template<typename U >
 size_nd (const vector< U > &new_widths)
 
 size_nd (const vector< string > &new_widths)
 
 size_nd (const string &init_size_nd)
 
size_nd< T > & operator= (const size_nd< T > &x)
 
size_nd< T > & operator= (size_nd< T > &&x)
 
size_nd< T > & operator= (const string &init_size_nd)
 
bool is_nd (int i) const
 
int get_nd () const
 
template<typename U >
size_nd< Toperator+ (const size_nd< U > &x) const
 
template<typename U >
size_nd< Toperator- (const size_nd< U > &x) const
 
template<typename U >
void operator+= (const size_nd< U > &x)
 
template<typename U >
void operator-= (const size_nd< U > &x)
 
scalar_unit get_volume_nd () const
 
string display () const
 

Public Attributes

vector< Twidths
 

Private Member Functions

void initialize_from_string (const string &init_size_nd)
 

Detailed Description

template<typename T = length>
class scifir::size_nd< T >

Definition at line 17 of file size_nd.hpp.

Constructor & Destructor Documentation

◆ size_nd() [1/6]

template<typename T = length>
scifir::size_nd< T >::size_nd ( )
inline

Definition at line 20 of file size_nd.hpp.

20 : widths()
21 {}
vector< T > widths
Definition size_nd.hpp:173

◆ size_nd() [2/6]

template<typename T = length>
scifir::size_nd< T >::size_nd ( const size_nd< T > &  x)
inline

Definition at line 23 of file size_nd.hpp.

23 : widths(x.widths)
24 {}

◆ size_nd() [3/6]

template<typename T = length>
scifir::size_nd< T >::size_nd ( size_nd< T > &&  x)
inline

Definition at line 26 of file size_nd.hpp.

26 : widths(std::move(x.widths))
27 {}

◆ size_nd() [4/6]

template<typename T = length>
template<typename U >
scifir::size_nd< T >::size_nd ( const vector< U > &  new_widths)
inlineexplicit

Definition at line 30 of file size_nd.hpp.

30 : widths()
31 {
32 for(const U& new_width : new_widths)
33 {
34 widths.push_back(T(new_width));
35 }
36 }

◆ size_nd() [5/6]

template<typename T = length>
scifir::size_nd< T >::size_nd ( const vector< string > &  new_widths)
inlineexplicit

Definition at line 38 of file size_nd.hpp.

38 : widths()
39 {
40 for (const string& new_width : new_widths)
41 {
42 widths.push_back(T(new_width));
43 }
44 }

◆ size_nd() [6/6]

template<typename T = length>
scifir::size_nd< T >::size_nd ( const string init_size_nd)
inlineexplicit

Definition at line 46 of file size_nd.hpp.

46 : size_nd()
47 {
48 initialize_from_string(init_size_nd);
49 }
void initialize_from_string(const string &init_size_nd)
Definition size_nd.hpp:176

Member Function Documentation

◆ display()

template<typename T = length>
string scifir::size_nd< T >::display ( ) const
inline

Definition at line 152 of file size_nd.hpp.

153 {
154 if (widths.size() > 0)
155 {
156 ostringstream output;
157 output << widths[0];
158 if (widths.size() > 1)
159 {
160 for (unsigned int i = 1; i < widths.size(); i++)
161 {
162 output << " * " << widths[i];
163 }
164 }
165 return output.str();
166 }
167 else
168 {
169 return "[empty]";
170 }
171 }

◆ get_nd()

template<typename T = length>
int scifir::size_nd< T >::get_nd ( ) const
inline

Definition at line 74 of file size_nd.hpp.

75 {
76 return widths.size();
77 }

◆ get_volume_nd()

template<typename T = length>
scalar_unit scifir::size_nd< T >::get_volume_nd ( ) const
inline

Definition at line 141 of file size_nd.hpp.

142 {
143 vector<dimension> new_dimensions = create_dimensions(widths[0].get_dimensions()[0].get_symbol() + std::to_string(get_nd()));
144 float new_value = 1;
145 for (unsigned int i = 0; i < widths.size(); i++)
146 {
147 new_value *= widths[i].get_value();
148 }
149 return scalar_unit(new_value,new_dimensions);
150 }
int get_nd() const
Definition size_nd.hpp:74
vector< dimension > create_dimensions(string init_dimensions)
Creates the dimensions from an initialization string of dimensions.

◆ initialize_from_string()

template<typename T = length>
void scifir::size_nd< T >::initialize_from_string ( const string init_size_nd)
inlineprivate

Definition at line 176 of file size_nd.hpp.

177 {
178 widths.clear();
179 vector<string> new_widths;
180 boost::split(new_widths,init_size_nd,boost::is_any_of("*"));
181 for (string& new_width : new_widths)
182 {
183 boost::trim(new_width);
184 widths.push_back(T(new_width));
185 }
186 }

◆ is_nd()

template<typename T = length>
bool scifir::size_nd< T >::is_nd ( int  i) const
inline

Definition at line 69 of file size_nd.hpp.

70 {
71 return widths.size() == i;
72 }

◆ operator+()

template<typename T = length>
template<typename U >
size_nd< T > scifir::size_nd< T >::operator+ ( const size_nd< U > &  x) const
inline

Definition at line 80 of file size_nd.hpp.

81 {
82 if (get_nd() == x.get_nd())
83 {
84 vector<T> new_widths = vector<T>();
85 for (unsigned int i = 0; i < widths.size(); i++)
86 {
87 new_widths.push_back(widths[i]);
88 new_widths[i] += T(x.widths[i]);
89 }
90 return size_nd<T>(new_widths);
91 }
92 else
93 {
94 return size_nd<T>();
95 }
96 }

◆ operator+=()

template<typename T = length>
template<typename U >
void scifir::size_nd< T >::operator+= ( const size_nd< U > &  x)
inline

Definition at line 118 of file size_nd.hpp.

119 {
120 if (get_nd() == x.get_nd())
121 {
122 for (unsigned int i = 0; i < widths.size(); i++)
123 {
124 widths[i] += T(x.widths[i]);
125 }
126 }
127 }

◆ operator-()

template<typename T = length>
template<typename U >
size_nd< T > scifir::size_nd< T >::operator- ( const size_nd< U > &  x) const
inline

Definition at line 99 of file size_nd.hpp.

100 {
101 if (get_nd() == x.get_nd())
102 {
103 vector<T> new_widths = vector<T>();
104 for (unsigned int i = 0; i < widths.size(); i++)
105 {
106 new_widths.push_back(widths[i]);
107 new_widths[i] -= T(x.widths[i]);
108 }
109 return size_nd<T>(new_widths);
110 }
111 else
112 {
113 return size_nd<T>();
114 }
115 }

◆ operator-=()

template<typename T = length>
template<typename U >
void scifir::size_nd< T >::operator-= ( const size_nd< U > &  x)
inline

Definition at line 130 of file size_nd.hpp.

131 {
132 if (get_nd() == x.get_nd())
133 {
134 for (unsigned int i = 0; i < widths.size(); i++)
135 {
136 widths[i] -= T(x.widths[i]);
137 }
138 }
139 }

◆ operator=() [1/3]

template<typename T = length>
size_nd< T > & scifir::size_nd< T >::operator= ( const size_nd< T > &  x)
inline

Definition at line 51 of file size_nd.hpp.

52 {
53 widths = x.widths;
54 return *this;
55 }

◆ operator=() [2/3]

template<typename T = length>
size_nd< T > & scifir::size_nd< T >::operator= ( const string init_size_nd)
inline

Definition at line 63 of file size_nd.hpp.

64 {
65 initialize_from_string(init_size_nd);
66 return *this;
67 }

◆ operator=() [3/3]

template<typename T = length>
size_nd< T > & scifir::size_nd< T >::operator= ( size_nd< T > &&  x)
inline

Definition at line 57 of file size_nd.hpp.

58 {
59 widths = std::move(x.widths);
60 return *this;
61 }

Member Data Documentation

◆ widths

template<typename T = length>
vector<T> scifir::size_nd< T >::widths

Definition at line 173 of file size_nd.hpp.


The documentation for this class was generated from the following file: