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 | List of all members
scifir::lab_number< T > Class Template Reference

#include <lab_number.hpp>

Public Member Functions

 lab_number ()
 
 lab_number (const lab_number< T > &x)
 
 lab_number (lab_number< T > &&x)
 
 lab_number (const scalar_unit &x, const scalar_unit &y)
 
 lab_number (const string &x, const string &y)
 
 lab_number (const string &init_lab_number)
 
lab_number< T > & operator= (const lab_number< T > &x)
 
lab_number< T > & operator= (lab_number< T > &&x)
 
template<typename U >
lab_number< scalar_unitoperator+ (const lab_number< U > &x) const
 
template<typename U >
lab_number< scalar_unitoperator- (const lab_number< U > &x) const
 
template<typename U >
lab_number< scalar_unitoperator* (const lab_number< U > &x) const
 
template<typename U >
lab_number< scalar_unitoperator/ (const lab_number< U > &x) const
 
template<typename U >
void operator+= (const lab_number< U > &x)
 
template<typename U >
void operator-= (const lab_number< U > &x)
 
string display (int number_of_decimals=2) const
 

Public Attributes

T value
 
T error_value
 

Detailed Description

template<typename T>
class scifir::lab_number< T >

Definition at line 19 of file lab_number.hpp.

Constructor & Destructor Documentation

◆ lab_number() [1/6]

template<typename T >
scifir::lab_number< T >::lab_number ( )
inline

Definition at line 22 of file lab_number.hpp.

◆ lab_number() [2/6]

template<typename T >
scifir::lab_number< T >::lab_number ( const lab_number< T > &  x)
inline

Definition at line 25 of file lab_number.hpp.

25 : value(x.value),error_value(x.error_value)
26 {}

◆ lab_number() [3/6]

template<typename T >
scifir::lab_number< T >::lab_number ( lab_number< T > &&  x)
inline

Definition at line 28 of file lab_number.hpp.

28 : value(std::move(x.value)),error_value(std::move(x.error_value))
29 {}

◆ lab_number() [4/6]

template<typename T >
scifir::lab_number< T >::lab_number ( const scalar_unit x,
const scalar_unit y 
)
inlineexplicit

Definition at line 31 of file lab_number.hpp.

31 : value(x),error_value(y)
32 {}

◆ lab_number() [5/6]

template<typename T >
scifir::lab_number< T >::lab_number ( const string x,
const string y 
)
inlineexplicit

Definition at line 34 of file lab_number.hpp.

34 : value(x),error_value(y)
35 {}

◆ lab_number() [6/6]

template<typename T >
scifir::lab_number< T >::lab_number ( const string init_lab_number)
inlineexplicit

Definition at line 37 of file lab_number.hpp.

38 {
39 vector<string> values;
40 boost::split(values,init_lab_number,boost::is_any_of("+-,\u00B1"));
41 if (values.size() == 3)
42 {
43 boost::trim(values[0]);
44 boost::trim(values[2]);
45 value = T(values[0]);
46 error_value = T(values[2]);
47 }
48 }

Member Function Documentation

◆ display()

template<typename T >
string scifir::lab_number< T >::display ( int  number_of_decimals = 2) const
inline

Definition at line 102 of file lab_number.hpp.

103 {
104 ostringstream output;
105 output << value.display(number_of_decimals) << " \u00B1 " << error_value.display(number_of_decimals);
106 return output.str();
107 }

◆ operator*()

template<typename T >
template<typename U >
lab_number< scalar_unit > scifir::lab_number< T >::operator* ( const lab_number< U > &  x) const
inline

Definition at line 77 of file lab_number.hpp.

78 {
79 return lab_number<scalar_unit>(value * x.value,error_value * x.error_value);
80 }

◆ operator+()

template<typename T >
template<typename U >
lab_number< scalar_unit > scifir::lab_number< T >::operator+ ( const lab_number< U > &  x) const
inline

Definition at line 65 of file lab_number.hpp.

66 {
67 return lab_number<scalar_unit>(value + x.value,error_value + x.error_value);
68 }

◆ operator+=()

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

Definition at line 89 of file lab_number.hpp.

90 {
91 value += x.value;
92 error_value += x.error_value;
93 }

◆ operator-()

template<typename T >
template<typename U >
lab_number< scalar_unit > scifir::lab_number< T >::operator- ( const lab_number< U > &  x) const
inline

Definition at line 71 of file lab_number.hpp.

72 {
73 return lab_number<scalar_unit>(value - x.value,error_value - x.error_value);
74 }

◆ operator-=()

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

Definition at line 96 of file lab_number.hpp.

97 {
98 value -= x.value;
99 error_value -= x.error_value;
100 }

◆ operator/()

template<typename T >
template<typename U >
lab_number< scalar_unit > scifir::lab_number< T >::operator/ ( const lab_number< U > &  x) const
inline

Definition at line 83 of file lab_number.hpp.

84 {
85 return lab_number<scalar_unit>(value / x.value,error_value / x.error_value);
86 }

◆ operator=() [1/2]

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

Definition at line 50 of file lab_number.hpp.

51 {
52 value = x.value;
53 error_value = x.error_value;
54 return *this;
55 }

◆ operator=() [2/2]

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

Definition at line 57 of file lab_number.hpp.

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

Member Data Documentation

◆ error_value

template<typename T >
T scifir::lab_number< T >::error_value

Definition at line 110 of file lab_number.hpp.

◆ value

template<typename T >
T scifir::lab_number< T >::value

Definition at line 109 of file lab_number.hpp.


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