antioch-0.4.0
List of all members | Public Member Functions | Private Attributes | Friends
Antioch::Converter< T > Class Template Reference

Class to deal with the conversion between units. More...

#include <converter.h>

Public Member Functions

 Converter ()
 Default constructor, defaults values are (1.,0.) More...
 
 Converter (const T &coef, const T &trans)
 Constructor. More...
 
template<typename P >
 Converter (const Converter< P > &rhs)
 Copy constructor, uses Converter & operator=(const Converter&) More...
 
 ~Converter ()
 Default constructor. More...
 
template<typename P = T>
const P geta () const
 Multiplicative factor getter. More...
 
template<typename P = T>
const P getb () const
 Translationnal factor getter. More...
 
void clear ()
 Set the values to (1.,0.) More...
 
template<typename P >
bool operator== (const Converter< P > &rhs) const
 Comparison operator, equal if the two values are equal. More...
 
template<typename P >
bool operator!= (const Converter< P > &rhs) const
 Comparison operator, not equal is not "equal". More...
 
template<typename P >
Converteroperator= (const Converter< P > &rhs)
 Assignement operator, equalize the two values. More...
 
template<typename P >
Converteroperator*= (const Converter< P > &rhs)
 Multiplying operator. More...
 
template<typename P >
Converteroperator/= (const Converter< P > &rhs)
 Dividing operator. More...
 
template<typename P >
Converteroperator+= (const Converter< P > &rhs)
 Adding operator. More...
 
template<typename P >
Converter operator/ (const Converter< P > &rhs) const
 Dividing operator, same operations as Converter &operator/=(const Converter&) More...
 
template<typename P >
Converter operator* (const Converter< P > &rhs) const
 Multiplying operator, same operations as Converter &operator*=(const Converter&) More...
 
template<typename P >
Converteroperator*= (const P &coef)
 Multiplying operator with a scalar, only multiply the multiplicative value. More...
 
template<typename P >
Converteroperator/= (const P &coef)
 Dividing operator with a double, only divide the multiplicative value. More...
 
template<typename P >
Converter operator* (const P &coef) const
 Multiplying operator with a scalar, only multiply the multiplicative value. More...
 
template<typename P >
Converter operator/ (const P &coef) const
 Dividing operator with a scalar, only divide the multiplicative value. More...
 
template<typename P >
Converter< T > & operator= (const Converter< P > &rhs)
 
template<typename P >
Converter< T > & operator*= (const P &coef)
 
template<typename P >
Converter< T > & operator/= (const P &coef)
 
template<typename P >
Converter< T > & operator*= (const Converter< P > &rhs)
 
template<typename P >
Converter< T > & operator/= (const Converter< P > &rhs)
 
template<typename P >
Converter< T > & operator+= (const Converter< P > &rhs)
 
template<typename P >
Converter< T > operator* (const P &coef) const
 
template<typename P >
Converter< T > operator/ (const P &coef) const
 
template<typename P >
Converter< T > operator/ (const Converter< P > &rhs) const
 
template<typename P >
Converter< T > operator* (const Converter< P > &rhs) const
 

Private Attributes

a
 Two double for a multiplicative and translationnal part of a coefficient. More...
 
b
 

Friends

std::ostream & operator<< (std::ostream &out, const Converter< T > &rhs)
 << operator, to show the coef as a complex number (a,b) More...
 

Detailed Description

template<typename T = double>
class Antioch::Converter< T >

Class to deal with the conversion between units.

This class keeps track of the conversion factor between the unit and the base unit. To be general, this is a couple of double, one for the multiplication part and another one for the translationnal part (mainly for temperature, but it should not be used).

Definition at line 47 of file converter.h.

Constructor & Destructor Documentation

template<typename T >
Antioch::Converter< T >::Converter ( )
inline

Default constructor, defaults values are (1.,0.)

Definition at line 148 of file converter.h.

