Jpp 21.0.0-rc.1-88-g0130508c4
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 2046 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 2056 of file JMathlib.hh.

2056 :
2057 center(0.0),
2058 sigma (0.0)
2059 {}

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

2069 :
2070 center(center),
2071 sigma (sigma)
2072 {}

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

2082 {
2083 const double u = (x - center) / sigma;
2084
2085 return get(u);
2086 }
double get(const double u) const
Get ordinate value.
Definition JMathlib.hh:2136

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

2096 {
2097 const double w = 1.0 / sigma;
2098 const double u = (x - center) / sigma;
2099
2100 return get(u) * -u * w;
2101 }

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

2111 {
2112 JGauss gradient;
2113
2114 const double w = 1.0 / sigma;
2115 const double u = (x - center) * w;
2116 const double f0 = get(u);
2117
2118 gradient.center = f0 * (u) * w; // d(f)/d(center)
2119 gradient.sigma = f0 * (u + 1.0) * (u - 1.0) * w; // d(f)/d(sigma)
2120
2121 return gradient;
2122 }

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

2137 {
2138 static const double W = 1.0 / sqrt(2.0 * acos(-1.0));
2139
2140 return exp(-0.5*u*u) * W / sigma;
2141 }

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

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

◆ 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 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< JGauss< ID_t, true > >::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 }

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

◆ center

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

center

Definition at line 2124 of file JMathlib.hh.

◆ sigma

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

sigma

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

double sigma
sigma
Definition JMathlib.hh:2024
double center
center
Definition JMathlib.hh:2023

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