|
Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
|
Defines a collection of unit-enabled, strongly-typed versions of <cmath> functions. More...
Functions | |
| template<class AngleUnit, std::enable_if_t< traits::is_angle_unit_v< AngleUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename AngleUnit::underlying_type > > | units::cos (const AngleUnit angle) noexcept |
| Compute cosine. | |
| template<class AngleUnit, std::enable_if_t< traits::is_angle_unit_v< AngleUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename AngleUnit::underlying_type > > | units::sin (const AngleUnit angle) noexcept |
| Compute sine. | |
| template<class AngleUnit, std::enable_if_t< traits::is_angle_unit_v< AngleUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename AngleUnit::underlying_type > > | units::tan (const AngleUnit angle) noexcept |
| Compute tangent. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| radians< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::acos (const dimensionlessUnit x) noexcept |
| Compute arc cosine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| radians< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::asin (const dimensionlessUnit x) noexcept |
| Compute arc sine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| radians< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::atan (const dimensionlessUnit x) noexcept |
| Compute arc tangent. | |
| template<class Y, class X, std::enable_if_t< traits::is_dimensionless_unit_v< decltype(std::declval< Y >()/std::declval< X >())>, int> | |
| radians< detail::floating_point_promotion_t< std::common_type_t< typename X::underlying_type, typename Y::underlying_type > > > | units::atan2 (const Y y, const X x) noexcept |
| Compute arc tangent with two parameters. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::cosh (const dimensionlessUnit x) noexcept |
| Compute hyperbolic cosine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::sinh (const dimensionlessUnit x) noexcept |
| Compute hyperbolic sine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::tanh (const dimensionlessUnit x) noexcept |
| Compute hyperbolic tangent. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::acosh (const dimensionlessUnit x) noexcept |
| Compute arc hyperbolic cosine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::asinh (const dimensionlessUnit x) noexcept |
| Compute arc hyperbolic sine. | |
| template<class dimensionlessUnit, std::enable_if_t< traits::is_dimensionless_unit_v< dimensionlessUnit >, int > = 0> | |
| dimensionless< detail::floating_point_promotion_t< typename dimensionlessUnit::underlying_type > > | units::atanh (const dimensionlessUnit x) noexcept |
| Compute arc hyperbolic tangent. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::exp (const UnitType x) noexcept |
| Compute exponential function. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::log (const UnitType x) noexcept |
| Compute natural logarithm. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::log10 (const UnitType x) noexcept |
| Compute common logarithm. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::modf (const UnitType x, UnitType *intpart) noexcept |
| Break into fractional and integral parts. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::exp2 (const UnitType x) noexcept |
| Compute binary exponential function. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::expm1 (const UnitType x) noexcept |
| Compute exponential minus one. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::log1p (const UnitType x) noexcept |
| Compute logarithm plus one. | |
| template<DimensionlessUnitType UnitType> | |
| constexpr dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > | units::log2 (const UnitType x) noexcept |
| Compute binary logarithm. | |
| template<UnitType UnitType> requires (traits::has_linear_scale_v<UnitType>) | |
| constexpr auto | units::sqrt (const UnitType &value) noexcept -> detail::rewrap_to_named_t< unit< traits::strong_t< square_root< typename traits::unit_traits< UnitType >::conversion_factor > >, detail::floating_point_promotion_t< typename traits::unit_traits< UnitType >::underlying_type > > > |
| computes the square root of value | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> requires (same_dimension<UnitTypeLhs, UnitTypeRhs> && traits::has_linear_scale_v<UnitTypeLhs, UnitTypeRhs>) | |
| constexpr detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > | units::hypot (const UnitTypeLhs &x, const UnitTypeRhs &y) |
| Computes the square root of the sum-of-squares of x and y. | |
| template<UnitType Unit> | |
| constexpr detail::floating_point_promotion_t< Unit > | units::ceil (const Unit x) noexcept |
| Round up value. | |
| template<UnitType Unit> | |
| constexpr detail::floating_point_promotion_t< Unit > | units::floor (const Unit x) noexcept |
| Round down value. | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> requires (same_dimension<UnitTypeLhs, UnitTypeRhs>) | |
| constexpr detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > | units::fmod (const UnitTypeLhs numer, const UnitTypeRhs denom) noexcept |
| Compute remainder of division. | |
| template<UnitType UnitType> | |
| constexpr detail::floating_point_promotion_t< UnitType > | units::trunc (const UnitType x) noexcept |
| Truncate value. | |
| template<UnitType UnitType> | |
| constexpr detail::floating_point_promotion_t< UnitType > | units::round (const UnitType x) noexcept |
| Round to nearest. | |
| template<class To, UnitType From> requires detail::is_roundable_unit_conversion<To, From> | |
| constexpr To | units::floor (const From &x) noexcept |
| Convert to a coarser integral unit, rounding down (toward negative infinity). | |
| template<class To, UnitType From> requires detail::is_roundable_unit_conversion<To, From> | |
| constexpr To | units::ceil (const From &x) noexcept |
| Convert to a coarser integral unit, rounding up (toward positive infinity). | |
| template<class To, UnitType From> requires detail::is_roundable_unit_conversion<To, From> | |
| constexpr To | units::round (const From &x) noexcept |
| Convert to a coarser integral unit, rounding to nearest (halfway away from zero). | |
| template<class To, UnitType From> requires detail::is_roundable_unit_conversion<To, From> | |
| constexpr To | units::trunc (const From &x) noexcept |
| Convert to a coarser integral unit, rounding toward zero. | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> | |
| constexpr detail::floating_point_promotion_t< UnitTypeLhs > | units::copysign (const UnitTypeLhs x, const UnitTypeRhs y) noexcept |
| Copy sign. | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> requires (same_dimension<UnitTypeLhs, UnitTypeRhs>) | |
| constexpr detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > | units::fdim (const UnitTypeLhs x, const UnitTypeRhs y) noexcept |
| Positive difference. | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> requires (same_dimension<UnitTypeLhs, UnitTypeRhs>) | |
| constexpr detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > | units::fmax (const UnitTypeLhs x, const UnitTypeRhs y) noexcept |
| Maximum value. | |
| template<UnitType UnitTypeLhs, UnitType UnitTypeRhs> requires (same_dimension<UnitTypeLhs, UnitTypeRhs>) | |
| constexpr detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > | units::fmin (const UnitTypeLhs x, const UnitTypeRhs y) noexcept |
| Minimum value. | |
| template<UnitType UnitType> | |
| constexpr detail::floating_point_promotion_t< UnitType > | units::fabs (const UnitType x) noexcept |
| Compute absolute value. | |
| template<UnitType UnitType> | |
| constexpr UnitType | units::abs (const UnitType x) noexcept |
| Compute absolute value. | |
| template<UnitType UnitTypeLhs, UnitType UnitMultiply, UnitType UnitAdd> requires (traits::is_same_dimension_conversion_factor_v< compound_conversion_factor<typename traits::unit_traits<UnitTypeLhs> ::conversion_factor, typename traits::unit_traits<UnitMultiply>::conversion_factor>, typename traits::unit_traits <UnitAdd>::conversion_factor>) | |
| constexpr auto | units::fma (const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept -> std::common_type_t< decltype(detail::floating_point_promotion_t< UnitTypeLhs >(x) *detail::floating_point_promotion_t< UnitMultiply >(y)), UnitAdd > |
| Multiply-add. | |
Defines a collection of unit-enabled, strongly-typed versions of <cmath> functions.
Includes most c++11 extensions.
|
constexprnoexcept |
Compute absolute value.
Returns the absolute value of x, i.e. |x|.
| [in] | x | Value whose absolute value is returned. |
|
noexcept |
Compute arc cosine.
Returns the principal value of the arc cosine of x, expressed in radians.
| [in] | x | Value whose arc cosine is computed, in the interval [-1,+1]. |
|
noexcept |
Compute arc hyperbolic cosine.
The result of an inverse hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is returned as a dimensionless quantity.
| [in] | x | value whose arc hyperbolic cosine is computed. If the argument is less than 1, a domain error occurs. |
|
noexcept |
Compute arc sine.
Returns the principal value of the arc sine of x, expressed in radians.
| [in] | x | Value whose arc sine is computed, in the interval [-1,+1]. |
|
noexcept |
Compute arc hyperbolic sine.
The result of an inverse hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is returned as a dimensionless quantity.
| [in] | x | value whose arc hyperbolic sine is computed. |
|
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.
| AngleUnit | any unit type of dimension::angle. |
| [in] | x | Value whose arc tangent is computed, in the interval [-1,+1]. |
|
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.
| [in] | y | y-component of the triangle expressed. |
| [in] | x | x-component of the triangle expressed. |
|
noexcept |
Compute arc hyperbolic tangent.
The result of an inverse hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is returned as a dimensionless quantity.
| [in] | x | value whose arc hyperbolic tangent is computed, in the interval [-1,+1]. If the argument is out of this interval, a domain error occurs; for -1 and +1 a pole error may occur. |
|
constexprnoexcept |
Convert to a coarser integral unit, rounding up (toward positive infinity).
Run-time lossy conversion with explicit rounding intent; see floor<To>.
| To | the coarser integral target unit. |
| From | the source unit (deduced), same dimension as To. |
| [in] | x | the value to convert. |
|
constexprnoexcept |
Round up value.
Rounds x upward, returning the smallest integral value that is not less than x.
| [in] | x | Unit value to round up. |
|
constexprnoexcept |
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.
| [in] | x | Value with the magnitude of the resulting value. |
| [in] | y | Value with the sign of the resulting value. |
|
noexcept |
Compute cosine.
The input value can be in any unit of angle, including radians or degrees.
| AngleUnit | any unit type of dimension::angle. |
| [in] | angle | angle to compute the cosine of |
|
noexcept |
Compute hyperbolic cosine.
The argument of a hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is taken as a dimensionless quantity and used without any radian conversion.
| dimensionlessUnit | a dimensionless unit type. |
| [in] | x | value to compute the hyperbolic cosine of |
|
constexprnoexcept |
Compute exponential function.
Returns the base-e exponential function of x, which is e raised to the power x: ex.
| [in] | x | dimensionless value of the exponent. |
|
constexprnoexcept |
Compute binary exponential function.
Returns the base-2 exponential function of x, which is 2 raised to the power x: 2^x.
| [in] | x | Value of the exponent. |
|
constexprnoexcept |
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.
| [in] | x | Value of the exponent. |
|
constexprnoexcept |
Compute absolute value.
Returns the absolute value of x, i.e. |x|.
| [in] | x | Value whose absolute value is returned. |
|
constexprnoexcept |
Positive difference.
The function returns x-y if x>y, and zero otherwise, in their common type.
| [in] | x | Values whose difference is calculated. |
| [in] | y | Values whose difference is calculated. |
|
constexprnoexcept |
Convert to a coarser integral unit, rounding down (toward negative infinity).
The run-time counterpart to the compile-time exact narrowing conversion: where bytes<int> b = someRuntimeBits; is correctly rejected (a run-time value need not be a whole number of bytes), units::floor<bytes<int>>(someRuntimeBits) states the rounding intent and yields the number of whole bytes at or below the value. Same shape as std::chrono::floor<To>.
| To | the coarser integral target unit (e.g. bytes<int>). |
| From | the source unit (deduced), same dimension as To. |
| [in] | x | the value to convert. |
|
constexprnoexcept |
Round down value.
Rounds x downward, returning the largest integral value that is not greater than x.
| [in] | x | Unit value to round down. |
|
constexprnoexcept |
Multiply-add.
Returns x*y+z, computed with a single rounding via std::fma — preserving both the accuracy and the performance contract of the underlying operation (a fused multiply-add maps to one hardware instruction where available). The three operands may be expressed in different units of their respective dimensions; each is reconciled to the result unit within the single fused step so the multiply and the add share a consistent basis. The result unit is the common type of the product x*y and the addend z.
| [in] | x | Value to be multiplied. |
| [in] | y | Value to be multiplied. |
| [in] | z | Value to be added. |
|
constexprnoexcept |
Maximum value.
Returns the larger of its arguments: either x or y, in their common type.
| [in] | x | Values among which the function selects a maximum. |
| [in] | y | Values among which the function selects a maximum. |
|
constexprnoexcept |
Minimum value.
Returns the smaller of its arguments: either x or y, in their common type. If one of the arguments in a NaN, the other is returned.
| [in] | x | Values among which the function selects a minimum. |
| [in] | y | Values among which the function selects a minimum. |
|
constexprnoexcept |
Compute remainder of division.
Returns the floating-point remainder of numer/denom (rounded towards zero).
| [in] | numer | Value of the quotient numerator. |
| [in] | denom | Value of the quotient denominator. |
|
constexpr |
Computes the square root of the sum-of-squares of x and y.
Only implemented for linear_scale units.
| [in] | x | unit type value |
| [in] | y | unit type value |
|
constexprnoexcept |
Compute natural logarithm.
Returns the natural logarithm of x.
| [in] | x | dimensionless value whose logarithm is calculated. If the argument is negative, a domain error occurs. |
|
constexprnoexcept |
Compute common logarithm.
Returns the common (base-10) logarithm of x.
| [in] | x | Value whose logarithm is calculated. If the argument is negative, a domain error occurs. |
|
constexprnoexcept |
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).
| [in] | x | Value whose logarithm is calculated. If the argument is less than -1, a domain error occurs. |
|
constexprnoexcept |
Compute binary logarithm.
Returns the binary (base-2) logarithm of x.
| [in] | x | Value whose logarithm is calculated. If the argument is negative, a domain error occurs. |
|
constexprnoexcept |
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.
| [in] | x | dimensionless value to break into parts. |
| [in] | intpart | Pointer to an object (of the same type as x) where the integral part is stored with the same sign as x. |
|
constexprnoexcept |
Convert to a coarser integral unit, rounding to nearest (halfway away from zero).
Run-time lossy conversion with explicit rounding intent; see floor<To>.
| To | the coarser integral target unit. |
| From | the source unit (deduced), same dimension as To. |
| [in] | x | the value to convert. |
|
constexprnoexcept |
Round to nearest.
Returns the integral value that is nearest to x, with halfway cases rounded away from zero.
| [in] | x | value to round. |
|
noexcept |
Compute sine.
The input value can be in any unit of angle, including radians or degrees.
| AngleUnit | any unit type of dimension::angle. |
| [in] | angle | angle to compute the since of |
|
noexcept |
Compute hyperbolic sine.
The argument of a hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is taken as a dimensionless quantity and used without any radian conversion.
| dimensionlessUnit | a dimensionless unit type. |
| [in] | x | value to compute the hyperbolic sine of |
|
constexprnoexcept |
computes the square root of value
Only implemented for linear_scale units.
| [in] | value | unit derived type to compute the square root of. |
|
noexcept |
Compute tangent.
The input value can be in any unit of angle, including radians or degrees.
| AngleUnit | any unit type of dimension::angle. |
| [in] | angle | angle to compute the tangent of |
|
noexcept |
Compute hyperbolic tangent.
The argument of a hyperbolic function is a dimensionless real number (a hyperbolic angle), not a geometric angle, so it is taken as a dimensionless quantity and used without any radian conversion.
| dimensionlessUnit | a dimensionless unit type. |
| [in] | x | value to compute the hyperbolic tangent of |
|
constexprnoexcept |
Convert to a coarser integral unit, rounding toward zero.
Run-time lossy conversion with explicit rounding intent; see floor<To>.
| To | the coarser integral target unit. |
| From | the source unit (deduced), same dimension as To. |
| [in] | x | the value to convert. |
|
constexprnoexcept |
Truncate value.
Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. Effectively rounds towards 0.
| [in] | x | Value to truncate |