Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JMATH::JGauss< ID_t, normalised > Struct Template Reference

Gauss function object. More...

#include <JGauss.hh>

Inheritance diagram for JMATH::JGauss< ID_t, normalised >:
JMATH::JGauss_t JMATH::JMathlib< JGauss< ID_t > > JMATH::JCalculus< JGauss< ID_t > > JMATH::JMath< JGauss_t > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

typedef double JGauss::* parameter_type
 Type definition of fit parameter.
 

Public Member Functions

 JGauss ()
 Default constructor.
 
 JGauss (const JGauss_t &gauss)
 Copy constructor.
 
 JGauss (const double mean, const double sigma, const double signal=1.0, const double background=0.0)
 Constructor.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
double operator() (const double x) const
 Function value.
 
const JGauss_tgetGradient (const double x) const
 Get gradient.
 
 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.
 
const JGaussgetGradient (const double x) const
 Get gradient.
 
bool equals (const JGauss_t &gauss, const double eps=std::numeric_limits< double >::min()) const
 Equality.
 
JGauss_tadd (const JGauss_t &gauss)
 Add gauss.
 
JGauss_tsub (const JGauss_t &gauss)
 Subtract gauss.
 
JGauss_tmul (const double factor)
 Scale gauss.
 
JGauss_tmul (const JSecond_t &object)
 Multiply with object.
 
double operator() (const Args &...args) const
 Function value.
 
JGauss< ID_t > & negate ()
 Negate function.
 
JGauss< ID_t > & add (const JGauss< ID_t > &f1)
 Add function.
 
JGauss< ID_t > & sub (const JGauss< ID_t > &f1)
 Subtract function.
 
JGauss< ID_t > & mul (const double factor)
 Scale function.
 
JGauss< ID_t > & div (const double factor)
 Scale function.
 

Public Attributes

double center
 center
 
double sigma
 sigma
 
double mean
 
double signal
 
double background
 

Static Public Attributes

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

Private Member Functions

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

Private Attributes

JGauss_t gradient
 

Detailed Description

template<int ID_t, bool normalised = false>
struct JMATH::JGauss< ID_t, normalised >

Gauss function object.

Gauss function.

Evaluates function, derivative and gradient values.

Definition at line 1586 of file JMathlib.hh.

Member Typedef Documentation

◆ parameter_type

template<int ID_t, bool normalised = false>
double JGauss::* JMATH::JGauss< ID_t, normalised >::parameter_type

Type definition of fit parameter.

Definition at line 179 of file JGauss.hh.

Constructor & Destructor Documentation

◆ JGauss() [1/5]

template<int ID_t, bool normalised = false>
JMATH::JGauss< ID_t, normalised >::JGauss ( )
inline

Default constructor.

Definition at line 185 of file JGauss.hh.

185 :
186 JGauss_t()
187 {}
JGauss_t()
Default constructor.
Definition JGauss.hh:36

◆ JGauss() [2/5]

template<int ID_t, bool normalised = false>
JMATH::JGauss< ID_t, normalised >::JGauss ( const JGauss_t & gauss)
inline

Copy constructor.

Parameters
gaussgauss

Definition at line 195 of file JGauss.hh.

195 :
197 {}
double gauss(const double x, const double sigma)
Gauss function (normalised to 1 at x = 0).

◆ JGauss() [3/5]

template<int ID_t, bool normalised = false>
JMATH::JGauss< ID_t, normalised >::JGauss ( const double mean,
const double sigma,
const double signal = 1.0,
const double background = 0.0 )
inline

Constructor.

Parameters
meanmean
sigmasigma
signalsignal
backgroundbackground

Definition at line 208 of file JGauss.hh.

211 :
213 {}
double background
Definition JGauss.hh:164
double signal
Definition JGauss.hh:163
double sigma
sigma
Definition JMathlib.hh:1665

◆ JGauss() [4/5]

template<int ID_t, bool normalised = false>
JMATH::JGauss< ID_t, normalised >::JGauss ( )
inline

Default constructor.

Definition at line 1596 of file JMathlib.hh.

