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.

bool operator==(Quantity const &other) const#

Test whether magnitudes and dimensions are equal.

bool operator!=(Quantity const &other) const#

Test whether magnitudes or dimensions differ.

Quantity &operator+=(Quantity const &other)#

In-place addition of a compatible quantity.

Quantity &operator+=(double s)#

In-place addition of a compatible quantity.

Quantity &operator-=(Quantity const &other)#

In-place subtraction of a compatible quantity.

Quantity &operator-=(double s)#

In-place subtraction of a compatible quantity.

Quantity &operator*=(Quantity const &other)#

In-place multiplication.

Quantity &operator*=(double scalar)#

In-place multiplication.

Quantity &operator/=(Quantity const &other)#

In-place division.

Quantity &operator/=(double scalar)#

In-place division.

Quantity &operator%=(Quantity const &other)#

In-place floating-point modulo.

Quantity &operator%=(double scalar)#

In-place floating-point modulo.

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.

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.

template<std::size_t N, xt::layout_type L = XTENSOR_DEFAULT_LAYOUT>
TensorR<N, L> convert_to(TensorQ<N, L> const &q, Quantity const &t)#

Convert a sequence of Quantity to given unit.

Array Typedefs#

template<std::size_t N, xt::layout_type L = XTENSOR_DEFAULT_LAYOUT>
using TensorQ = xt::xtensor<Quantity, N, L>#

Static-dimension array of Quantity objects.

using ArrayQ = xt::xarray<Quantity>#

Dynamic-dimension array of Quantity objects.

using Vector2Q = Vector2<Quantity>#

2D vector of Quantity

using Vector3Q = Vector3<Quantity>#

3D vector of Quantity

using Vector4Q = Vector4<Quantity>#

4D vector of Quantity

using Matrix2x2Q = Matrix2x2<Quantity>#

2x2 matrix of Quantity

using Matrix3x3Q = Matrix3x3<Quantity>#

3x3 matrix of Quantity

using Matrix4x4Q = Matrix4x4<Quantity>#

3x3 matrix of Quantity