Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
Loading...
Searching...
No Matches
Unit Math

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.

Detailed Description

Defines a collection of unit-enabled, strongly-typed versions of <cmath> functions.

Includes most c++11 extensions.

Function Documentation

◆ abs()

template<UnitType UnitType>
UnitType units::abs ( const UnitType x)
constexprnoexcept

Compute absolute value.

Returns the absolute value of x, i.e. |x|.

Parameters
[in]xValue whose absolute value is returned.
Returns
The absolute value of x.

◆ acos()

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.

Returns the principal value of the arc cosine of x, expressed in radians.

Parameters
[in]xValue whose arc cosine is computed, in the interval [-1,+1].
Returns
Principal arc cosine of x, in the interval [0,pi] radians.

◆ acosh()

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.

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.

Parameters
[in]xvalue whose arc hyperbolic cosine is computed. If the argument is less than 1, a domain error occurs.
Returns
the nonnegative arc hyperbolic cosine of x, as a dimensionless quantity.

◆ asin()

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.

Returns the principal value of the arc sine of x, expressed in radians.

Parameters
[in]xValue whose arc sine is computed, in the interval [-1,+1].
Returns
Principal arc sine of x, in the interval [-pi/2,+pi/2] radians.

◆ asinh()

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.

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.

Parameters
[in]xvalue whose arc hyperbolic sine is computed.
Returns
the arc hyperbolic sine of x, as a dimensionless quantity.

◆ atan()

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.

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
AngleUnitany unit type of dimension::angle.
Parameters
[in]xValue whose arc tangent is computed, in the interval [-1,+1].
Returns
Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.

◆ atan2()

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.

To compute the value, the function takes into account the sign of both arguments in order to determine the quadrant.

Parameters
[in]yy-component of the triangle expressed.
[in]xx-component of the triangle expressed.
Returns
Returns the principal value of the arc tangent of y/x, expressed in radians.

◆ atanh()

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.

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.

Parameters
[in]xvalue 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.
Returns
the arc hyperbolic tangent of x, as a dimensionless quantity.

◆ ceil() [1/2]

template<class To, UnitType From>
requires detail::is_roundable_unit_conversion<To, From>
To units::ceil ( const From & x)
constexprnoexcept

Convert to a coarser integral unit, rounding up (toward positive infinity).

Run-time lossy conversion with explicit rounding intent; see floor<To>.

Template Parameters
Tothe coarser integral target unit.
Fromthe source unit (deduced), same dimension as To.
Parameters
[in]xthe value to convert.
Returns
x in units of To, rounded toward positive infinity.

◆ ceil() [2/2]

template<UnitType Unit>
detail::floating_point_promotion_t< Unit > units::ceil ( const Unit x)
constexprnoexcept

Round up value.

Rounds x upward, returning the smallest integral value that is not less than x.

Parameters
[in]xUnit value to round up.
Returns
The smallest integral value that is not less than x.

◆ copysign()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
detail::floating_point_promotion_t< UnitTypeLhs > units::copysign ( const UnitTypeLhs x,
const UnitTypeRhs y )
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.

Parameters
[in]xValue with the magnitude of the resulting value.
[in]yValue with the sign of the resulting value.
Returns
value with the magnitude and dimension of x, and the sign of y.

◆ cos()

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.

The input value can be in any unit of angle, including radians or degrees.

Template Parameters
AngleUnitany unit type of dimension::angle.
Parameters
[in]angleangle to compute the cosine of
Returns
Returns the cosine of angle

◆ cosh()

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.

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.

Template Parameters
dimensionlessUnita dimensionless unit type.
Parameters
[in]xvalue to compute the hyperbolic cosine of
Returns
the hyperbolic cosine of x

◆ exp()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::exp ( const UnitType x)
constexprnoexcept

Compute exponential function.

Returns the base-e exponential function of x, which is e raised to the power x: ex.

Parameters
[in]xdimensionless value of the exponent.
Returns
Exponential value of x. If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs

◆ exp2()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::exp2 ( const UnitType x)
constexprnoexcept

Compute binary exponential function.

Returns the base-2 exponential function of x, which is 2 raised to the power x: 2^x.

Parameters
[in]xValue of the exponent.
Returns
2 raised to the power of x.

