Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JMATH::JXn< N > Struct Template Reference

Function object for x;. More...

#include <JMathlib.hh>

Inheritance diagram for JMATH::JXn< N >:
JMATH::JMathlib< JXn< N > > JMATH::JCalculus< JXn< N > >

Public Member Functions

 JXn ()
 Default constructor.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
JXn getGradient (const double x) const
 Get gradient.
 
double operator() (const Args &...args) const
 Function value.
 
double operator[] (const size_t i) const
 Get value of parameter at given index.
 
double & operator[] (const size_t i)
 Get value of parameter at given index.
 
JXn< N > & negate ()
 Negate function.
 
JXn< N > & add (const JXn< N > &f1)
 Add function.
 
JXn< N > & sub (const JXn< N > &f1)
 Subtract function.
 
JXn< N > & mul (const double factor)
 Scale function.
 
JXn< N > & div (const double factor)
 Scale function.
 

Static Public Member Functions

static size_t size ()
 Get size of parameter.
 

Static Public Attributes

static constexpr parameter_list< JXn, 0 > parameters {}
 

Detailed Description

template<int N>
struct JMATH::JXn< N >

Function object for x;.

Fixed power of x.

Definition at line 1610 of file JMathlib.hh.

Constructor & Destructor Documentation

◆ JXn()

template<int N>
JMATH::JXn< N >::JXn ( )
inline

Default constructor.

Definition at line 1617 of file JMathlib.hh.

1618 {}

Member Function Documentation

◆ getValue()

template<int N>
double JMATH::JXn< N >::getValue ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 1627 of file JMathlib.hh.

1628 {
1629 return pow(x, N);
1630 }
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97

◆ getDerivative()

template<int N>
double JMATH::JXn< N >::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 1639 of file JMathlib.hh.

1640 {
1641 return N * pow(x, N - 1);
1642 }

◆ getGradient()

template<int N>
JXn JMATH::JXn< N >::getGradient ( const double x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 1651 of file JMathlib.hh.

1652 {
1653 JXn gradient;
1654
1655 return gradient;
1656 }
JXn()
Default constructor.
Definition JMathlib.hh:1617

◆ operator()()

double JMATH::JMathlib< JXn< N > >::operator() ( const Args &... args) const
inlineinherited

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 331 of file JMathlib.hh.

332 {
333 return static_cast<const JF1_t&>(*this).getValue(args...);
334 }

◆ size()

static size_t JMATH::JMathlib< JXn< N > >::size ( )
inlinestaticinherited

Get size of parameter.

Returns
size

Definition at line 538 of file JMathlib.hh.

539 {
540 return JF1_t::parameters.size();
541 }

◆ operator[]() [1/2]

double JMATH::JMathlib< JXn< N > >::operator[] ( const size_t i) const
inlineinherited

Get value of parameter at given index.

Parameters
iindex
Returns
value

Definition at line 550 of file JMathlib.hh.

551 {
552 return static_cast<const JF1_t&>(*this).*JF1_t::parameters[i];
553 }

◆ operator[]() [2/2]

double & JMATH::JMathlib< JXn< N > >::operator[] ( const size_t i)
inlineinherited

Get value of parameter at given index.

Parameters
iindex
Returns
value

Definition at line 562 of file JMathlib.hh.

563 {
564 return static_cast<JF1_t&>(*this).*JF1_t::parameters[i];
565 }

◆ negate()

JXn< N > & JMATH::JCalculus< JXn< N > >::negate ( )
inlineinherited

Negate function.

Returns
this function

Definition at line 170 of file JMathlib.hh.

171 {
172 for (const auto& i : JF1_t::parameters) {
173 static_cast<JF1_t&>(*this).*i = -(static_cast<JF1_t&>(*this).*i);
174 }
175
176 return static_cast<JF1_t&>(*this);
177 }

◆ add()

JXn< N > & JMATH::JCalculus< JXn< N > >::add ( const JXn< N > & f1)
inlineinherited

Add function.

Parameters
f1function
Returns
this function

Definition at line 186 of file JMathlib.hh.

187 {
188 for (const auto& i : JF1_t::parameters) {
189 static_cast<JF1_t&>(*this).*i += f1.*i;
190 }
191
192 return static_cast<JF1_t&>(*this);
193 }

◆ sub()

JXn< N > & JMATH::JCalculus< JXn< N > >::sub ( const JXn< N > & f1)
inlineinherited

Subtract function.

Parameters
f1function
Returns
this function

Definition at line 202 of file JMathlib.hh.

203 {
204 for (const auto& i : JF1_t::parameters) {
205 static_cast<JF1_t&>(*this).*i -= f1.*i;
206 }
207
208 return static_cast<JF1_t&>(*this);
209 }

◆ mul()

JXn< N > & JMATH::JCalculus< JXn< N > >::mul ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 218 of file JMathlib.hh.

219 {
220 for (const auto& i : JF1_t::parameters) {
221 static_cast<JF1_t&>(*this).*i *= factor;
222 }
223
224 return static_cast<JF1_t&>(*this);
225 }

◆ div()

JXn< N > & JMATH::JCalculus< JXn< N > >::div ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 234 of file JMathlib.hh.

235 {
236 for (const auto& i : JF1_t::parameters) {
237 static_cast<JF1_t&>(*this).*i /= factor;
238 }
239
240 return static_cast<JF1_t&>(*this);
241 }

Member Data Documentation

◆ parameters

template<int N>
parameter_list<JXn, 0> JMATH::JXn< N >::parameters {}
staticconstexpr

Definition at line 1658 of file JMathlib.hh.

1658{};

The documentation for this struct was generated from the following file: