5 #include <amdis/common/Math.hpp> 6 #include <amdis/common/Concepts.hpp> 7 #include <amdis/operations/Basic.hpp> 8 #include <amdis/operations/Composer.hpp> 21 template <
class... Ts>
22 constexpr
auto operator()(Ts
const&... ts)
const 24 return Math::sum(ts...);
45 template <
class... Int>
46 constexpr
int order(
Plus const&, Int... orders)
48 return Math::max(
int(orders)...);
51 template <std::
size_t I>
52 constexpr
auto partial(
Plus const&, index_t<I>)
54 static_assert((I < 2),
"Derivatives of `Plus` only defined for the binary case.");
63 template <
class T,
class S>
64 constexpr
auto operator()(T
const& lhs, S
const& rhs)
const 69 friend constexpr
int order(
Minus const&,
int lhs,
int rhs)
71 return Math::max(lhs, rhs);
74 friend constexpr
auto partial(
Minus const&, index_t<0>)
79 friend constexpr
auto partial(
Minus const&, index_t<1>)
102 template <
class... Ts>
103 constexpr
auto operator()(Ts
const&... ts)
const 128 template <
class... Int>
129 constexpr
int order(
Multiplies const&, Int... orders)
131 return Math::sum(
int(orders)...);
136 template <std::
size_t I>
137 constexpr
auto partial(
Multiplies const&, index_t<I>)
139 static_assert((I < 2),
"Derivatives of `Multiplies` only defined for the binary case.");
146 template <
class Factor>
149 Factor
const factor_;
152 constexpr
auto operator()(T
const& value)
const 154 return factor_ * value;
157 friend constexpr
int order(
Scale const&,
int d)
163 friend constexpr
auto partial(
Scale const& s, index_t<0>)
171 template <
class F,
class G>
176 template <
class F_,
class G_>
177 static constexpr type build(F_&& f, G_&& g)
179 return type{f.factor_ * g.factor_};
189 template <
class T,
class S>
190 constexpr
auto operator()(T
const& lhs, S
const& rhs)
const 196 friend constexpr
auto partial(
Divides const&, index_t<0>)
202 friend constexpr
auto partial(
Divides const&, index_t<1>);
211 constexpr
auto operator()(T
const& x)
const 216 friend constexpr
int order(
Negate const&,
int d)
221 friend constexpr
auto partial(
Negate const&, index_t<0>)
247 template <
int p,
bool positive>
269 constexpr
auto operator()(T
const& x)
const 271 return Math::pow<p>(x);
274 friend constexpr
int order(
PowImpl const&,
int d)
279 friend constexpr
auto partial(
PowImpl const&, index_t<0>)
287 :
public Composer<Divides, One, Pow<-p>>
294 constexpr
auto operator()(T
const& x)
const 296 return T(1) / Math::pow<-p>(x);
303 template <
int p1,
bool pos1,
int p2,
bool pos2>
308 template <
int p,
bool pos>
314 inline constexpr
auto partial(
Divides const&, index_t<1>)
317 compose(Pow<2>{},
Arg<1>{}));
323 constexpr
Power(
double p)
328 auto operator()(T
const& x)
const 330 return std::pow(x, p_);
333 friend constexpr
auto partial(Power
const& P, index_t<0>)
Definition: Basic.hpp:164
Composition of Functors.
Definition: Composer.hpp:29
Functor that represents A-B.
Definition: Arithmetic.hpp:208
Functor that represents f*A.
Definition: Arithmetic.hpp:147
Definition: AdaptBase.hpp:6
Definition: Arithmetic.hpp:248
Functor that represents A*B.
Definition: Arithmetic.hpp:100
Functor that represents A+B.
Definition: Arithmetic.hpp:19
Functor representing a static constant value.
Definition: Basic.hpp:37
Functor that represents A/B.
Definition: Arithmetic.hpp:187
Definition: Composer.hpp:51
Functor that represents A-B.
Definition: Arithmetic.hpp:61
Functor representing a constant value.
Definition: Basic.hpp:87
Functor that represents x^p,.
Definition: Arithmetic.hpp:321
Definition: Arithmetic.hpp:251
(Unary-)Functor representing the identity
Definition: Basic.hpp:64