Jpp 21.0.0-rc.1-88-g0130508c4
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.
 

Private Attributes

int N
 

Detailed Description

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

Fixed power of function.

Definition at line 1418 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 1430 of file JMathlib.hh.

1430 :
1431 JF1_t(),
1432 N(1)
1433 {}

◆ 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 1442 of file JMathlib.hh.

1442 :
1443 JF1_t(f1),
1444 N(N)
1445 {}

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 1455 of file JMathlib.hh.

1456 {
1457 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1458
1459 return pow(u, N);
1460 }
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 1469 of file JMathlib.hh.

1470 {
1471 const double u = static_cast<const JF1_t&>(*this).getValue(x);
1472 const double v = static_cast<const JF1_t&>(*this).getDerivative(x);
1473
1474 return N * pow(u, N - 1) * v;
1475 }

◆ 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 1485 of file JMathlib.hh.

1486 {
1487 JFn gradient;
1488
1489 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1490 const double w = N * pow(u, N - 1);
1491
1492 static_cast<JF1_t&>(gradient) = static_cast<const JF1_t&>(*this).getGradient(args...);
1493 static_cast<JF1_t&>(gradient) *= w;
1494
1495 return gradient;
1496 }
JFn()
Default constructor.
Definition JMathlib.hh:1430

◆ operator()()

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

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 330 of file JMathlib.hh.

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

◆ 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 538 of file JMathlib.hh.

539 {
540 return static_cast<const JF1_t&>(*this).*JF1_t::parameters[i];
541 }

◆ 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 550 of file JMathlib.hh.

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

Member Data Documentation

◆ N

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

Definition at line 1499 of file JMathlib.hh.


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