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

Fixed power of function. More...

#include <JMathlib.hh>

Inheritance diagram for JMATH::JFn< JF1_t >:
JMATH::JMathlib< JFn< JF1_t > >

Public Member Functions

 JFn ()
 Default constructor.
 
 JFn (const JF1_t &f1, const int N)
 Constructor.
 
template<class ... Args>
double getValue (const Args &...args) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
template<class ... Args>
JFn getGradient (const Args &...args) 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.
 

Static Public Member Functions

static size_t size ()
 Get size of parameter.
 

Private Attributes

int N
 

Detailed Description

template<class JF1_t>
struct JMATH::JFn< JF1_t >

Fixed power of function.

Definition at line 1464 of file JMathlib.hh.

Constructor & Destructor Documentation

◆ JFn() [1/2]

template<class JF1_t >
JMATH::JFn< JF1_t >::JFn ( )
inline

Default constructor.

Definition at line 1475 of file JMathlib.hh.

1475 :
1476 JF1_t(),
1477 N(1)
1478 {}

◆ JFn() [2/2]

template<class JF1_t >
JMATH::JFn< JF1_t >::JFn ( const JF1_t & f1,
const int N )
inline

Constructor.

Parameters
f1first function
Npower

Definition at line 1487 of file JMathlib.hh.

1487 :
1488 JF1_t(f1),
1489 N(N)
1490 {}

Member Function Documentation

◆ getValue()

template<class JF1_t >
template<class ... Args>
double JMATH::JFn< JF1_t >::getValue ( const Args &... args) const
inline

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 1500 of file JMathlib.hh.

1501 {
1502 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1503
1504 return pow(u, N);
1505 }
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97

◆ getDerivative()

template<class JF1_t >
double JMATH::JFn< JF1_t >::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 1514 of file JMathlib.hh.

1515 {
1516 const double u = static_cast<const JF1_t&>(*this).getValue(x);
1517 const double v = static_cast<const JF1_t&>(*this).getDerivative(x);
1518
1519 return N * pow(u, N - 1) * v;
1520 }

◆ getGradient()

template<class JF1_t >
template<class ... Args>
JFn JMATH::JFn< JF1_t >::getGradient ( const Args &... args) const
inline

Get gradient.

Parameters
argsabscissa value(s)
Returns
gradient

Definition at line 1530 of file JMathlib.hh.

1531 {
1532 JFn gradient;
1533
1534 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1535 const double w = N * pow(u, N - 1);
1536
1537 static_cast<JF1_t&>(gradient) = static_cast<const JF1_t&>(*this).getGradient(args...);
1538 static_cast<JF1_t&>(gradient) *= w;
1539
1540 return gradient;
1541 }
JFn()
Default constructor.
Definition JMathlib.hh:1475

◆ operator()()

double JMATH::JMathlib< JF1_t >::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< JF1_t >::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< JF1_t >::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< JF1_t >::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 }

Member Data Documentation

◆ N

template<class JF1_t >
int JMATH::JFn< JF1_t >::N
private

Definition at line 1544 of file JMathlib.hh.


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