◆ expm1()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::expm1 ( const UnitType x)
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.

Parameters
[in]xValue of the exponent.
Returns
e raised to the power of x, minus one.

◆ fabs()

template<UnitType UnitType>
detail::floating_point_promotion_t< UnitType > units::fabs ( const UnitType x)
constexprnoexcept

Compute absolute value.

Returns the absolute value of x, i.e. |x|.

Parameters
[in]xValue whose absolute value is returned.
Returns
The absolute value of x.

◆ fdim()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
requires (same_dimension<UnitTypeLhs, UnitTypeRhs>)
detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > units::fdim ( const UnitTypeLhs x,
const UnitTypeRhs y )
constexprnoexcept

Positive difference.

The function returns x-y if x>y, and zero otherwise, in their common type.

Parameters
[in]xValues whose difference is calculated.
[in]yValues whose difference is calculated.
Returns
The positive difference between x and y.

◆ floor() [1/2]

template<class To, UnitType From>
requires detail::is_roundable_unit_conversion<To, From>
To units::floor ( const From & x)
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>.

Template Parameters
Tothe coarser integral target unit (e.g. bytes<int>).
Fromthe source unit (deduced), same dimension as To.
Parameters
[in]xthe value to convert.
Returns
x in units of To, rounded toward negative infinity.

◆ floor() [2/2]

template<UnitType Unit>
detail::floating_point_promotion_t< Unit > units::floor ( const Unit x)
constexprnoexcept

Round down value.

Rounds x downward, returning the largest integral value that is not greater than x.

Parameters
[in]xUnit value to round down.
Returns
The value of x rounded downward.

◆ fma()

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>)
auto units::fma ( const UnitTypeLhs x,
const UnitMultiply y,
const UnitAdd z ) -> std::common_type_t< decltype(detail::floating_point_promotion_t< UnitTypeLhs >(x) *detail::floating_point_promotion_t< UnitMultiply >(y)), UnitAdd >
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.

Parameters
[in]xValue to be multiplied.
[in]yValue to be multiplied.
[in]zValue to be added.
Returns
The result of x*y+z.

◆ fmax()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
requires (same_dimension<UnitTypeLhs, UnitTypeRhs>)
detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > units::fmax ( const UnitTypeLhs x,
const UnitTypeRhs y )
constexprnoexcept

Maximum value.

Returns the larger of its arguments: either x or y, in their common type.

Parameters
[in]xValues among which the function selects a maximum.
[in]yValues among which the function selects a maximum.
Returns
The maximum numeric value of its arguments.

◆ fmin()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
requires (same_dimension<UnitTypeLhs, UnitTypeRhs>)
detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > units::fmin ( const UnitTypeLhs x,
const UnitTypeRhs y )
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.

Parameters
[in]xValues among which the function selects a minimum.
[in]yValues among which the function selects a minimum.
Returns
The minimum numeric value of its arguments.

◆ fmod()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
requires (same_dimension<UnitTypeLhs, UnitTypeRhs>)
detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > units::fmod ( const UnitTypeLhs numer,
const UnitTypeRhs denom )
constexprnoexcept

Compute remainder of division.

Returns the floating-point remainder of numer/denom (rounded towards zero).

Parameters
[in]numerValue of the quotient numerator.
[in]denomValue of the quotient denominator.
Returns
The remainder of dividing the arguments.

◆ hypot()

template<UnitType UnitTypeLhs, UnitType UnitTypeRhs>
requires (same_dimension<UnitTypeLhs, UnitTypeRhs> && traits::has_linear_scale_v<UnitTypeLhs, UnitTypeRhs>)
detail::floating_point_promotion_t< std::common_type_t< UnitTypeLhs, UnitTypeRhs > > units::hypot ( const UnitTypeLhs & x,
const UnitTypeRhs & y )
constexpr

Computes the square root of the sum-of-squares of x and y.

Only implemented for linear_scale units.

Parameters
[in]xunit type value
[in]yunit type value
Returns
square root of the sum-of-squares of x and y in the same units as x.

◆ log()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::log ( const UnitType x)
constexprnoexcept

Compute natural logarithm.

Returns the natural logarithm of x.

Parameters
[in]xdimensionless value whose logarithm is calculated. If the argument is negative, a domain error occurs.
See also
log10 for more common base-10 logarithms
Returns
Natural logarithm of x.

