5#include <amdis/operations/Basic.hpp>
13#ifndef AMDIS_MAKE_UNARY_FUNCTOR
14#define AMDIS_MAKE_UNARY_FUNCTOR( NAME, FCT, DERIV ) \
18 constexpr auto operator() (T const& x) const \
25 constexpr auto operator() (T const& x) const \
30 friend constexpr auto partial(NAME const&, index_t<0>) \
32 return Derivative{} ; \
50 constexpr auto operator()(T
const& x)
const
52 return (x > T{0} ? T{1} : T{-1});
55 friend constexpr auto partial(
Signum const&, index_t<0>)
65 AMDIS_MAKE_UNARY_FUNCTOR( Ceil, std::ceil(x), 0.0 )
66 AMDIS_MAKE_UNARY_FUNCTOR( Floor, std::floor(x), 0.0 )
67 AMDIS_MAKE_UNARY_FUNCTOR(
Sqrt, std::sqrt(x), 1.0/(2.0 * std::sqrt(x)) )
68 AMDIS_MAKE_UNARY_FUNCTOR( Exp, std::exp(x), std::exp(x) )
69 AMDIS_MAKE_UNARY_FUNCTOR( Log, std::log(x), 1.0/x )
70 AMDIS_MAKE_UNARY_FUNCTOR( Sin, std::sin(x), std::cos(x) )
71 AMDIS_MAKE_UNARY_FUNCTOR( Cos, std::cos(x), -std::sin(x) )
72 AMDIS_MAKE_UNARY_FUNCTOR( Tan, std::tan(x), 1.0 + Math::sqr(std::tan(x)) )
73 AMDIS_MAKE_UNARY_FUNCTOR( Asin, std::asin(x), 1.0/std::sqrt(1.0 - Math::sqr(x)) )
74 AMDIS_MAKE_UNARY_FUNCTOR( Acos, std::acos(x), -1.0/std::sqrt(1.0 - Math::sqr(x)) )
75 AMDIS_MAKE_UNARY_FUNCTOR( Atan, std::atan(x), 1.0/(1.0 + Math::sqr(x)) )
76 AMDIS_MAKE_UNARY_FUNCTOR( Sinh, std::sinh(x), std::cosh(x) )
77 AMDIS_MAKE_UNARY_FUNCTOR( Cosh, std::cosh(x), std::sinh(x) )
78 AMDIS_MAKE_UNARY_FUNCTOR( Tanh, std::tanh(x), 1.0 - Math::sqr(std::tanh(x)) )
79 AMDIS_MAKE_UNARY_FUNCTOR( Asinh, std::asinh(x), 1.0/std::sqrt(1.0 + Math::sqr(x)) )
80 AMDIS_MAKE_UNARY_FUNCTOR( Acosh, std::acosh(x), 1.0/std::sqrt(-1.0 + Math::sqr(x)) )
81 AMDIS_MAKE_UNARY_FUNCTOR( Atanh, std::atanh(x), 1.0/(1.0 - Math::sqr(x)) )
87 template <
class T1,
class T2>
88 constexpr auto operator() (T1
const& x, T2
const& y)
const
90 return std::atan2(x, y);
94 constexpr friend auto partial(Atan2
const&, index_t<0>)
96 return compose(Divides{}, compose(Negate{}, Arg<1>{}),
97 compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{})));
101 constexpr friend auto partial(Atan2
const&, index_t<1>)
103 return compose(Divides{}, Arg<0>{},
104 compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{})));
112 constexpr Clamp(T
const& lo, T
const& hi)
119 constexpr auto operator() (T
const& v)
const
121 return v < lo_ ? lo_ : hi_ < v ? hi_ : v;
126 constexpr auto operator() (T
const& v)
const
128 return v < lo_ ? T(0) : hi_ < v ? T(0) : T(1);
134 constexpr friend auto partial(
Clamp const& c, index_t<0>)
136 return DClamp{c.lo_,c.hi_};
Definition: CMath.hpp:125
Definition: CMath.hpp:111
Functor that represents the signum function.
Definition: CMath.hpp:48
Functor representing a static constant value.
Definition: Basic.hpp:38