Unit Conversion and Dimensional Analysis Library
2.3.0
A compile-time c++14 unit conversion library
|
Defines a series of classes to obtain unit type information at compile-time. More...
Namespaces | |
units::traits | |
namespace representing type traits which can access the properties of types provided by the units library. | |
Classes | |
struct | units::traits::is_base_unit< T > |
Trait which tests if a class is a base_unit type. More... | |
struct | units::traits::is_unit< T > |
Traits which tests if a class is a unit More... | |
struct | units::traits::is_convertible_unit< U1, U2 > |
Trait which checks whether two units can be converted to each other. More... | |
struct | units::traits::is_nonlinear_scale< T, Ret > |
Trait which tests that class T meets the requirements for a non-linear scale. More... | |
struct | units::traits::is_convertible_unit_t< U1, U2 > |
Trait which tests whether two container types derived from unit_t are convertible to each other. More... | |
struct | units::traits::is_unit_t< T > |
Traits which tests if a class is a unit More... | |
struct | units::traits::has_linear_scale< T > |
Trait which tests whether a type is inherited from a linear scale. More... | |
struct | units::traits::has_decibel_scale< T > |
Trait which tests whether a type is inherited from a decibel scale. More... | |
struct | units::traits::is_same_scale< T1, T2 > |
Trait which tests whether two types has the same non-linear scale. More... | |
struct | units::traits::is_unit_value_t< T, Units > |
Trait which tests whether a type is a unit_value_t representing the given unit type. More... | |
struct | units::traits::is_unit_value_t_category< Category, T > |
Trait which tests whether type T is a unit_value_t with a unit type in the given category. More... | |
Typedefs | |
template<typename Ratio , std::intmax_t Eps = 10000000000> | |
using | units::ratio_sqrt = typename units::detail::Sqrt< Ratio, std::ratio< 1, Eps > >::type |
Calculate square root of a ratio at compile-time. More... | |
Defines a series of classes to obtain unit type information at compile-time.
using units::ratio_sqrt = typedef typename units::detail::Sqrt<Ratio, std::ratio<1, Eps> >::type |
Calculate square root of a ratio at compile-time.
Calculates a rational approximation of the square root of the ratio. The error in the calculation is bounded by 1/epsilon (Eps). E.g. for the default value of 10000000000, the maximum error will be a/10000000000, or 1e-8, or said another way, the error will be on the order of 10^-9. Since these calculations are done at compile time, it is advisable to set epsilon to the highest value that does not cause an integer overflow in the calculation. If you can't compile ratio_sqrt
due to overflow errors, reducing the value of epsilon sufficiently will correct the problem.
ratio_sqrt
is guaranteed to converge for all values of Ratio
which do not overflow.
Ratio | ratio to take the square root of. This can represent any rational value, not just integers or values with integer roots. |
Eps | Value of epsilon, which represents the inverse of the maximum allowable error. This value should be chosen to be as high as possible before integer overflow errors occur in the compiler. |