1596 :
1597 center(0.0),
1598 sigma (0.0)
1599 {}
double center
center
Definition JMathlib.hh:1664

◆ JGauss() [5/5]

template<int ID_t, bool normalised = false>
JMATH::JGauss< ID_t, normalised >::JGauss ( const double center,
const double sigma )
inline

Constructor.

Parameters
centercenter
sigmasigma

Definition at line 1608 of file JMathlib.hh.

1609 :
1610 center(center),
1611 sigma (sigma)
1612 {}

Member Function Documentation

◆ getValue() [1/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::getValue ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 222 of file JGauss.hh.

223 {
224 const double u = (x - mean) / sigma;
225
226 return signal * get(u) + background;
227 }
double get(const double u) const
Get ordinate value.
Definition JGauss.hh:284

◆ getDerivative() [1/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 236 of file JGauss.hh.

237 {
238 const double u = (x - mean) / sigma;
239
240 return signal * get(u) * -u / sigma;
241 }

◆ operator()() [1/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::operator() ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 250 of file JGauss.hh.

251 {
252 return getValue(x);
253 }
double getValue(const double x) const
Function value.
Definition JGauss.hh:222

◆ getGradient() [1/2]

template<int ID_t, bool normalised = false>
const JGauss_t & JMATH::JGauss< ID_t, normalised >::getGradient ( const double x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 262 of file JGauss.hh.

263 {
264 const double w = 1.0 / sigma;
265 const double u = (x - mean) * w;
266 const double f0 = get(u);
267 const double fs = signal * f0;
268
269 gradient.mean = fs * (u) * w; // d(f)/d(mean)
270 gradient.sigma = fs * (u + 1.0) * (u - 1.0) * w; // d(f)/d(sigma)
271 gradient.signal = f0; // d(f)/d(signal)
272 gradient.background = 1.0; // d(f)/d(background)
273
274 return gradient;
275 }
JGauss_t gradient
Definition JGauss.hh:289

◆ get() [1/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivate

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 284 of file JGauss.hh.

285 {
286 return exp(-0.5*u*u) / (sqrt(2.0*PI) * sigma);
287 }

◆ getValue() [2/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::getValue ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 1621 of file JMathlib.hh.

1622 {
1623 const double u = (x - center) / sigma;
1624
1625 return get(u);
1626 }

◆ getDerivative() [2/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 1635 of file JMathlib.hh.

1636 {
1637 const double w = 1.0 / sigma;
1638 const double u = (x - center) / sigma;
1639
1640 return get(u) * -u * w;
1641 }

◆ getGradient() [2/2]

template<int ID_t, bool normalised = false>
const JGauss & JMATH::JGauss< ID_t, normalised >::getGradient ( const double x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 1650 of file JMathlib.hh.

1651 {
1652 static JGauss gradient;
1653
1654 const double w = 1.0 / sigma;
1655 const double u = (x - center) * w;
1656 const double f0 = get(u);
1657
1658 gradient.center = f0 * u * w; // d(f)/d(center)
1659 gradient.sigma = f0 * u * u * w; // d(f)/d(sigma)
1660
1661 return gradient;
1662 }

◆ get() [2/2]

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivate

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 1675 of file JMathlib.hh.

1676 {
1677 return exp(-0.5*u*u);
1678 }

◆ equals()

bool JMATH::JGauss_t::equals ( const JGauss_t & gauss,
const double eps = std::numeric_limits<double>::min() ) const
inlineinherited

Equality.

Parameters
gaussgauss
epsnumerical precision
Returns
true if gauss's identical; else false

Definition at line 70 of file JGauss.hh.

72 {
73 return (fabs(mean - gauss.mean) <= eps &&
74 fabs(sigma - gauss.sigma) <= eps &&
75 fabs(signal - gauss.signal) <= eps &&
76 fabs(background - gauss.background) <= eps);
77 }

◆ add() [1/2]

JGauss_t & JMATH::JGauss_t::add ( const JGauss_t & gauss)
inlineinherited

Add gauss.

Parameters
gaussgauss
Returns
this gauss

Definition at line 86 of file JGauss.hh.

87 {
88 mean += gauss.mean;
89 sigma += gauss.sigma;
90 signal += gauss.signal;
91 background += gauss.background;
92
93 return *this;
94 }

◆ sub() [1/2]

JGauss_t & JMATH::JGauss_t::sub ( const JGauss_t & gauss)
inlineinherited

Subtract gauss.

Parameters
gaussgauss
Returns
this gauss

Definition at line 103 of file JGauss.hh.

104 {
105 mean -= gauss.mean;
106 sigma -= gauss.sigma;
107 signal -= gauss.signal;
108 background -= gauss.background;
109
110 return *this;
111 }

◆ mul() [1/3]

JGauss_t & JMATH::JGauss_t::mul ( const double factor)
inlineinherited

Scale gauss.

Parameters
factormultiplication factor
Returns
this gauss

Definition at line 120 of file JGauss.hh.

121 {
122 mean *= factor;
123 sigma *= factor;
124 signal *= factor;
125 background *= factor;
126
127 return *this;
128 }

◆ mul() [2/3]

JGauss_t & JMATH::JMath< JGauss_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

◆ operator()() [2/2]

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

Function value.

Parameters
argsabscissa value(s)
Returns
function value

Definition at line 362 of file JMathlib.hh.

363 {
364 return static_cast<const JF1_t&>(*this).getValue(args...);
365 }

◆ negate()

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

Negate function.

Returns
this function

Definition at line 203 of file JMathlib.hh.

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

◆ add() [2/2]

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

Add function.

Parameters
f1function
Returns
this function

Definition at line 219 of file JMathlib.hh.

220 {
221 for (const auto& i : JF1_t::parameters) {
222 static_cast<JF1_t&>(*this).*i += f1.*i;
223 }
224
225 return static_cast<JF1_t&>(*this);
226 }
const JPolynome f1(1.0, 2.0, 3.0)
Function.

◆ sub() [2/2]

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

Subtract function.

Parameters
f1function
Returns
this function

Definition at line 235 of file JMathlib.hh.

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

◆ mul() [3/3]

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

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 251 of file JMathlib.hh.

252 {
253 for (const auto& i : JF1_t::parameters) {
254 static_cast<JF1_t&>(*this).*i *= factor;
255 }
256
257 return static_cast<JF1_t&>(*this);
258 }

◆ div()

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

Scale function.

Parameters
factorfactor
Returns
this function

Definition at line 267 of file JMathlib.hh.

268 {
269 for (const auto& i : JF1_t::parameters) {
270 static_cast<JF1_t&>(*this).*i /= factor;
271 }
272
273 return static_cast<JF1_t&>(*this);
274 }

Member Data Documentation

◆ gradient

template<int ID_t, bool normalised = false>
JGauss_t JMATH::JGauss< ID_t, normalised >::gradient
mutableprivate

Definition at line 289 of file JGauss.hh.

◆ ID

template<int ID_t, bool normalised = false>
const int JMATH::JGauss< ID_t, normalised >::ID = ID_t
static

Definition at line 1590 of file JMathlib.hh.

◆ center

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::center

center

Definition at line 1664 of file JMathlib.hh.

◆ sigma

template<int ID_t, bool normalised = false>
double JMATH::JGauss< ID_t, normalised >::sigma

sigma

Definition at line 1665 of file JMathlib.hh.

◆ parameters

template<int ID_t>
const parameter_list< JGauss< ID_t, true > > JMATH::JGauss< ID_t >::parameters = { &JGauss<ID_t, normalised>::center, &JGauss<ID_t, normalised>::sigma }
static

parameters

Set parameters.

Definition at line 1666 of file JMathlib.hh.

◆ mean

double JMATH::JGauss_t::mean
inherited

Definition at line 161 of file JGauss.hh.

◆ signal

double JMATH::JGauss_t::signal
inherited

Definition at line 163 of file JGauss.hh.

◆ background

double JMATH::JGauss_t::background
inherited

Definition at line 164 of file JGauss.hh.


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