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

forward declaration for division of fuction. 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 >

forward declaration for division of fuction.

Fixed power of function.

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

1423 :
1424 JF1_t(),
1425 N(1)
1426 {}

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

1435 :
1436 JF1_t(f1),
1437 N(N)
1438 {}

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

1449 {
1450 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1451
1452 return pow(u, N);
1453 }
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 1462 of file JMathlib.hh.

1463 {
1464 const double u = static_cast<const JF1_t&>(*this).getValue(x);
1465 const double v = static_cast<const JF1_t&>(*this).getDerivative(x);
1466
1467 return N * pow(u, N - 1) * v;
1468 }

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

1479 {
1480 JFn gradient;
1481
1482 const double u = static_cast<const JF1_t&>(*this).getValue(args...);
1483 const double w = N * pow(u, N - 1);
1484
1485 static_cast<JF1_t&>(gradient) = static_cast<const JF1_t&>(*this).getGradient(args...);
1486 static_cast<JF1_t&>(gradient) *= w;
1487
1488 return gradient;
1489 }
JFn()
Default constructor.
Definition JMathlib.hh:1423

◆ 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 }

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

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

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

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

Member Data Documentation

◆ N

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

Definition at line 1492 of file JMathlib.hh.


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