UnitMath(3)
| UnitMath(3) | Unit Conversion and Dimensional Analysis Library | UnitMath(3) |
NAME
UnitMath - Unit Math
- Defines a collection of unit-enabled, strongly-typed versions of
<cmath> functions.
SYNOPSIS
Functions
template<class AngleUnit > dimensionless::scalar_t
units::math::cos (const AngleUnit angle) noexcept
Compute cosine. template<class AngleUnit >
dimensionless::scalar_t units::math::sin (const AngleUnit
angle) noexcept
Compute sine. template<class AngleUnit > dimensionless::scalar_t
units::math::tan (const AngleUnit angle) noexcept
Compute tangent. template<class ScalarUnit > angle::radian_t
units::math::acos (const ScalarUnit x) noexcept
Compute arc cosine. template<class ScalarUnit > angle::radian_t
units::math::asin (const ScalarUnit x) noexcept
Compute arc sine. template<class ScalarUnit > angle::radian_t
units::math::atan (const ScalarUnit x) noexcept
Compute arc tangent. template<class Y , class X > angle::radian_t
units::math::atan2 (const Y y, const X x) noexcept
Compute arc tangent with two parameters. template<class AngleUnit >
dimensionless::scalar_t units::math::cosh (const AngleUnit
angle) noexcept
Compute hyperbolic cosine. template<class AngleUnit >
dimensionless::scalar_t units::math::sinh (const AngleUnit
angle) noexcept
Compute hyperbolic sine. template<class AngleUnit >
dimensionless::scalar_t units::math::tanh (const AngleUnit
angle) noexcept
Compute hyperbolic tangent. template<class ScalarUnit >
angle::radian_t units::math::acosh (const ScalarUnit x)
noexcept
Compute arc hyperbolic cosine. template<class ScalarUnit >
angle::radian_t units::math::asinh (const ScalarUnit x)
noexcept
Compute arc hyperbolic sine. template<class ScalarUnit >
angle::radian_t units::math::atanh (const ScalarUnit x)
noexcept
Compute arc hyperbolic tangent. template<class ScalarUnit >
dimensionless::scalar_t units::math::exp (const ScalarUnit x)
noexcept
Compute exponential function. template<class ScalarUnit >
dimensionless::scalar_t units::math::log (const ScalarUnit x)
noexcept
Compute natural logarithm. template<class ScalarUnit >
dimensionless::scalar_t units::math::log10 (const ScalarUnit
x) noexcept
Compute common logarithm. template<class ScalarUnit >
dimensionless::scalar_t units::math::modf (const ScalarUnit x,
ScalarUnit *intpart) noexcept
Break into fractional and integral parts. template<class ScalarUnit >
dimensionless::scalar_t units::math::exp2 (const ScalarUnit x)
noexcept
Compute binary exponential function. template<class ScalarUnit >
dimensionless::scalar_t units::math::expm1 (const ScalarUnit
x) noexcept
Compute exponential minus one. template<class ScalarUnit >
dimensionless::scalar_t units::math::log1p (const ScalarUnit
x) noexcept
Compute logarithm plus one. template<class ScalarUnit >
dimensionless::scalar_t units::math::log2 (const ScalarUnit x)
noexcept
Compute binary logarithm. template<class UnitType , std::enable_if_t<
units::traits::has_linear_scale< UnitType >::value, int > =
0> auto units::math::sqrt (const UnitType &value) noexcept
-> unit_t< square_root< typename
units::traits::unit_t_traits< UnitType >::unit_type >, typename
units::traits::unit_t_traits< UnitType >::underlying_type,
linear_scale >
computes the square root of value template<class UnitTypeLhs , class
UnitTypeRhs , std::enable_if_t<
units::traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs
>::value, int > = 0> UnitTypeLhs units::math::hypot (const
UnitTypeLhs &x, const UnitTypeRhs &y)
Computes the square root of the sum-of-squares of x and y. template<class
UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::ceil (const UnitType x) noexcept
Round up value. template<class UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::floor (const UnitType x) noexcept
Round down value. template<class UnitTypeLhs , class UnitTypeRhs , class =
std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs
units::math::fmod (const UnitTypeLhs numer, const UnitTypeRhs denom)
noexcept
Compute remainder of division. template<class UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::trunc (const UnitType x) noexcept
Truncate value. template<class UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::round (const UnitType x) noexcept
Round to nearest. template<class UnitTypeLhs , class UnitTypeRhs , class =
std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs
units::math::copysign (const UnitTypeLhs x, const UnitTypeRhs y)
noexcept
Copy sign. template<class UnitTypeLhs , class UnitTypeRhs , class =
std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs
units::math::fdim (const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Positive difference. template<class UnitTypeLhs , class UnitTypeRhs , class
= std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs
units::math::fmax (const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Maximum value. template<class UnitTypeLhs , class UnitTypeRhs , class =
std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs
units::math::fmin (const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Minimum value. template<class UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::fabs (const UnitType x) noexcept
Compute absolute value. template<class UnitType , class =
std::enable_if_t<traits::is_unit_t<UnitType>::value>>
UnitType units::math::abs (const UnitType x) noexcept
Compute absolute value. template<class UnitTypeLhs , class UnitMultiply ,
class UnitAdd , class =
std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
traits::is_unit_t<UnitMultiply>::value &&
traits::is_unit_t<UnitAdd>::value>> auto units::math::fma
(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept ->
decltype(x *y)
Multiply-add.
Detailed Description
Defines a collection of unit-enabled, strongly-typed versions of <cmath> functions.
Includes most c++11 extensions.
Function Documentation
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::abs (const UnitType x) [noexcept]
Compute absolute value. Returns the absolute value of x, i.e. |x|.
Parameters
Returns
template<class ScalarUnit > angle::radian_t units::math::acos (const ScalarUnit x) [noexcept]
Compute arc cosine. Returns the principal value of the arc cosine of x, expressed in radians.
Parameters
Returns
template<class ScalarUnit > angle::radian_t units::math::acosh (const ScalarUnit x) [noexcept]
Compute arc hyperbolic cosine. Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.
Parameters
Returns
template<class ScalarUnit > angle::radian_t units::math::asin (const ScalarUnit x) [noexcept]
Compute arc sine. Returns the principal value of the arc sine of x, expressed in radians.
Parameters
Returns
template<class ScalarUnit > angle::radian_t units::math::asinh (const ScalarUnit x) [noexcept]
Compute arc hyperbolic sine. Returns the arc hyperbolic sine of x, expressed in radians.
Parameters
Returns
template<class ScalarUnit > angle::radian_t units::math::atan (const ScalarUnit x) [noexcept]
Compute arc tangent. Returns the principal value of the arc tangent of x, expressed in radians. Notice that because of the sign ambiguity, the function cannot determine with certainty in which quadrant the angle falls only by its tangent value. See atan2 for an alternative that takes a fractional argument instead.
Template Parameters
Parameters
Returns
template<class Y , class X > angle::radian_t units::math::atan2 (const Y y, const X x) [noexcept]
Compute arc tangent with two parameters. To compute the value, the function takes into account the sign of both arguments in order to determine the quadrant.
Parameters
x x-component of the triangle expressed.
Returns
template<class ScalarUnit > angle::radian_t units::math::atanh (const ScalarUnit x) [noexcept]
Compute arc hyperbolic tangent. Returns the arc hyperbolic tangent of x, expressed in radians.
Parameters
Returns
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::ceil (const UnitType x) [noexcept]
Round up value. Rounds x upward, returning the smallest integral value that is not less than x.
Parameters
Returns
template<class UnitTypeLhs , class UnitTypeRhs , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs units::math::copysign (const UnitTypeLhs x, const UnitTypeRhs y) [noexcept]
Copy sign. Returns a value with the magnitude and dimension of x, and the sign of y. Values x and y do not have to be compatible units.
Parameters
y Value with the sign of the resulting value.
Returns
template<class AngleUnit > dimensionless::scalar_t units::math::cos (const AngleUnit angle) [noexcept]
Compute cosine. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class AngleUnit > dimensionless::scalar_t units::math::cosh (const AngleUnit angle) [noexcept]
Compute hyperbolic cosine. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::exp (const ScalarUnit x) [noexcept]
Compute exponential function. Returns the base-e exponential function of x, which is e raised to the power x: ex.
Parameters
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::exp2 (const ScalarUnit x) [noexcept]
Compute binary exponential function. Returns the base-2 exponential function of x, which is 2 raised to the power x: 2^x. 2param[in] x Value of the exponent.
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::expm1 (const ScalarUnit x) [noexcept]
Compute exponential minus one. Returns e raised to the power x minus one: e^x-1. For small magnitude values of x, expm1 may be more accurate than exp(x)-1.
Parameters
Returns
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::fabs (const UnitType x) [noexcept]
Compute absolute value. Returns the absolute value of x, i.e. |x|.
Parameters
Returns
template<class UnitTypeLhs , class UnitTypeRhs , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs units::math::fdim (const UnitTypeLhs x, const UnitTypeRhs y) [noexcept]
Positive difference. The function returns x-y if x>y, and zero otherwise, in the same units as x. Values x and y do not have to be the same type of units, but they do have to be compatible.
Parameters
y Values whose difference is calculated.
Returns
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::floor (const UnitType x) [noexcept]
Round down value. Rounds x downward, returning the largest integral value that is not greater than x.
Parameters
Returns
template<class UnitTypeLhs , class UnitMultiply , class UnitAdd , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitMultiply>::value && traits::is_unit_t<UnitAdd>::value>> auto units::math::fma (const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) -> decltype(x * y)
[noexcept]"
Multiply-add. Returns x*y+z. The function computes the result without losing precision in any intermediate result. The resulting unit type is a compound unit of x* y.
Parameters
y Values to be multiplied.
z Value to be added.
Returns
template<class UnitTypeLhs , class UnitTypeRhs , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs units::math::fmax (const UnitTypeLhs x, const UnitTypeRhs y) [noexcept]
Maximum value. Returns the larger of its arguments: either x or y, in the same units as x. Values x and y do not have to be the same type of units, but they do have to be compatible.
Parameters
y Values among which the function selects a maximum.
Returns
template<class UnitTypeLhs , class UnitTypeRhs , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs units::math::fmin (const UnitTypeLhs x, const UnitTypeRhs y) [noexcept]
Minimum value. Returns the smaller of its arguments: either x or y, in the same units as x. If one of the arguments in a NaN, the other is returned. Values x and y do not have to be the same type of units, but they do have to be compatible.
Parameters
y Values among which the function selects a minimum.
Returns
template<class UnitTypeLhs , class UnitTypeRhs , class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value && traits::is_unit_t<UnitTypeRhs>::value>> UnitTypeLhs units::math::fmod (const UnitTypeLhs numer, const UnitTypeRhs denom) [noexcept]
Compute remainder of division. Returns the floating-point remainder of numer/denom (rounded towards zero).
Parameters
denom Value of the quotient denominator.
Returns
template<class UnitTypeLhs , class UnitTypeRhs , std::enable_if_t< units::traits::has_linear_scale< UnitTypeLhs, UnitTypeRhs >::value, int > = 0> UnitTypeLhs units::math::hypot (const UnitTypeLhs & x, const UnitTypeRhs & y) [inline]
Computes the square root of the sum-of-squares of x and y. Only implemented for linear_scale units.
Parameters
y unit_t type value
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::log (const ScalarUnit x) [noexcept]
Compute natural logarithm. Returns the natural logarithm of x.
Parameters
See also
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::log10 (const ScalarUnit x) [noexcept]
Compute common logarithm. Returns the common (base-10) logarithm of x.
Parameters
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::log1p (const ScalarUnit x) [noexcept]
Compute logarithm plus one. Returns the natural logarithm of one plus x. For small magnitude values of x, logp1 may be more accurate than log(1+x).
Parameters
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::log2 (const ScalarUnit x) [noexcept]
Compute binary logarithm. Returns the binary (base-2) logarithm of x.
Parameters
Returns
template<class ScalarUnit > dimensionless::scalar_t units::math::modf (const ScalarUnit x, ScalarUnit * intpart) [noexcept]
Break into fractional and integral parts. The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function. Both parts have the same sign as x.
Parameters
intpart Pointer to an object (of the same type as x) where the integral part is stored with the same sign as x.
Returns
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::round (const UnitType x) [noexcept]
Round to nearest. Returns the integral value that is nearest to x, with halfway cases rounded away from zero.
Parameters
Returns
template<class AngleUnit > dimensionless::scalar_t units::math::sin (const AngleUnit angle) [noexcept]
Compute sine. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class AngleUnit > dimensionless::scalar_t units::math::sinh (const AngleUnit angle) [noexcept]
Compute hyperbolic sine. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class UnitType , std::enable_if_t< units::traits::has_linear_scale< UnitType >::value, int > = 0> auto units::math::sqrt (const UnitType & value) -> unit_t<square_root<typename units::traits::unit_t_traits<UnitType>::unit_type>, typename units::traits::unit_t_traits<UnitType>::underlying_type, linear_scale>
[inline], [noexcept]"
computes the square root of value Only implemented for linear_scale units.
Parameters
Returns
Note
template<class AngleUnit > dimensionless::scalar_t units::math::tan (const AngleUnit angle) [noexcept]
Compute tangent. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class AngleUnit > dimensionless::scalar_t units::math::tanh (const AngleUnit angle) [noexcept]
Compute hyperbolic tangent. The input value can be in any unit of angle, including radians or degrees.
Template Parameters
Parameters
Returns
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> UnitType units::math::trunc (const UnitType x) [noexcept]
Truncate value. Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. Effectively rounds towards 0.
Parameters
Returns
Author
Generated automatically by Doxygen for Unit Conversion and Dimensional Analysis Library from the source code.
| Wed Mar 29 2023 | Version 2.3.0 |
