59#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
60template <
class AngleUnit>
63 traits::is_angle_unit<AngleUnit>::value,
64 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
66 std::cos(angle.template convert<angle::radian>()()));
79#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
80template <
class AngleUnit>
83 traits::is_angle_unit<AngleUnit>::value,
84 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
86 std::sin(angle.template convert<angle::radian>()()));
98#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
99template <
class AngleUnit>
102 traits::is_angle_unit<AngleUnit>::value,
103 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
105 std::tan(angle.template convert<angle::radian>()()));
117#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
118template <
class ScalarUnit>
119angle::radian_t
acos(
const ScalarUnit x)
noexcept {
122 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
135#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
136template <
class ScalarUnit>
137angle::radian_t
asin(
const ScalarUnit x)
noexcept {
140 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
157#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
158template <
class ScalarUnit>
159angle::radian_t
atan(
const ScalarUnit x)
noexcept {
162 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
177#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
178template <
class Y,
class X>
179angle::radian_t
atan2(
const Y
y,
const X x)
noexcept {
181 "The quantity y/x must yield a dimensionless ratio.");
184 return angle::radian_t(
186 typename units::traits::unit_t_traits<X>::unit_type>()(),
204#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
205template <
class AngleUnit>
208 traits::is_angle_unit<AngleUnit>::value,
209 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
211 std::cosh(angle.template convert<angle::radian>()()));
224#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
225template <
class AngleUnit>
228 traits::is_angle_unit<AngleUnit>::value,
229 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
231 std::sinh(angle.template convert<angle::radian>()()));
244#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
245template <
class AngleUnit>
248 traits::is_angle_unit<AngleUnit>::value,
249 "Type `AngleUnit` must be a unit of angle derived from `unit_t`.");
251 std::tanh(angle.template convert<angle::radian>()()));
265#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
266template <
class ScalarUnit>
267angle::radian_t
acosh(
const ScalarUnit x)
noexcept {
270 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
282#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
283template <
class ScalarUnit>
284angle::radian_t
asinh(
const ScalarUnit x)
noexcept {
287 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
301#if !defined(DISABLE_PREDEFINED_UNITS) || defined(ENABLE_PREDEFINED_ANGLE_UNITS)
302template <
class ScalarUnit>
303angle::radian_t
atanh(
const ScalarUnit x)
noexcept {
306 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
331template <
class ScalarUnit>
335 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
348template <
class ScalarUnit>
352 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
364template <
class ScalarUnit>
368 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
383template <
class ScalarUnit>
387 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
403template <
class ScalarUnit>
407 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
419template <
class ScalarUnit>
423 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
436template <
class ScalarUnit>
440 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
452template <
class ScalarUnit>
456 "Type `ScalarUnit` must be a dimensionless unit derived from `unit_t`.");
482 std::enable_if_t<units::traits::has_linear_scale<UnitType>::value,
int> = 0>
485 typename units::traits::unit_t_traits<UnitType>::underlying_type,
489 typename units::traits::unit_t_traits<UnitType>::underlying_type,
501template <
class UnitTypeLhs,
class UnitTypeRhs,
505inline UnitTypeLhs
hypot(
const UnitTypeLhs& x,
const UnitTypeRhs&
y) {
507 "Parameters of hypot() function are not compatible units.");
511 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
526template <
class UnitType,
527 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
528UnitType
ceil(
const UnitType x)
noexcept {
540template <
class UnitType,
541 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
542UnitType
floor(
const UnitType x)
noexcept {
555template <
class UnitTypeLhs,
class UnitTypeRhs,
556 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
558UnitTypeLhs
fmod(
const UnitTypeLhs numer,
const UnitTypeRhs denom)
noexcept {
560 "Parameters of fmod() function are not compatible units.");
564 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
575template <
class UnitType,
576 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
577UnitType
trunc(
const UnitType x)
noexcept {
589template <
class UnitType,
590 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
591UnitType
round(
const UnitType x)
noexcept {
608template <
class UnitTypeLhs,
class UnitTypeRhs,
609 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
611UnitTypeLhs
copysign(
const UnitTypeLhs x,
const UnitTypeRhs
y)
noexcept {
617template <
class UnitTypeLhs,
618 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value>>
638template <
class UnitTypeLhs,
class UnitTypeRhs,
639 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
641UnitTypeLhs
fdim(
const UnitTypeLhs x,
const UnitTypeRhs
y)
noexcept {
643 "Parameters of fdim() function are not compatible units.");
647 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
660template <
class UnitTypeLhs,
class UnitTypeRhs,
661 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
663UnitTypeLhs
fmax(
const UnitTypeLhs x,
const UnitTypeRhs
y)
noexcept {
665 "Parameters of fmax() function are not compatible units.");
669 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
683template <
class UnitTypeLhs,
class UnitTypeRhs,
684 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
686UnitTypeLhs
fmin(
const UnitTypeLhs x,
const UnitTypeRhs
y)
noexcept {
688 "Parameters of fmin() function are not compatible units.");
692 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type>()()));
706template <
class UnitType,
707 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
708UnitType
fabs(
const UnitType x)
noexcept {
719template <
class UnitType,
720 class = std::enable_if_t<traits::is_unit_t<UnitType>::value>>
721UnitType
abs(
const UnitType x)
noexcept {
736template <
class UnitTypeLhs,
class UnitMultiply,
class UnitAdd,
737 class = std::enable_if_t<traits::is_unit_t<UnitTypeLhs>::value &&
740auto fma(
const UnitTypeLhs x,
const UnitMultiply
y,
const UnitAdd z)
noexcept
742 using resultType =
decltype(x *
y);
746 typename units::traits::unit_t_traits<UnitTypeLhs>::unit_type,
747 typename units::traits::unit_t_traits<UnitMultiply>::unit_type>,
748 typename units::traits::unit_t_traits<UnitAdd>::unit_type>
::value,
749 "Unit types are not compatible.");
750 return resultType(
std::fma(x(),
y(), resultType(z)()));
constexpr return_t< T > acosh(const T x) noexcept
Compile-time inverse hyperbolic cosine function.
Definition: acosh.hpp:62
constexpr return_t< T > asinh(const T x) noexcept
Compile-time inverse hyperbolic sine function.
Definition: asinh.hpp:59
constexpr common_return_t< T1, T2 > atan2(const T1 y, const T2 x) noexcept
Compile-time two-argument arctangent function.
Definition: atan2.hpp:82
constexpr return_t< T > atanh(const T x) noexcept
Compile-time inverse hyperbolic tangent function.
Definition: atanh.hpp:73
#define UNIT_LIB_DEFAULT_TYPE
Definition: base.h:60
Container for values which represent quantities of a given unit.
Definition: base.h:1937
constexpr T1 copysign(const T1 x, const T2 y) noexcept
Compile-time copy sign function.
Definition: copysign.hpp:35
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:298
constexpr common_return_t< T1, T2 > fmod(const T1 x, const T2 y) noexcept
Compile-time remainder of division function.
Definition: fmod.hpp:64
static constexpr T convert(const T &value) noexcept
converts a value from one type to another.
Definition: base.h:1659
typename units::detail::sqrt_impl< U, Eps >::type square_root
represents the square root of type class U.
Definition: base.h:1412
UnitTypeLhs fmax(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Maximum value.
Definition: math.h:663
UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:721
angle::radian_t acosh(const ScalarUnit x) noexcept
Compute arc hyperbolic cosine.
Definition: math.h:267
UnitTypeLhs fmin(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Minimum value.
Definition: math.h:686
UnitTypeLhs hypot(const UnitTypeLhs &x, const UnitTypeRhs &y)
Computes the square root of the sum-of-squares of x and y.
Definition: math.h:505
dimensionless::scalar_t exp(const ScalarUnit x) noexcept
Compute exponential function.
Definition: math.h:332
dimensionless::scalar_t sinh(const AngleUnit angle) noexcept
Compute hyperbolic sine.
Definition: math.h:226
UnitType round(const UnitType x) noexcept
Round to nearest.
Definition: math.h:591
dimensionless::scalar_t tan(const AngleUnit angle) noexcept
Compute tangent.
Definition: math.h:100
UnitTypeLhs fmod(const UnitTypeLhs numer, const UnitTypeRhs denom) noexcept
Compute remainder of division.
Definition: math.h:558
angle::radian_t asin(const ScalarUnit x) noexcept
Compute arc sine.
Definition: math.h:137
auto fma(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept -> decltype(x *y)
Multiply-add.
Definition: math.h:740
UnitTypeLhs fdim(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Positive difference.
Definition: math.h:641
angle::radian_t atanh(const ScalarUnit x) noexcept
Compute arc hyperbolic tangent.
Definition: math.h:303
angle::radian_t acos(const ScalarUnit x) noexcept
Compute arc cosine.
Definition: math.h:119
angle::radian_t atan2(const Y y, const X x) noexcept
Compute arc tangent with two parameters.
Definition: math.h:179
dimensionless::scalar_t modf(const ScalarUnit x, ScalarUnit *intpart) noexcept
Break into fractional and integral parts.
Definition: math.h:384
dimensionless::scalar_t exp2(const ScalarUnit x) noexcept
Compute binary exponential function.
Definition: math.h:404
dimensionless::scalar_t expm1(const ScalarUnit x) noexcept
Compute exponential minus one.
Definition: math.h:420
UnitType fabs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:708
dimensionless::scalar_t cosh(const AngleUnit angle) noexcept
Compute hyperbolic cosine.
Definition: math.h:206
angle::radian_t atan(const ScalarUnit x) noexcept
Compute arc tangent.
Definition: math.h:159
dimensionless::scalar_t log2(const ScalarUnit x) noexcept
Compute binary logarithm.
Definition: math.h:453
dimensionless::scalar_t cos(const AngleUnit angle) noexcept
Compute cosine.
Definition: math.h:61
dimensionless::scalar_t tanh(const AngleUnit angle) noexcept
Compute hyperbolic tangent.
Definition: math.h:246
UnitType floor(const UnitType x) noexcept
Round down value.
Definition: math.h:542
UnitTypeLhs copysign(const UnitTypeLhs x, const UnitTypeRhs y) noexcept
Copy sign.
Definition: math.h:611
UnitType trunc(const UnitType x) noexcept
Truncate value.
Definition: math.h:577
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:483
dimensionless::scalar_t log(const ScalarUnit x) noexcept
Compute natural logarithm.
Definition: math.h:349
dimensionless::scalar_t log1p(const ScalarUnit x) noexcept
Compute logarithm plus one.
Definition: math.h:437
dimensionless::scalar_t log10(const ScalarUnit x) noexcept
Compute common logarithm.
Definition: math.h:365
dimensionless::scalar_t sin(const AngleUnit angle) noexcept
Compute sine.
Definition: math.h:81
UnitType ceil(const UnitType x) noexcept
Round up value.
Definition: math.h:528
angle::radian_t asinh(const ScalarUnit x) noexcept
Compute arc hyperbolic sine.
Definition: math.h:284
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1445
constexpr common_return_t< T1, T2 > hypot(const T1 x, const T2 y) noexcept
Compile-time Pythagorean addition function.
Definition: hypot.hpp:84
const Scalar & y
Definition: MathFunctions.h:821
unit_t< scalar > scalar_t
Definition: base.h:2524
namespace for unit-enabled versions of the <cmath> library
Definition: base.h:2808
unit_t scale which is linear
Definition: base.h:2498
Trait which tests whether a type is inherited from a linear scale.
Definition: base.h:2426
Trait which tests whether two container types derived from unit_t are convertible to each other.
Definition: base.h:1837
Traits which tests if a class is a unit
Definition: base.h:1875
constexpr return_t< T > trunc(const T x) noexcept
Compile-time trunc function.
Definition: trunc.hpp:115