units
Use physical dimensions at compile-time or run-time.
|
Model of a physically dimensioned quantity. More...
#include <dimval.hpp>
Public Member Functions | |
dimval () | |
< Allow access to dimension. More... | |
constexpr | dimval (T const &v, dim const &d) |
Initialize from numeric value and from dimension. More... | |
template<typename OT , typename OB > | |
constexpr | dimval (dimval< OT, OB > const &v) |
Initialize from other dimensioned value. More... | |
constexpr | dimval (T const &n) |
Initialize from dimensionless number. More... | |
constexpr T | to_number () const |
Convert to dimensionless number. More... | |
constexpr dim::rat | d (dim::off off) const |
Exponent for base at specified offset. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator== (dimval< OT, OB > const &v) const |
Equality-comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator!= (dimval< OT, OB > const &v) const |
Inequality-comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator< (dimval< OT, OB > const &v) const |
Less-than comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator<= (dimval< OT, OB > const &v) const |
Less-than-or-equal comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator> (dimval< OT, OB > const &v) const |
Greater-than comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator>= (dimval< OT, OB > const &v) const |
Greater-than-or-equal comparison of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator+ (dimval< OT, OB > const &v) const |
Sum of two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator- (dimval< OT, OB > const &v) const |
Difference between two dimensioned values. More... | |
template<typename OT , typename OB > | |
constexpr dimval & | operator+= (dimval< OT, OB > const &v) |
Modify present instance by adding in a dimensioned value. More... | |
template<typename OT , typename OB > | |
constexpr dimval & | operator-= (dimval< OT, OB > const &v) |
Modify present instance by subtracting out a dimensioned value. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr auto | operator* (OT const &n) const |
Scale dimensioned value. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator* (dimval< OT, OB > const &v) const |
Multiply two dimensioned values. More... | |
constexpr auto | operator[] (size_t off) const |
Support element-access in case it be supported by numeric type. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr auto | dot (OT const &n) const |
Support dot-product in case it be supported by numeric type. More... | |
template<typename OT , typename OB > | |
constexpr auto | dot (dimval< OT, OB > const &v) const |
Support dot-product in case it be supported by numeric type. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr auto | cross (OT const &n) const |
Support cross-product in case it be supported by numeric type. More... | |
template<typename OT , typename OB > | |
constexpr auto | cross (dimval< OT, OB > const &v) const |
Support cross-product in case it be supported by numeric type. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr auto | operator/ (OT const &n) const |
Scale dimensioned quantity by dividing by number. More... | |
constexpr dimval< T, typename B::recip_basedim > | inverse () const |
Invert dimensioned value. More... | |
template<typename OT , typename OB > | |
constexpr auto | operator/ (dimval< OT, OB > const &v) const |
Divide two dimensioned values. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr dimval & | operator*= (OT const &v) |
Modify present instance by multiplying in a dimensionless value. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr dimval & | operator/= (OT const &v) |
Modify present instance by dividing it by a dimensionless value. More... | |
template<int64_t PN, int64_t PD = 1> | |
constexpr auto | power () const |
Raise dimensioned value to rational power. More... | |
constexpr auto | power (dim::rat p) const |
Raise dimensioned value to rational power. More... | |
constexpr auto | square_root () const |
Square-root of a dimensioned quantity. More... | |
Protected Member Functions | |
dimval (dim const &d) | |
Initialize dimension, but leave number undefined. More... | |
Friends | |
template<typename OT , typename OB > | |
class | dimval |
Allow access to every kind of dimval. More... | |
template<typename OT > | |
class | basic_dyndim |
Allow access to each kind (float or double) of dyndim. More... | |
template<dim::word D, typename OT > | |
class | basic_statdim |
Allow access to every kind of statdim. More... | |
template<typename OT , otest< OT > = 0> | |
constexpr auto | operator* (OT const &n, dimval const &v) |
Scale dimensioned value. More... | |
std::ostream & | operator<< (std::ostream &s, dimval const &v) |
Print to to output stream. More... | |
Model of a physically dimensioned quantity.
T | Type of storage (e.g., float or double) for numerical quantity. |
B | Base-class (statdim_base or dyndim_base) for dimension. |
Definition at line 22 of file dimval.hpp.
|
inlineprotected |
Initialize dimension, but leave number undefined.
d | Dimension. |
Definition at line 72 of file dimval.hpp.
|
inline |
< Allow access to dimension.
By default, do not initialize.
Definition at line 78 of file dimval.hpp.
|
inline |
Initialize from numeric value and from dimension.
NOTE: This is public not because it ought to be called by the user but because there is no easy way to allow every friend operator access to every kind of dimval.
v | Numeric value. |
d | Dimension. |
Definition at line 88 of file dimval.hpp.
|
inline |
Initialize from other dimensioned value.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 95 of file dimval.hpp.
|
inline |
Initialize from dimensionless number.
n | Number. |
Definition at line 99 of file dimval.hpp.
|
inline |
Support cross-product in case it be supported by numeric type.
OT | Numeric type of factor. |
n | Factor. |
Definition at line 302 of file dimval.hpp.
|
inline |
Support cross-product in case it be supported by numeric type.
OT | Numeric type of factor. |
OB | Base-dimension type of factor. |
v | Factor. |
Definition at line 313 of file dimval.hpp.
|
inline |
Exponent for base at specified offset.
off | Offset. |
Definition at line 109 of file dimval.hpp.
|
inline |
Support dot-product in case it be supported by numeric type.
OT | Numeric type of factor. |
n | Factor. |
Definition at line 280 of file dimval.hpp.
|
inline |
Support dot-product in case it be supported by numeric type.
OT | Numeric type of factor. |
OB | Base-dimension type of factor. |
v | Factor. |
Definition at line 291 of file dimval.hpp.
|
inline |
Invert dimensioned value.
Definition at line 335 of file dimval.hpp.
|
inline |
Inequality-comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 130 of file dimval.hpp.
|
inline |
Scale dimensioned value.
This function's scope for matching the template-type parameter is limited by SFINAE.
OT | Type of scale-factor. |
n | Scale-factor. |
Definition at line 237 of file dimval.hpp.
|
inline |
Multiply two dimensioned values.
OT | Numeric type of factor. |
OB | Base-dimension type of factor. |
v | Factor. |
Definition at line 263 of file dimval.hpp.
|
inline |
Modify present instance by multiplying in a dimensionless value.
This function's scope for matching the template-type parameter is limited by SFINAE.
OT | Type of scale-factor. |
v | Dimensionless scale-factor. |
Definition at line 361 of file dimval.hpp.
|
inline |
Sum of two dimensioned values.
OT | Numeric type of addend. |
OB | Base-dimension type of addend. |
v | Addend. |
Definition at line 186 of file dimval.hpp.
|
inline |
Modify present instance by adding in a dimensioned value.
OT | Numeric type of addend. |
OB | Base-dimension type of addend. |
v | Addend. |
Definition at line 210 of file dimval.hpp.
|
inline |
Difference between two dimensioned values.
OT | Numeric type of subtractor. |
OB | Base-dimension type of subtractor. |
v | Subractor. |
Definition at line 198 of file dimval.hpp.
|
inline |
Modify present instance by subtracting out a dimensioned value.
OT | Numeric type of subtractor. |
OB | Base-dimension type of subtractor. |
v | Subtractor. |
Definition at line 222 of file dimval.hpp.
|
inline |
Scale dimensioned quantity by dividing by number.
This function's scope for matching the template-type parameter is limited by SFINAE.
OT | Type of scale-factor. |
n | Scale-divisor. |
Definition at line 328 of file dimval.hpp.
|
inline |
Divide two dimensioned values.
OT | Numeric type of divisor. |
OB | Base-dimension type of divisor. |
v | Divisor. |
Definition at line 346 of file dimval.hpp.
|
inline |
Modify present instance by dividing it by a dimensionless value.
This function's scope for matching the template-type parameter is limited by SFINAE.
OT | Type of scale-factor. |
v | Dimensionless scale-divisor. |
Definition at line 375 of file dimval.hpp.
|
inline |
Less-than comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 141 of file dimval.hpp.
|
inline |
Less-than-or-equal comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 153 of file dimval.hpp.
|
inline |
Equality-comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 118 of file dimval.hpp.
|
inline |
Greater-than comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 165 of file dimval.hpp.
|
inline |
Greater-than-or-equal comparison of two dimensioned values.
This will throw an exception if the dimensions are different.
OT | Numeric type of other dimensioned value. |
OB | Base-dimension type of other dimensioned value. |
v | Reference to other dimensioned value. |
Definition at line 176 of file dimval.hpp.
|
inline |
Support element-access in case it be supported by numeric type.
off | Offset of element. |
Definition at line 271 of file dimval.hpp.
|
inline |
Raise dimensioned value to rational power.
PN | Numerator of power. |
PD | Denominator of power (by default, 1). |
Definition at line 384 of file dimval.hpp.
|
inline |
Raise dimensioned value to rational power.
p | Rational power. |
Definition at line 393 of file dimval.hpp.
|
inline |
Square-root of a dimensioned quantity.
Definition at line 400 of file dimval.hpp.
|
inline |
Convert to dimensionless number.
Definition at line 102 of file dimval.hpp.
Allow access to each kind (float or double) of dyndim.
OT | Type of dyndim's numeric value. |
Definition at line 62 of file dimval.hpp.
|
friend |
Allow access to every kind of statdim.
D | Encoding of dimension in dim::word. |
OT | Type of statdim's numeric value. |
Definition at line 67 of file dimval.hpp.
Allow access to every kind of dimval.
OT | Type of other dimval's numeric value. |
OB | Type of other dimval's base-class for dimension. |
Definition at line 58 of file dimval.hpp.
|
friend |
Scale dimensioned value.
This function's scope for matching the template-type parameter is limited by SFINAE.
OT | Type of scale-factor. |
n | Scale-factor. |
v | Original value. |
Definition at line 252 of file dimval.hpp.
|
friend |