Jpp 21.0.0-rc.3
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.
 

Static Public Member Functions

static size_t size ()
 Get size of parameter.
 

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

2108 :
2109 center(0.0),
2110 sigma (0.0)
2111 {}

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

2121 :
2122 center(center),
2123 sigma (sigma)
2124 {}

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

2134 {
2135 const double u = (x - center) / sigma;
2136
2137 return get(u);
2138 }
double get(const double u) const
Get ordinate value.
Definition JMathlib.hh:2188

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

2148 {
2149 const double w = 1.0 / sigma;
2150 const double u = (x - center) / sigma;
2151
2152 return get(u) * -u * w;
2153 }

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

2163 {
2164 JGauss gradient;
2165
2166 const double w = 1.0 / sigma;
2167 const double u = (x - center) * w;
2168 const double f0 = get(u);
2169
2170 gradient.center = f0 * (u) * w; // d(f)/d(center)
2171 gradient.sigma = f0 * (u + 1.0) * (u - 1.0) * w; // d(f)/d(sigma)
2172
2173 return gradient;
2174 }

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

2189 {
2190 static const double W = 1.0 / sqrt(2.0 * acos(-1.0));
2191
2192 return exp(-0.5*u*u) * W / sigma;
2193 }

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

◆ size()

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

◆ negate()

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

Negate function.

Returns
this function

Definition at line 170 of file JMathlib.hh.

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

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

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

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

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

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

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

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

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

Member Data Documentation

◆ ID

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

Definition at line 2102 of file JMathlib.hh.

◆ center

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

center

Definition at line 2176 of file JMathlib.hh.

◆ sigma

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

sigma

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

double sigma
sigma
Definition JMathlib.hh:2076
double center
center
Definition JMathlib.hh:2075

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