◆ log10()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::log10 ( const UnitType x)
constexprnoexcept

Compute common logarithm.

Returns the common (base-10) logarithm of x.

Parameters
[in]xValue whose logarithm is calculated. If the argument is negative, a domain error occurs.
Returns
Common logarithm of x.

◆ log1p()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::log1p ( const UnitType x)
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).

Parameters
[in]xValue whose logarithm is calculated. If the argument is less than -1, a domain error occurs.
Returns
The natural logarithm of (1+x).

◆ log2()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::log2 ( const UnitType x)
constexprnoexcept

Compute binary logarithm.

Returns the binary (base-2) logarithm of x.

Parameters
[in]xValue whose logarithm is calculated. If the argument is negative, a domain error occurs.
Returns
The binary logarithm of x: log2x.

◆ modf()

template<DimensionlessUnitType UnitType>
dimensionless< detail::floating_point_promotion_t< typename UnitType::underlying_type > > units::modf ( const UnitType x,
UnitType * intpart )
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.

Parameters
[in]xdimensionless value to break into parts.
[in]intpartPointer to an object (of the same type as x) where the integral part is stored with the same sign as x.
Returns
The fractional part of x, with the same sign.

◆ round() [1/2]

template<class To, UnitType From>
requires detail::is_roundable_unit_conversion<To, From>
To units::round ( const From & 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>.

Template Parameters
Tothe coarser integral target unit.
Fromthe source unit (deduced), same dimension as To.
Parameters
[in]xthe value to convert.
Returns
x in units of To, rounded to the nearest whole target unit.

◆ round() [2/2]

template<UnitType UnitType>
detail::floating_point_promotion_t< UnitType > units::round ( const UnitType x)
constexprnoexcept

Round to nearest.

Returns the integral value that is nearest to x, with halfway cases rounded away from zero.

Parameters
[in]xvalue to round.
Returns
The value of x rounded to the nearest integral.

◆ sin()

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.

The input value can be in any unit of angle, including radians or degrees.

Template Parameters
AngleUnitany unit type of dimension::angle.
Parameters
[in]angleangle to compute the since of
Returns
Returns the sine of angle

◆ sinh()

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.

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.

Template Parameters
dimensionlessUnita dimensionless unit type.
Parameters
[in]xvalue to compute the hyperbolic sine of
Returns
the hyperbolic sine of x

◆ sqrt()

template<UnitType UnitType>
requires (traits::has_linear_scale_v<UnitType>)
auto units::sqrt ( const UnitType & value) -> 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 > > >
constexprnoexcept

computes the square root of value

Only implemented for linear_scale units.

Parameters
[in]valueunit derived type to compute the square root of.
Returns
new unit, whose units are the square root of value's. E.g. if values had units of square_meter, then the return type will have units of meter.
Note
sqrt provides a rational approximation of the square root of value. In some cases, both the returned value and conversion factor of the returned unit type may have errors no larger than 1e-10.

◆ tan()

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.

The input value can be in any unit of angle, including radians or degrees.

Template Parameters
AngleUnitany unit type of dimension::angle.
Parameters
[in]angleangle to compute the tangent of
Returns
Returns the tangent of angle

◆ tanh()

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.

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.

Template Parameters
dimensionlessUnita dimensionless unit type.
Parameters
[in]xvalue to compute the hyperbolic tangent of
Returns
the hyperbolic tangent of x

◆ trunc() [1/2]

template<class To, UnitType From>
requires detail::is_roundable_unit_conversion<To, From>
To units::trunc ( const From & x)
constexprnoexcept

Convert to a coarser integral unit, rounding toward zero.

Run-time lossy conversion with explicit rounding intent; see floor<To>.

Template Parameters
Tothe coarser integral target unit.
Fromthe source unit (deduced), same dimension as To.
Parameters
[in]xthe value to convert.
Returns
x in units of To, rounded toward zero.

◆ trunc() [2/2]

template<UnitType UnitType>
detail::floating_point_promotion_t< UnitType > units::trunc ( const UnitType x)
constexprnoexcept

Truncate value.

Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. Effectively rounds towards 0.

Parameters
[in]xValue to truncate
Returns
The nearest integral value that is not larger in magnitude than x.