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

Gauss function. More...

#include <JMathlib.hh>

Inheritance diagram for JMATH::JGauss< ID_t, true >:
JMATH::JMathlib< JGauss< ID_t, true > > JMATH::JCalculus< JGauss< ID_t, true > >

Public Member Functions

 JGauss ()
 Default constructor.
 
 JGauss (const double center, const double sigma)
 Constructor.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
JGauss 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.
 
JGauss< ID_t, true > & negate ()
 Negate function.
 
JGauss< ID_t, true > & add (const JGauss< ID_t, true > &f1)
 Add function.
 
JGauss< ID_t, true > & sub (const JGauss< ID_t, true > &f1)
 Subtract function.
 
JGauss< ID_t, true > & mul (const double factor)
 Scale function.
 
JGauss< ID_t, true > & div (const double factor)
 Scale function.
 

Public Attributes

double center
 center
 
double sigma
 sigma
 

Static Public Attributes

static const int ID = ID_t
 
static constexpr parameter_list< JGauss, 2 > parameters { &JGauss::center, &JGauss::sigma }
 

Private Member Functions

double get (const double u) const
 Get ordinate value.
 

Detailed Description

template<int ID_t>
struct JMATH::JGauss< ID_t, true >

Gauss function.

Definition at line 2039 of file JMathlib.hh.

Constructor & Destructor Documentation

◆ JGauss() [1/2]

template<int ID_t>
JMATH::JGauss< ID_t, true >::JGauss ( )
inline

Default constructor.

Definition at line 2049 of file JMathlib.hh.

2049 :
2050 center(0.0),
2051 sigma (0.0)
2052 {}

◆ JGauss() [2/2]

template<int ID_t>
JMATH::JGauss< ID_t, true >::JGauss ( const double center,
const double sigma )
inline

Constructor.

Parameters
centercenter
sigmasigma

Definition at line 2061 of file JMathlib.hh.

2062 :
2063 center(center),
2064 sigma (sigma)
2065 {}

Member Function Documentation

◆ getValue()

template<int ID_t>
double JMATH::JGauss< ID_t, true >::getValue ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 2074 of file JMathlib.hh.

2075 {
2076 const double u = (x - center) / sigma;
2077
2078 return get(u);
2079 }
double get(const double u) const
Get ordinate value.
Definition JMathlib.hh:2129

◆ getDerivative()

template<int ID_t>
double JMATH::JGauss< ID_t, true >::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 2088 of file JMathlib.hh.

2089 {
2090 const double w = 1.0 / sigma;
2091 const double u = (x - center) / sigma;
2092
2093 return get(u) * -u * w;
2094 }

◆ getGradient()

template<int ID_t>
JGauss JMATH::JGauss< ID_t, true >::getGradient ( const double x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 2103 of file JMathlib.hh.

2104 {
2105 JGauss gradient;
2106
2107 const double w = 1.0 / sigma;
2108 const double u = (x - center) * w;
2109 const double f0 = get(u);
2110
2111 gradient.center = f0 * (u) * w; // d(f)/d(center)
2112 gradient.sigma = f0 * (u + 1.0) * (u - 1.0) * w; // d(f)/d(sigma)
2113
2114 return gradient;
2115 }

◆ get()

template<int ID_t>
double JMATH::JGauss< ID_t, true >::get ( const double u) const
inlineprivate

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 2129 of file JMathlib.hh.

2130 {
2131 static const double W = 1.0 / sqrt(2.0 * acos(-1.0));
2132
2133 return exp(-0.5*u*u) * W / sigma;
2134 }

◆ operator()()

double JMATH::JMathlib< JGauss< ID_t, true > >::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< JGauss< ID_t, true > >::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< JGauss< ID_t, true > >::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 }

◆ negate()

JGauss< ID_t, true > & JMATH::JCalculus< JGauss< ID_t, true > >::negate ( )
inlineinherited

Negate function.

Returns
this function

Definition at line 169 of file JMathlib.hh.

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

◆ add()

JGauss< ID_t, true > & JMATH::JCalculus< JGauss< ID_t, true > >::add ( const JGauss< ID_t, true > & f1)
inlineinherited

Add function.

Parameters
f1function
Returns
this function

Definition at line 185 of file JMathlib.hh.

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

◆ sub()

JGauss< ID_t, true > & JMATH::JCalculus< JGauss< ID_t, true > >::sub ( const JGauss< ID_t, true > & f1)
inlineinherited

Subtract function.

Parameters
f1function
Returns
this function

Definition at line 201 of file JMathlib.hh.

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

◆ mul()

JGauss< ID_t, true > & JMATH::JCalculus< JGauss< ID_t, true > >::mul ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 217 of file JMathlib.hh.

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

◆ div()

JGauss< ID_t, true > & JMATH::JCalculus< JGauss< ID_t, true > >::div ( const double factor)
inlineinherited

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 233 of file JMathlib.hh.

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

Member Data Documentation

◆ ID

template<int ID_t>
const int JMATH::JGauss< ID_t, true >::ID = ID_t
static

Definition at line 2043 of file JMathlib.hh.

◆ center

template<int ID_t>
double JMATH::JGauss< ID_t, true >::center

center

Definition at line 2117 of file JMathlib.hh.

◆ sigma

template<int ID_t>
double JMATH::JGauss< ID_t, true >::sigma

sigma

Definition at line 2118 of file JMathlib.hh.

◆ parameters

template<int ID_t>
parameter_list<JGauss, 2> JMATH::JGauss< ID_t, true >::parameters { &JGauss::center, &JGauss::sigma }
staticconstexpr

Definition at line 2120 of file JMathlib.hh.

double sigma
sigma
Definition JMathlib.hh:2017
double center
center
Definition JMathlib.hh:2016

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