Quantity#
Defined in sycomore/Quantity.h
-
class Quantity#
Quantity in the SI system.
Public Functions
-
Quantity(double magnitude = {}, Dimensions const &dimensions = {})#
Create a quantity from a magnitude and dimensions.
-
double convert_to(Quantity const &destination) const#
Return the scalar value of the quantity converted to the given unit.
Raise an exception if the given unit is not compatible.
-
operator double() const#
Convert to a scalar.
Raise an exception if the quantity is not unitless.
Public Members
-
double magnitude#
Magnitude of the quantity in base units.
-
Dimensions dimensions#
Dimensions of the quantity.
-
Quantity(double magnitude = {}, Dimensions const &dimensions = {})#
Operators#
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator==(Quantity const &q, T s)# Test whether magnitudes and dimensions are equal.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator==(T s, Quantity const &q)# Test whether magnitudes and dimensions are equal.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator!=(Quantity const &q, T s)# Test whether magnitudes or dimensions differ.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator!=(T s, Quantity const &q)# Test whether magnitudes or dimensions differ.
-
bool operator<(Quantity const &l, Quantity const &r)#
Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator<(Quantity const &q, T s)# Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator<(T s, Quantity const &q)# Compare the magnitude of two compatible quantities.
-
bool operator<=(Quantity const &l, Quantity const &r)#
Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator<=(Quantity const &q, T s)# Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator<=(T s, Quantity const &q)# Compare the magnitude of two compatible quantities.
-
bool operator>(Quantity const &l, Quantity const &r)#
Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator>(Quantity const &q, T s)# Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator>(T s, Quantity const &q)# Compare the magnitude of two compatible quantities.
-
bool operator>=(Quantity const &l, Quantity const &r)#
Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator>=(Quantity const &q, T s)# Compare the magnitude of two compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
bool operator>=(T s, Quantity const &q)# Compare the magnitude of two compatible quantities.
-
Quantity operator+(Quantity q)#
Identity operator.
-
Quantity operator-(Quantity q)#
Return a quantity with the opposite magnitude.
-
Quantity operator+(Quantity l, Quantity const &r)#
Addition of compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator+(Quantity const &q, T s)# Addition of compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator+(T s, Quantity const &q)# Addition of compatible quantities.
-
Quantity operator-(Quantity l, Quantity const &r)#
Subtraction of compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator-(Quantity const &q, T s)# Subtraction of compatible quantities.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator-(T s, Quantity const &q)# Subtraction of compatible quantities.
-
Quantity operator*(Quantity l, Quantity const &r)#
Multiplication.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator*(Quantity q, T s)# Multiplication.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator*(T s, Quantity const &q)# Multiplication.
-
Quantity operator/(Quantity l, Quantity const &r)#
Division.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator/(Quantity q, T s)# Division.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator/(T s, Quantity const &q)# Division.
-
Quantity operator%(Quantity l, Quantity const &r)#
Floating-point modulo.
-
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
Quantity operator%(Quantity q, T s)# Floating-point modulo.
-
std::ostream &operator<<(std::ostream &stream, Quantity const &q)#
String representation of a quantity.
-
template<typename SourceIt, typename DestinationIt>
DestinationIt convert_to(SourceIt const &begin, SourceIt const &end, DestinationIt destination, Quantity const &t)# Convert a sequence of Quantity to given unit.