Minsky
minsky::UnitsExpressionWalker Struct Reference

#include <unitsExpressionWalker.h>

Collaboration diagram for minsky::UnitsExpressionWalker:
Collaboration graph

Public Member Functions

 UnitsExpressionWalker ()
 
 UnitsExpressionWalker (double x)
 
 UnitsExpressionWalker (const std::string &units)
 
void checkSameDims (const UnitsExpressionWalker &x) const
 
void checkDimensionless () const
 
UnitsExpressionWalker operator+= (const UnitsExpressionWalker &x)
 
UnitsExpressionWalker operator+ (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator-= (const UnitsExpressionWalker &x)
 
UnitsExpressionWalker operator- (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator*= (const UnitsExpressionWalker &x)
 
UnitsExpressionWalker operator* (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator/= (const UnitsExpressionWalker &x)
 
UnitsExpressionWalker operator/ (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator% (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator && (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator^ (const UnitsExpressionWalker &x) const
 
UnitsExpressionWalker operator|| (const UnitsExpressionWalker &x) const
 
bool operator< (const UnitsExpressionWalker &x) const
 
bool operator> (const UnitsExpressionWalker &x) const
 
bool operator<= (const UnitsExpressionWalker &x) const
 
bool operator>= (const UnitsExpressionWalker &x) const
 
bool operator== (const UnitsExpressionWalker &x) const
 
bool operator!= (const UnitsExpressionWalker &x) const
 

Public Attributes

Units units
 
double value =std::nan("")
 

Static Public Attributes

static bool check =true
 

Detailed Description

Definition at line 31 of file unitsExpressionWalker.h.

Constructor & Destructor Documentation

◆ UnitsExpressionWalker() [1/3]

minsky::UnitsExpressionWalker::UnitsExpressionWalker ( )
inline

Definition at line 36 of file unitsExpressionWalker.h.

36 {}

◆ UnitsExpressionWalker() [2/3]

minsky::UnitsExpressionWalker::UnitsExpressionWalker ( double  x)
inline

Definition at line 37 of file unitsExpressionWalker.h.

◆ UnitsExpressionWalker() [3/3]

minsky::UnitsExpressionWalker::UnitsExpressionWalker ( const std::string &  units)
inline

Definition at line 38 of file unitsExpressionWalker.h.

Member Function Documentation

◆ checkDimensionless()

void minsky::UnitsExpressionWalker::checkDimensionless ( ) const
inline

Definition at line 42 of file unitsExpressionWalker.h.

References check, and units.

Referenced by minsky::checkDimensionless(), and minsky::pow().

43  {if (check && !units.empty()) throw std::runtime_error("Should be dimensionless");}
Here is the caller graph for this function:

◆ checkSameDims()

void minsky::UnitsExpressionWalker::checkSameDims ( const UnitsExpressionWalker x) const
inline

Definition at line 40 of file unitsExpressionWalker.h.

References check, and units.

Referenced by minsky::checkSameDims(), operator &&(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator>(), operator>=(), operator^(), and operator||().

41  {if (check && x.units!=units) throw std::runtime_error("Incommensurate units");}
Here is the caller graph for this function:

◆ operator &&()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator&& ( const UnitsExpressionWalker x) const
inline

Definition at line 73 of file unitsExpressionWalker.h.

References checkSameDims().

74  {checkSameDims(x);return x;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator!=()

bool minsky::UnitsExpressionWalker::operator!= ( const UnitsExpressionWalker x) const
inline

Definition at line 89 of file unitsExpressionWalker.h.

References operator==().

90  {return !operator==(x);}
bool operator==(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator%()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator% ( const UnitsExpressionWalker x) const
inline

Definition at line 71 of file unitsExpressionWalker.h.

72  {return x;}

◆ operator*()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator* ( const UnitsExpressionWalker x) const
inline

Definition at line 60 of file unitsExpressionWalker.h.

61  {auto tmp=*this; return tmp*=x;}

◆ operator*=()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator*= ( const UnitsExpressionWalker x)
inline

Definition at line 53 of file unitsExpressionWalker.h.

References minsky::Units::normalise(), and units.

54  {
55  for (auto& i: x.units)
56  units[i.first]+=i.second;
57  units.normalise();
58  return *this;
59  }
void normalise()
Definition: units.h:42
Here is the call graph for this function:

◆ operator+()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator+ ( const UnitsExpressionWalker x) const
inline

Definition at line 46 of file unitsExpressionWalker.h.

References checkSameDims().

47  {checkSameDims(x); return *this;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator+=()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator+= ( const UnitsExpressionWalker x)
inline

Definition at line 44 of file unitsExpressionWalker.h.

References checkSameDims().

45  {checkSameDims(x); return *this;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator-()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator- ( const UnitsExpressionWalker x) const
inline

Definition at line 50 of file unitsExpressionWalker.h.

References checkSameDims().

51  {checkSameDims(x); return *this;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator-=()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator-= ( const UnitsExpressionWalker x)
inline

Definition at line 48 of file unitsExpressionWalker.h.

References checkSameDims().

49  {checkSameDims(x); return *this;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator/()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator/ ( const UnitsExpressionWalker x) const
inline

Definition at line 69 of file unitsExpressionWalker.h.

70  {auto tmp=*this; return tmp/=x;}

◆ operator/=()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator/= ( const UnitsExpressionWalker x)
inline

Definition at line 62 of file unitsExpressionWalker.h.

References minsky::Units::normalise(), and units.

63  {
64  for (auto& i: x.units)
65  units[i.first]-=i.second;
66  units.normalise();
67  return *this;
68  }
void normalise()
Definition: units.h:42
Here is the call graph for this function:

◆ operator<()

bool minsky::UnitsExpressionWalker::operator< ( const UnitsExpressionWalker x) const
inline

Definition at line 79 of file unitsExpressionWalker.h.

References checkSameDims(), and value.

80  {checkSameDims(x); return value<x.value;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator<=()

bool minsky::UnitsExpressionWalker::operator<= ( const UnitsExpressionWalker x) const
inline

Definition at line 83 of file unitsExpressionWalker.h.

References checkSameDims(), and value.

84  {checkSameDims(x); return value<=x.value;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator==()

bool minsky::UnitsExpressionWalker::operator== ( const UnitsExpressionWalker x) const
inline

Definition at line 87 of file unitsExpressionWalker.h.

References value.

Referenced by operator!=().

88  {return x.value==value;}
Here is the caller graph for this function:

◆ operator>()

bool minsky::UnitsExpressionWalker::operator> ( const UnitsExpressionWalker x) const
inline

Definition at line 81 of file unitsExpressionWalker.h.

References checkSameDims(), and value.

82  {checkSameDims(x); return value>x.value;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator>=()

bool minsky::UnitsExpressionWalker::operator>= ( const UnitsExpressionWalker x) const
inline

Definition at line 85 of file unitsExpressionWalker.h.

References checkSameDims(), and value.

86  {checkSameDims(x); return value>=x.value;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator^()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator^ ( const UnitsExpressionWalker x) const
inline

Definition at line 75 of file unitsExpressionWalker.h.

References checkSameDims().

76  {checkSameDims(x);return x;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

◆ operator||()

UnitsExpressionWalker minsky::UnitsExpressionWalker::operator|| ( const UnitsExpressionWalker x) const
inline

Definition at line 77 of file unitsExpressionWalker.h.

References checkSameDims().

78  {checkSameDims(x);return x;}
void checkSameDims(const UnitsExpressionWalker &x) const
Here is the call graph for this function:

Member Data Documentation

◆ check

bool minsky::UnitsExpressionWalker::check =true
static

Definition at line 34 of file unitsExpressionWalker.h.

Referenced by checkDimensionless(), and checkSameDims().

◆ units

◆ value


The documentation for this struct was generated from the following files: