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< float > Class Reference

#include <size_nd.hpp>

Public Member Functions

 size_nd ()
 
 size_nd (const size_nd< float > &x)
 
 size_nd (size_nd< float > &&x)
 
 size_nd (const vector< float > &new_widths)
 
 size_nd (const vector< string > &new_widths)
 
 size_nd (const string &init_size_nd)
 
size_nd< float > & operator= (const size_nd< float > &x)
 
size_nd< float > & operator= (size_nd< float > &&x)
 
size_nd< float > & operator= (const string &init_size_nd)
 
bool is_nd (unsigned int i) const
 
int get_nd () const
 
size_nd< floatoperator+ (const size_nd< float > &x) const
 
size_nd< floatoperator- (const size_nd< float > &x) const
 
void operator+= (const size_nd< float > &x)
 
void operator-= (const size_nd< float > &x)
 
float get_volume_nd () const
 
string display () const
 

Public Attributes

vector< floatwidths
 

Private Member Functions

void initialize_from_string (const string &init_size_nd)
 

Detailed Description

Definition at line 190 of file size_nd.hpp.

Constructor & Destructor Documentation

◆ size_nd() [1/6]

scifir::size_nd< float >::size_nd ( )
inline

Definition at line 193 of file size_nd.hpp.

193 : widths()
194 {}
vector< float > widths
Definition size_nd.hpp:333

◆ size_nd() [2/6]

scifir::size_nd< float >::size_nd ( const size_nd< float > &  x)
inline

Definition at line 196 of file size_nd.hpp.

196 : widths(x.widths)
197 {}

◆ size_nd() [3/6]

scifir::size_nd< float >::size_nd ( size_nd< float > &&  x)
inline

Definition at line 199 of file size_nd.hpp.

199 : widths(std::move(x.widths))
200 {}

◆ size_nd() [4/6]

scifir::size_nd< float >::size_nd ( const vector< float > &  new_widths)
inlineexplicit

Definition at line 202 of file size_nd.hpp.

202 : widths(new_widths)
203 {}

◆ size_nd() [5/6]

scifir::size_nd< float >::size_nd ( const vector< string > &  new_widths)
inlineexplicit

Definition at line 205 of file size_nd.hpp.

205 : widths()
206 {
207 for (const string& new_width : new_widths)
208 {
209 widths.push_back(stof(new_width));
210 }
211 }

◆ size_nd() [6/6]

scifir::size_nd< float >::size_nd ( const string init_size_nd)
inlineexplicit

Definition at line 213 of file size_nd.hpp.

213 : size_nd()
214 {
215 initialize_from_string(init_size_nd);
216 }
void initialize_from_string(const string &init_size_nd)
Definition size_nd.hpp:336

Member Function Documentation

◆ display()

string scifir::size_nd< float >::display ( ) const
inline

Definition at line 312 of file size_nd.hpp.

313 {
314 if (widths.size() > 0)
315 {
316 ostringstream output;
317 output << display_float(widths[0],2);
318 if (widths.size() > 1)
319 {
320 for (unsigned int i = 1; i < widths.size(); i++)
321 {
322 output << " * " << display_float(widths[i],2);
323 }
324 }
325 return output.str();
326 }
327 else
328 {
329 return "[empty]";
330 }
331 }
string display_float(const float &value, int number_of_decimals)
Definition types.cpp:36

◆ get_nd()

int scifir::size_nd< float >::get_nd ( ) const
inline

Definition at line 241 of file size_nd.hpp.

242 {
243 return int(widths.size());
244 }

◆ get_volume_nd()

float scifir::size_nd< float >::get_volume_nd ( ) const
inline

Definition at line 302 of file size_nd.hpp.

303 {
304 float new_value = 1;
305 for (unsigned int i = 0; i < widths.size(); i++)
306 {
307 new_value *= widths[i];
308 }
309 return new_value;
310 }

◆ initialize_from_string()

void scifir::size_nd< float >::initialize_from_string ( const string init_size_nd)
inlineprivate

Definition at line 336 of file size_nd.hpp.

337 {
338 widths.clear();
339 vector<string> new_widths;
340 boost::split(new_widths,init_size_nd,boost::is_any_of("*"));
341 for (string& new_width : new_widths)
342 {
343 boost::trim(new_width);
344 widths.push_back(stof(new_width));
345 }
346 }

◆ is_nd()

bool scifir::size_nd< float >::is_nd ( unsigned int  i) const
inline

Definition at line 236 of file size_nd.hpp.

237 {
238 return widths.size() == i;
239 }

◆ operator+()

size_nd< float > scifir::size_nd< float >::operator+ ( const size_nd< float > &  x) const
inline

Definition at line 246 of file size_nd.hpp.

247 {
248 if (get_nd() == x.get_nd())
249 {
250 vector<float> new_widths = widths;
251 for (unsigned int i = 0; i < new_widths.size(); i++)
252 {
253 new_widths[i] += x.widths[i];
254 }
255 return size_nd<float>(new_widths);
256 }
257 else
258 {
259 return size_nd<float>();
260 }
261 }

◆ operator+=()

void scifir::size_nd< float >::operator+= ( const size_nd< float > &  x)
inline

Definition at line 280 of file size_nd.hpp.

281 {
282 if (get_nd() == x.get_nd())
283 {
284 for (unsigned int i = 0; i < widths.size(); i++)
285 {
286 widths[i] += x.widths[i];
287 }
288 }
289 }

◆ operator-()

size_nd< float > scifir::size_nd< float >::operator- ( const size_nd< float > &  x) const
inline

Definition at line 263 of file size_nd.hpp.

264 {
265 if (get_nd() == x.get_nd())
266 {
267 vector<float> new_widths = widths;
268 for (unsigned int i = 0; i < new_widths.size(); i++)
269 {
270 new_widths[i] -= x.widths[i];
271 }
272 return size_nd<float>(new_widths);
273 }
274 else
275 {
276 return size_nd<float>();
277 }
278 }

◆ operator-=()

void scifir::size_nd< float >::operator-= ( const size_nd< float > &  x)
inline

Definition at line 291 of file size_nd.hpp.

292 {
293 if (get_nd() == x.get_nd())
294 {
295 for (unsigned int i = 0; i < widths.size(); i++)
296 {
297 widths[i] -= x.widths[i];
298 }
299 }
300 }

◆ operator=() [1/3]

size_nd< float > & scifir::size_nd< float >::operator= ( const size_nd< float > &  x)
inline

Definition at line 218 of file size_nd.hpp.

219 {
220 widths = x.widths;
221 return *this;
222 }

◆ operator=() [2/3]

size_nd< float > & scifir::size_nd< float >::operator= ( const string init_size_nd)
inline

Definition at line 230 of file size_nd.hpp.

231 {
232 initialize_from_string(init_size_nd);
233 return *this;
234 }

◆ operator=() [3/3]

size_nd< float > & scifir::size_nd< float >::operator= ( size_nd< float > &&  x)
inline

Definition at line 224 of file size_nd.hpp.

225 {
226 widths = std::move(x.widths);
227 return *this;
228 }

Member Data Documentation

◆ widths

Definition at line 333 of file size_nd.hpp.


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