149 {
150  clear();
151  return;
152 }
void clear()
Set the values to (1.,0.)
Definition: converter.h:66
template<typename T >
Antioch::Converter< T >::Converter ( const T &  coef,
const T &  trans 
)
inline

Constructor.

Definition at line 156 of file converter.h.

References Antioch::constant_clone().

157 {
158  a = Antioch::constant_clone(a,coef);
159  b = Antioch::constant_clone(b,tran);
160  return;
161 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)
Definition: eigen_utils.h:181
template<typename T = double>
template<typename P >
Antioch::Converter< T >::Converter ( const Converter< P > &  rhs)
inline

Copy constructor, uses Converter & operator=(const Converter&)

Definition at line 55 of file converter.h.

55 {*this = rhs;}
template<typename T = double>
Antioch::Converter< T >::~Converter ( )
inline

Default constructor.

Definition at line 57 of file converter.h.

57 {}

Member Function Documentation

template<typename T = double>
void Antioch::Converter< T >::clear ( )
inline

Set the values to (1.,0.)

Definition at line 66 of file converter.h.

References Antioch::Converter< T >::a, Antioch::Converter< T >::b, and Antioch::set_zero().

66 {a = 1.L; Antioch::set_zero(b);}
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
Definition: eigen_utils.h:217
template<typename T = double>
template<typename P = T>
const P Antioch::Converter< T >::geta ( ) const
inline

Multiplicative factor getter.

Definition at line 61 of file converter.h.

References Antioch::Converter< T >::a.

Referenced by Antioch::Converter< T >::operator*(), Antioch::Converter< T >::operator*=(), Antioch::Converter< T >::operator+=(), Antioch::Converter< T >::operator/(), Antioch::Converter< T >::operator/=(), Antioch::Converter< T >::operator=(), and Antioch::Units< T >::raise().

61 {return (P)a;} //only scalar type
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P = T>
const P Antioch::Converter< T >::getb ( ) const
inline
template<typename T = double>
template<typename P >
bool Antioch::Converter< T >::operator!= ( const Converter< P > &  rhs) const
inline

Comparison operator, not equal is not "equal".

Definition at line 80 of file converter.h.

80 {return !(*this == rhs);}
template<typename T = double>
template<typename P >
Converter Antioch::Converter< T >::operator* ( const Converter< P > &  rhs) const

Multiplying operator, same operations as Converter &operator*=(const Converter&)

template<typename T = double>
template<typename P >
Converter Antioch::Converter< T >::operator* ( const P &  coef) const

Multiplying operator with a scalar, only multiply the multiplicative value.

template<typename T = double>
template<typename P >
Converter<T> Antioch::Converter< T >::operator* ( const P &  coef) const
inline

Definition at line 226 of file converter.h.

