61#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
62template <
class AngleUnit>
65 traits::is_angle_unit<AngleUnit>::value,
66 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
81#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
82template <
class AngleUnit>
85 traits::is_angle_unit<AngleUnit>::value,
86 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
100#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
101template <
class AngleUnit>
104 traits::is_angle_unit<AngleUnit>::value,
105 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
119#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
120template <
class ScalarUnit>
121constexpr angle::radian_t
acos(
const ScalarUnit x)
noexcept {
124 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
137#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
138template <
class ScalarUnit>
139constexpr angle::radian_t
asin(
const ScalarUnit x)
noexcept {
142 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
159#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
160template <
class ScalarUnit>
161constexpr angle::radian_t
atan(
const ScalarUnit x)
noexcept {
164 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
179#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
180template <
class Y,
class X>
181constexpr angle::radian_t
atan2(
const Y y,
const X x)
noexcept {
183 "The quantity y/x must yield a dimensionless ratio.");
186 return angle::radian_t(
188 typename units::traits::unit_t_traits<X>::unit_type>()(),
206#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
207template <
class AngleUnit>
210 traits::is_angle_unit<AngleUnit>::value,
211 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
226#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
227template <
class AngleUnit>
230 traits::is_angle_unit<AngleUnit>::value,
231 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
246#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
247template <
class AngleUnit>
250 traits::is_angle_unit<AngleUnit>::value,
251 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
267#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
268template <
class ScalarUnit>
269constexpr angle::radian_t
acosh(
const ScalarUnit x)
noexcept {
272 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
284#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
285template <
class ScalarUnit>
286constexpr angle::radian_t
asinh(
const ScalarUnit x)
noexcept {
289 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
303#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
304template <
class ScalarUnit>
305constexpr angle::radian_t
atanh(
const ScalarUnit x)
noexcept {
308 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
333template <
class ScalarUnit>
337 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
350template <
class ScalarUnit>
354 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
366template <
class ScalarUnit>
370 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
385template <
class ScalarUnit>
389 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
405template <
class ScalarUnit>
409 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
421template <
class ScalarUnit>
425 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
438template <
class ScalarUnit>
442 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
454template <
class ScalarUnit>
458 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
484 std::enable_if_t<units::traits::has_linear_scale<UnitType>::value,
int> = 0>
485inline constexpr auto sqrt(
const UnitType& value)
noexcept
488 typename units::traits::unit_t_traits<UnitType>::underlying_type,
492 typename units::traits::unit_t_traits<UnitType>::underlying_type,
504template <
class UnitTypeLhs,
class UnitTypeRhs,
508inline constexpr UnitTypeLhs
hypot(
const UnitTypeLhs& x,
const UnitTypeRhs& y) {
510 "Parameters of hypot() function are not compatible units.");
514 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
529template <
class UnitType,
530 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
531constexpr UnitType
ceil(
const UnitType x)
noexcept {
543template <
class UnitType,
544 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
545constexpr UnitType
floor(
const UnitType x)
noexcept {
558template <
class UnitTypeLhs,
class UnitTypeRhs,
559 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
561constexpr UnitTypeLhs
fmod(
const UnitTypeLhs numer,
562 const UnitTypeRhs denom)
noexcept {
564 "Parameters of fmod() function are not compatible units.");
568 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
579template <
class UnitType,
580 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
581constexpr UnitType
trunc(
const UnitType x)
noexcept {
593template <
class UnitType,
594 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
595constexpr UnitType
round(
const UnitType x)
noexcept {
612template <
class UnitTypeLhs,
class UnitTypeRhs,
613 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
616 const UnitTypeRhs y)
noexcept {
622template <
class UnitTypeLhs,
623 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value>>
643template <
class UnitTypeLhs,
class UnitTypeRhs,
644 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
646UnitTypeLhs
fdim(
const UnitTypeLhs x,
const UnitTypeRhs y)
noexcept {
648 "Parameters of fdim() function are not compatible units.");
649 return UnitTypeLhs(std::fdim(
652 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
665template <
class UnitTypeLhs,
class UnitTypeRhs,
666 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
668constexpr UnitTypeLhs
fmax(
const UnitTypeLhs x,
const UnitTypeRhs y)
noexcept {
670 "Parameters of fmax() function are not compatible units.");
674 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
688template <
class UnitTypeLhs,
class UnitTypeRhs,
689 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
691constexpr UnitTypeLhs
fmin(
const UnitTypeLhs x,
const UnitTypeRhs y)
noexcept {
693 "Parameters of fmin() function are not compatible units.");
697 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
711template <
class UnitType,
712 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
713constexpr UnitType
fabs(
const UnitType x)
noexcept {
724template <
class UnitType,
725 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
726constexpr UnitType
abs(
const UnitType x)
noexcept {
741template <
class UnitTypeLhs,
class UnitMultiply,
class UnitAdd,
742 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
745auto fma(
const UnitTypeLhs x,
const UnitMultiply y,
746 const UnitAdd z)
noexcept ->
decltype(x * y) {
747 using resultType =
decltype(x * y);
751 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type,
752 typename units::traits::unit_t_traits<UnitMultiply>::unit_type>,
753 typename units::traits::unit_t_traits<UnitAdd>::unit_type>::value,
754 "Unit types are not compatible.");
755 return resultType(std::fma(x(), y(), resultType(z)()));
Container for values which represent quantities of a given unit.
Definition base.h:1930
static constexpr T convert(const T &value) noexcept
converts a value from one type to another.
Definition base.h:1652
typename units::detail::sqrt_impl< U, Eps >::type square_root
represents the square root of type class U.
Definition base.h:1405
constexpr UnitTypeLhs fmin(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Minimum value.
Definition math.h:691
constexpr UnitTypeLhs fmax(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Maximum value.
Definition math.h:668
constexpr UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition math.h:726
constexpr UnitType ceil(const UnitType x) noexcept
Round up value.
Definition math.h:531
constexpr UnitTypeLhs copysign(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Copy sign.
Definition math.h:615
constexpr UnitType fabs(const UnitType x) noexcept
Compute absolute value.
Definition math.h:713
constexpr UnitType floor(const UnitType x) noexcept
Round down value.
Definition math.h:545
constexpr auto 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
Definition math.h:485
constexpr dimensionless::scalar_t log2(const ScalarUnit x) noexcept
Compute binary logarithm.
Definition math.h:455
constexpr angle::radian_t acosh(const ScalarUnit x) noexcept
Compute arc hyperbolic cosine.
Definition math.h:269
constexpr dimensionless::scalar_t log1p(const ScalarUnit x) noexcept
Compute logarithm plus one.
Definition math.h:439
constexpr angle::radian_t asin(const ScalarUnit x) noexcept
Compute arc sine.
Definition math.h:139
constexpr UnitTypeLhs hypot(const UnitTypeLhs &x, const UnitTypeRhs &y)
Computes the square root of the sum-of-squares of x and y.
Definition math.h:508
constexpr angle::radian_t acos(const ScalarUnit x) noexcept
Compute arc cosine.
Definition math.h:121
constexpr dimensionless::scalar_t sinh(const AngleUnit angle) noexcept
Compute hyperbolic sine.
Definition math.h:228
auto fma(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept -> decltype(x *y)
Multiply-add.
Definition math.h:745
UnitTypeLhs fdim(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Positive difference.
Definition math.h:646
constexpr UnitTypeLhs fmod(const UnitTypeLhs numer, const UnitTypeRhs denom) noexcept
Compute remainder of division.
Definition math.h:561
dimensionless::scalar_t modf(const ScalarUnit x, ScalarUnit *intpart) noexcept
Break into fractional and integral parts.
Definition math.h:386
dimensionless::scalar_t exp2(const ScalarUnit x) noexcept
Compute binary exponential function.
Definition math.h:406
constexpr angle::radian_t atan2(const Y y, const X x) noexcept
Compute arc tangent with two parameters.
Definition math.h:181
constexpr dimensionless::scalar_t sin(const AngleUnit angle) noexcept
Compute sine.
Definition math.h:83
constexpr dimensionless::scalar_t log(const ScalarUnit x) noexcept
Compute natural logarithm.
Definition math.h:351
constexpr UnitType trunc(const UnitType x) noexcept
Truncate value.
Definition math.h:581
constexpr dimensionless::scalar_t log10(const ScalarUnit x) noexcept
Compute common logarithm.
Definition math.h:367
constexpr dimensionless::scalar_t tanh(const AngleUnit angle) noexcept
Compute hyperbolic tangent.
Definition math.h:248
constexpr dimensionless::scalar_t cos(const AngleUnit angle) noexcept
Compute cosine.
Definition math.h:63
constexpr dimensionless::scalar_t cosh(const AngleUnit angle) noexcept
Compute hyperbolic cosine.
Definition math.h:208
constexpr angle::radian_t atan(const ScalarUnit x) noexcept
Compute arc tangent.
Definition math.h:161
constexpr angle::radian_t atanh(const ScalarUnit x) noexcept
Compute arc hyperbolic tangent.
Definition math.h:305
constexpr angle::radian_t asinh(const ScalarUnit x) noexcept
Compute arc hyperbolic sine.
Definition math.h:286
constexpr UnitType round(const UnitType x) noexcept
Round to nearest.
Definition math.h:595
constexpr dimensionless::scalar_t expm1(const ScalarUnit x) noexcept
Compute exponential minus one.
Definition math.h:422
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition base.h:1438
constexpr return_t< T > cosh(const T x) noexcept
Compile-time hyperbolic cosine function.
Definition cosh.hpp:65
constexpr return_t< T > round(const T x) noexcept
Compile-time round function.
Definition round.hpp:125
constexpr T abs(const T x) noexcept
Compile-time absolute value function.
Definition abs.hpp:40
constexpr return_t< T > log10(const T x) noexcept
Compile-time common logarithm function.
Definition log10.hpp:59
constexpr return_t< T > atan(const T x) noexcept
Compile-time arctangent function.
Definition atan.hpp:217
constexpr return_t< T > ceil(const T x) noexcept
Compile-time ceil function.
Definition ceil.hpp:130
constexpr return_t< T > tan(const T x) noexcept
Compile-time tangent function.
Definition tan.hpp:140
constexpr return_t< T > sinh(const T x) noexcept
Compile-time hyperbolic sine function.
Definition sinh.hpp:65
constexpr return_t< T > asin(const T x) noexcept
Compile-time arcsine function.
Definition asin.hpp:82
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition max.hpp:41
constexpr common_return_t< T1, T2 > fmod(const T1 x, const T2 y) noexcept
Compile-time remainder of division function.
Definition fmod.hpp:70
constexpr T1 copysign(const T1 x, const T2 y) noexcept
Compile-time copy sign function.
Definition copysign.hpp:41
constexpr return_t< T > log(const T x) noexcept
Compile-time natural logarithm function.
Definition log.hpp:186
constexpr return_t< T > cos(const T x) noexcept
Compile-time cosine function.
Definition cos.hpp:83
constexpr return_t< T > sin(const T x) noexcept
Compile-time sine function.
Definition sin.hpp:85
constexpr return_t< T > acosh(const T x) noexcept
Compile-time inverse hyperbolic cosine function.
Definition acosh.hpp:68
constexpr return_t< T > trunc(const T x) noexcept
Compile-time trunc function.
Definition trunc.hpp:121
constexpr return_t< T > log2(const T x) noexcept
Compile-time binary logarithm function.
Definition log2.hpp:59
constexpr common_return_t< T1, T2 > hypot(const T1 x, const T2 y) noexcept
Compile-time Pythagorean addition function.
Definition hypot.hpp:147
constexpr return_t< T > sqrt(const T x) noexcept
Compile-time square-root function.
Definition sqrt.hpp:109
constexpr return_t< T > floor(const T x) noexcept
Compile-time floor function.
Definition floor.hpp:130
constexpr return_t< T > atanh(const T x) noexcept
Compile-time inverse hyperbolic tangent function.
Definition atanh.hpp:79
constexpr return_t< T > exp(const T x) noexcept
Compile-time exponential function.
Definition exp.hpp:130
constexpr return_t< T > acos(const T x) noexcept
Compile-time arccosine function.
Definition acos.hpp:84
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition min.hpp:41
constexpr return_t< T > log1p(const T x) noexcept
Compile-time natural-logarithm-plus-1 function.
Definition log1p.hpp:80
constexpr return_t< T > expm1(const T x) noexcept
Compile-time exponential-minus-1 function.
Definition expm1.hpp:76
constexpr common_return_t< T1, T2 > atan2(const T1 y, const T2 x) noexcept
Compile-time two-argument arctangent function.
Definition atan2.hpp:88
constexpr return_t< T > tanh(const T x) noexcept
Compile-time hyperbolic tangent function.
Definition tanh.hpp:113
constexpr return_t< T > asinh(const T x) noexcept
Compile-time inverse hyperbolic sine function.
Definition asinh.hpp:65
unit_t< scalar > scalar_t
Definition base.h:2517
namespace for unit-enabled versions of the <cmath> library
Definition base.h:2801
unit_t scale which is linear
Definition base.h:2491
Trait which tests whether a type is inherited from a linear scale.
Definition base.h:2419
Trait which tests whether two container types derived from unit_t are convertible to each other.
Definition base.h:1830
Traits which tests if a class is a unit
Definition base.h:1868
#define UNIT_LIB_DEFAULT_TYPE
Definition base.h:59