WPILibC++ 2023.4.3
|
Defines a collection of unit-enabled, strongly-typed versions of <cmath>
functions.
More...
Functions | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::cos (const AngleUnit angle) noexcept |
Compute cosine. More... | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::sin (const AngleUnit angle) noexcept |
Compute sine. More... | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::tan (const AngleUnit angle) noexcept |
Compute tangent. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::acos (const ScalarUnit x) noexcept |
Compute arc cosine. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::asin (const ScalarUnit x) noexcept |
Compute arc sine. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::atan (const ScalarUnit x) noexcept |
Compute arc tangent. More... | |
template<class Y , class X > | |
angle::radian_t | units::math::atan2 (const Y y, const X x) noexcept |
Compute arc tangent with two parameters. More... | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::cosh (const AngleUnit angle) noexcept |
Compute hyperbolic cosine. More... | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::sinh (const AngleUnit angle) noexcept |
Compute hyperbolic sine. More... | |
template<class AngleUnit > | |
dimensionless::scalar_t | units::math::tanh (const AngleUnit angle) noexcept |
Compute hyperbolic tangent. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::acosh (const ScalarUnit x) noexcept |
Compute arc hyperbolic cosine. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::asinh (const ScalarUnit x) noexcept |
Compute arc hyperbolic sine. More... | |
template<class ScalarUnit > | |
angle::radian_t | units::math::atanh (const ScalarUnit x) noexcept |
Compute arc hyperbolic tangent. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::exp (const ScalarUnit x) noexcept |
Compute exponential function. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::log (const ScalarUnit x) noexcept |
Compute natural logarithm. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::log10 (const ScalarUnit x) noexcept |
Compute common logarithm. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::modf (const ScalarUnit x, ScalarUnit *intpart) noexcept |
Break into fractional and integral parts. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::exp2 (const ScalarUnit x) noexcept |
Compute binary exponential function. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::expm1 (const ScalarUnit x) noexcept |
Compute exponential minus one. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::log1p (const ScalarUnit x) noexcept |
Compute logarithm plus one. More... | |
template<class ScalarUnit > | |
dimensionless::scalar_t | units::math::log2 (const ScalarUnit x) noexcept |
Compute binary logarithm. More... | |
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 More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<class UnitType , class = std::enable_if_t<traits::is_unit_t<UnitType>::value>> | |
UnitType | units::math::trunc (const UnitType x) noexcept |
Truncate value. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Defines a collection of unit-enabled, strongly-typed versions of <cmath>
functions.
Includes most c++11 extensions.
|
noexcept |
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.
Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.
[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.
Returns the arc hyperbolic sine of x, expressed in radians.
[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_t type of category::angle_unit . |
[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.
Returns the arc hyperbolic tangent of x, expressed in radians.
[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 values of -1 and +1, a pole error may occur. |
|
noexcept |
Round up value.
Rounds x upward, returning the smallest integral value that is not less than x.
[in] | x | Unit value to round up. |
|
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.
[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_t type of category::angle_unit . |
[in] | angle | angle to compute the cosine of |
|
noexcept |
Compute hyperbolic cosine.
The input value can be in any unit of angle, including radians or degrees.
AngleUnit | any unit_t type of category::angle_unit . |
[in] | angle | angle to compute the hyperbolic cosine of |
|
noexcept |
Compute exponential function.
Returns the base-e exponential function of x, which is e raised to the power x: ex.
[in] | x | scalar value of the exponent. |
|
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.
|
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.
[in] | x | Value of the exponent. |
|
noexcept |
Compute absolute value.
Returns the absolute value of x, i.e. |x|.
[in] | x | Value whose absolute value is returned. |
|
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.
[in] | x | Values whose difference is calculated. |
[in] | y | Values whose difference is calculated. |
|
noexcept |
Round down value.
Rounds x downward, returning the largest integral value that is not greater than x.
[in] | x | Unit value to round down. |
|
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.
[in] | x | Values to be multiplied. |
[in] | y | Values to be multiplied. |
[in] | z | Value to be added. |
|
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.
[in] | x | Values among which the function selects a maximum. |
[in] | y | Values among which the function selects a maximum. |
|
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.
[in] | x | Values among which the function selects a minimum. |
[in] | y | Values among which the function selects a minimum. |
|
noexcept |
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. |
|
inline |
Computes the square root of the sum-of-squares of x and y.
Only implemented for linear_scale units.
|
noexcept |
Compute natural logarithm.
Returns the natural logarithm of x.
[in] | x | scalar value whose logarithm is calculated. If the argument is negative, a domain error occurs. |
|
noexcept |
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. |
|
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).
[in] | x | Value whose logarithm is calculated. If the argument is less than -1, a domain error occurs. |
|
noexcept |
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. |
|
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.
[in] | x | scalar 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. |
|
noexcept |
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_t type of category::angle_unit . |
[in] | angle | angle to compute the since of |
|
noexcept |
Compute hyperbolic sine.
The input value can be in any unit of angle, including radians or degrees.
AngleUnit | any unit_t type of category::angle_unit . |
[in] | angle | angle to compute the hyperbolic sine of |
|
inlinenoexcept |
computes the square root of value
Only implemented for linear_scale units.
[in] | value | unit_t derived type to compute the square root of. |
square_meter
, then the return type will have units of meter
. 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
.
|
noexcept |
Compute tangent.
The input value can be in any unit of angle, including radians or degrees.
AngleUnit | any unit_t type of category::angle_unit . |
[in] | angle | angle to compute the tangent of |
|
noexcept |
Compute hyperbolic tangent.
The input value can be in any unit of angle, including radians or degrees.
AngleUnit | any unit_t type of category::angle_unit . |
[in] | angle | angle to compute the hyperbolic tangent of |
|
noexcept |
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 |