227 {
228  return Converter<T>(a*coef,b);
229 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter<T> Antioch::Converter< T >::operator* ( const Converter< P > &  rhs) const
inline

Definition at line 250 of file converter.h.

References Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

251 {
252  return Converter<T>(a * rhs.geta() , (b + rhs.getb())/rhs.geta());
253 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator*= ( const Converter< P > &  rhs)

Multiplying operator.

The operations performed for the mutiplication of (a,b) and (c,d) are:

\[ a = a \times c \]

\[ b = \frac{b + d}{c} \]

template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator*= ( const P &  coef)

Multiplying operator with a scalar, only multiply the multiplicative value.

template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator*= ( const P &  coef)
inline

Definition at line 178 of file converter.h.

179 {
180  a *= coef;
181  return *this;
182 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator*= ( const Converter< P > &  rhs)
inline

Definition at line 196 of file converter.h.

References Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

197 {
198  a *= rhs.geta();
199  b = (b + rhs.getb())/rhs.geta();
200  return *this;
201 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator+= ( const Converter< P > &  rhs)

Adding operator.

The operations performed for the addition of (a,b) and (c,d) are:

\[ a = a \times c \]

\[ b = b + d \]

template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator+= ( const Converter< P > &  rhs)
inline

Definition at line 216 of file converter.h.

References Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

217 {
218  a *= rhs.geta();
219  b += rhs.getb();
220  return *this;
221 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter Antioch::Converter< T >::operator/ ( const Converter< P > &  rhs) const

Dividing operator, same operations as Converter &operator/=(const Converter&)

template<typename T = double>
template<typename P >
Converter Antioch::Converter< T >::operator/ ( const P &  coef) const

Dividing operator with a scalar, only divide the multiplicative value.

template<typename T = double>
template<typename P >
Converter<T> Antioch::Converter< T >::operator/ ( const P &  coef) const
inline

Definition at line 234 of file converter.h.

235 {
236  return Converter<T>(a/coef,b);
237 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter<T> Antioch::Converter< T >::operator/ ( const Converter< P > &  rhs) const
inline

Definition at line 242 of file converter.h.

References Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

243 {
244  return Converter(a/rhs.geta(),(b-rhs.getb())/rhs.geta());
245 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
Converter()
Default constructor, defaults values are (1.,0.)
Definition: converter.h:148
template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator/= ( const Converter< P > &  rhs)

Dividing operator.

The operations performed for the division of (a,b) and (c,d) are:

\[ a = \frac{a}{c} \]

\[ b = \frac{b - d}{c} \]

template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator/= ( const P &  coef)

Dividing operator with a double, only divide the multiplicative value.

template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator/= ( const P &  coef)
inline

Definition at line 187 of file converter.h.

188 {
189  a /= coef;
190  return *this;
191 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator/= ( const Converter< P > &  rhs)
inline

Definition at line 206 of file converter.h.

References Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

207 {
208  a /= rhs.geta();
209  b = (b - rhs.getb())/rhs.geta();
210  return *this;
211 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
template<typename T = double>
template<typename P >
Converter& Antioch::Converter< T >::operator= ( const Converter< P > &  rhs)

Assignement operator, equalize the two values.

template<typename T = double>
template<typename P >
Converter<T>& Antioch::Converter< T >::operator= ( const Converter< P > &  rhs)
inline

Definition at line 167 of file converter.h.

References Antioch::constant_clone(), Antioch::Converter< T >::geta(), and Antioch::Converter< T >::getb().

168 {
169  // if(this == static_cast<Converter<T>*>(&rhs)){return *this;}
170  a = Antioch::constant_clone(a,rhs.geta());
171  b = Antioch::constant_clone(b,rhs.getb());
172  return *this;
173 }
T a
Two double for a multiplicative and translationnal part of a coefficient.
Definition: converter.h:141
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)
Definition: eigen_utils.h:181
template<typename T = double>
template<typename P >
bool Antioch::Converter< T >::operator== ( const Converter< P > &  rhs) const

Comparison operator, equal if the two values are equal.

Friends And Related Function Documentation

template<typename T = double>
std::ostream& operator<< ( std::ostream &  out,
const Converter< T > &  rhs 
)
friend

<< operator, to show the coef as a complex number (a,b)

Definition at line 69 of file converter.h.

70  {
71  out << "(" << rhs.geta() << "," << rhs.getb() << ")";
72  return out;
73  }

Member Data Documentation

template<typename T = double>
T Antioch::Converter< T >::a
private

Two double for a multiplicative and translationnal part of a coefficient.

Definition at line 141 of file converter.h.

Referenced by Antioch::Converter< T >::clear(), and Antioch::Converter< T >::geta().

template<typename T = double>
T Antioch::Converter< T >::b
private

Definition at line 142 of file converter.h.

Referenced by Antioch::Converter< T >::clear(), and Antioch::Converter< T >::getb().


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

Generated on Thu Jul 7 2016 11:09:48 for antioch-0.4.0 by  doxygen 1.8.8