21 #ifndef RFFGEN_MATHEMATICAL_OPERATIONS_SCALE_HH
22 #define RFFGEN_MATHEMATICAL_OPERATIONS_SCALE_HH
24 #include <type_traits>
27 #include "../Util/base.hh"
28 #include "../Util/derivativeWrappers.hh"
29 #include "../Util/indexedType.hh"
36 template <
class>
struct Chainer;
41 namespace MathematicalOperations
46 template <
class>
struct FunctionConceptCheck;
56 template <
class F,
class = FunctionConceptCheck<F> >
57 struct Scale :
Base , Chainer< Scale< F , FunctionConceptCheck<F> > >
59 using Chainer< Scale< F , FunctionConceptCheck<F> > >::operator();
68 template <
class InitF>
69 Scale(
double a_,
const InitF& f_) : a(a_), f(f_)
83 template <
int index,
class Arg>
86 f.template updateVariable<index>(x);
90 const auto&
d0() const noexcept
99 template <
int idx ,
class Arg ,
100 class IndexedArg = IndexedType<Arg,idx> ,
101 class = std::enable_if_t< D1<F,IndexedArg>::present> >
102 auto d1(Arg
const& dx)
const
104 return a * f.template d1<idx>(dx);
112 template <
int idx ,
int idy ,
class ArgX ,
class ArgY ,
113 class IndexedArgX = IndexedType<ArgX,idx> ,
114 class IndexedArgY = IndexedType<ArgY,idy> ,
115 class = std::enable_if_t< D2<F,IndexedArgX,IndexedArgY>::present> >
116 auto d2(ArgX
const& dx, ArgY
const& dy)
const
118 return a * f.template d2<idx,idy>(dx,dy);
127 template <
int idx ,
int idy ,
int idz ,
class ArgX ,
class ArgY ,
class ArgZ ,
128 class IndexedArgX = IndexedType<ArgX,idx> ,
129 class IndexedArgY = IndexedType<ArgY,idy> ,
130 class IndexedArgZ = IndexedType<ArgZ,idz> ,
131 class = std::enable_if_t< D3<F,IndexedArgX,IndexedArgY,IndexedArgZ>::present > >
132 auto d3(ArgX
const& dx, ArgY
const& dy, ArgZ
const& dz)
const
134 return a * f.template d3<idx,idy,idz>(dx,dy,dz);
138 void updateResultOfD0()
140 resultOfD0 = a * f.d0();
145 std::remove_const_t<std::remove_reference_t<decltype(std::declval<F>().
d0())> > resultOfD0;
150 #endif // RFFGEN_MATHEMATICAL_OPERATIONS_SCALE_HH
void update(Arg const &arg)
Reset point of evaluation.
Definition: scale.hh:76
const auto & d0() const noexcept
Function value.
Definition: scale.hh:90
Scaling of some function with a double (F must satisfy the requirements of Concepts::FunctionConce...
Definition: scale.hh:57
Base class for functions satisfying FunctionConcept. Required for enabling the operators in generate...
Definition: base.hh:27
auto d1(Arg const &dx) const
First directional derivative.
Definition: scale.hh:102
void updateVariable(const Arg &x)
Propagate call to updateVariable() to f.
Definition: scale.hh:84
Scale(double a_, const InitF &f_)
Constructor passing arguments to function constructor.
Definition: scale.hh:69
auto d3(ArgX const &dx, ArgY const &dy, ArgZ const &dz) const
Third directional derivative.
Definition: scale.hh:132
Scale()=default
Default constructor. May leave member variables uninitialized! Call update before using evaluation...
auto d2(ArgX const &dx, ArgY const &dy) const
Second directional derivative.
Definition: scale.hh:116