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

3D correlated Gauss function. More...

#include <JMathlib3D.hh>

Inheritance diagram for JMATH::JGauss3D< ID_t, normalise >:
JMATH::JMathlib< JGauss3D< ID_t, false > > JMATH::JGauss< ID_t, false > 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_t::* parameter_type
 Type definition of fit parameter.
 

Public Member Functions

 JGauss3D ()
 Default constructor.
 
 JGauss3D (const double mean, const double sigma)
 Constructor.
 
double getValue (const double x, const double y, const double z) const
 Function value.
 
const JGauss3DgetGradient (const double x, const double y, const double z) 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.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
double getDerivative (const double x) const
 Derivative value.
 
double operator() (const double x) const
 Function value.
 
double operator() (const Args &...args) const
 Function value.
 
const JGauss_tgetGradient (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< ID_t > & add (const JGauss< ID_t > &f1)
 Add function.
 
JGauss_tsub (const JGauss_t &gauss)
 Subtract gauss.
 
JGauss< ID_t > & sub (const JGauss< ID_t > &f1)
 Subtract function.
 
JGauss_tmul (const double factor)
 Scale gauss.
 
JGauss_tmul (const JSecond_t &object)
 Multiply with object.
 
JGauss< ID_t > & mul (const double factor)
 Scale function.
 
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 > & negate ()
 Negate 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
 
static constexpr parameter_list< JGauss, 2 > 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 normalise = false>
struct JMATH::JGauss3D< ID_t, normalise >

3D correlated Gauss function.

Definition at line 267 of file JMathlib3D.hh.

Member Typedef Documentation

◆ parameter_type

double JGauss_t::* JMATH::JGauss< ID_t, normalised >::parameter_type
inherited

Type definition of fit parameter.

Definition at line 179 of file JGauss.hh.

Constructor & Destructor Documentation

◆ JGauss3D() [1/2]

template<int ID_t, bool normalise = false>
JMATH::JGauss3D< ID_t, normalise >::JGauss3D ( )
inline

Default constructor.

Definition at line 277 of file JMathlib3D.hh.

278 {}

◆ JGauss3D() [2/2]

template<int ID_t, bool normalise = false>
JMATH::JGauss3D< ID_t, normalise >::JGauss3D ( const double mean,
const double sigma )
inline

Constructor.

Parameters
meanmean
sigmasigma

Definition at line 287 of file JMathlib3D.hh.

Member Function Documentation

◆ getValue() [1/2]

template<int ID_t, bool normalise = false>
double JMATH::JGauss3D< ID_t, normalise >::getValue ( const double x,
const double y,
const double z ) const
inline

Function value.

Parameters
xabscissa value
yabscissa value
zabscissa value
Returns
function value

Definition at line 301 of file JMathlib3D.hh.

302 {
303 typedef JGauss<ID_t, normalise> JGauss_t;
304
305 return (static_cast<const JGauss_t&>(*this).getValue(x) *
306 static_cast<const JGauss_t&>(*this).getValue(y) *
307 static_cast<const JGauss_t&>(*this).getValue(z));
308 }
JGauss_t()
Default constructor.
Definition JGauss.hh:36

◆ getGradient() [1/2]

template<int ID_t, bool normalise = false>
const JGauss3D & JMATH::JGauss3D< ID_t, normalise >::getGradient ( const double x,
const double y,
const double z ) const
inline

Get gradient.

Parameters
xabscissa value
yabscissa value
zabscissa value
Returns
gradient

Definition at line 319 of file JMathlib3D.hh.

320 {
321 static JGauss3D gradient;
322
323 typedef JGauss<ID_t, normalise> JGauss_t;
324
325 static_cast<JGauss_t&>(gradient) = JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(x)).mul(static_cast<const JGauss_t&>(*this).getValue(y) * static_cast<const JGauss_t&>(*this).getValue(z));
326 static_cast<JGauss_t&>(gradient) += JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(y)).mul(static_cast<const JGauss_t&>(*this).getValue(x) * static_cast<const JGauss_t&>(*this).getValue(z));
327 static_cast<JGauss_t&>(gradient) += JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(z)).mul(static_cast<const JGauss_t&>(*this).getValue(x) * static_cast<const JGauss_t&>(*this).getValue(y));
328
329 return gradient;
330 }
JGauss3D()
Default constructor.
JGauss_t & mul(const double factor)
Scale gauss.
Definition JGauss.hh:120

◆ operator()() [1/3]

double JMATH::JMathlib< JGauss3D< ID_t, false > >::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/4]

double JMATH::JMathlib< JGauss3D< ID_t, false > >::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/4]

double & JMATH::JMathlib< JGauss3D< ID_t, false > >::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 }

◆ getValue() [2/2]

double JMATH::JGauss< ID_t, normalised >::getValue ( const double x) const
inlineinherited

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 background
Definition JGauss.hh:164
double signal
Definition JGauss.hh:163

◆ getDerivative() [1/2]

double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inlineinherited

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 }

◆ getDerivative() [2/2]

double JMATH::JGauss< ID_t, normalised >::getDerivative ( const double x) const
inlineinherited

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 1987 of file JMathlib.hh.

1988 {
1989 const double w = 1.0 / sigma;
1990 const double u = (x - center) / sigma;
1991
1992 return get(u) * -u * w;
1993 }

◆ operator()() [2/3]

double JMATH::JGauss< ID_t, normalised >::operator() ( const double x) const
inlineinherited

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
Definition JGauss.hh:222

◆ operator()() [3/3]

double JMATH::JMathlib< JGauss< ID_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 }

◆ getGradient() [2/2]

const JGauss_t & JMATH::JGauss< ID_t, normalised >::getGradient ( const double x) const
inlineinherited

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 }

◆ get() [1/2]

double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivateinherited

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 }

◆ get() [2/2]

double JMATH::JGauss< ID_t, normalised >::get ( const double u) const
inlineprivateinherited

Get ordinate value.

Parameters
uabscissa value
Returns
ordinate value

Definition at line 2028 of file JMathlib.hh.

2029 {
2030 return exp(-0.5*u*u);
2031 }

◆ 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 }
double gauss(const double x, const double sigma)
Gauss function (normalised to 1 at x = 0).

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

◆ 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 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() [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 }

◆ 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 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() [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 }

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

◆ operator[]() [3/4]

double JMATH::JMathlib< JGauss< ID_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[]() [4/4]

double & JMATH::JMathlib< JGauss< ID_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 }

◆ negate()

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::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 }

◆ div()

JGauss< ID_t > & JMATH::JCalculus< JGauss< ID_t > >::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

◆ gradient

JGauss_t JMATH::JGauss< ID_t, normalised >::gradient
mutableprivateinherited

Definition at line 289 of file JGauss.hh.

◆ ID

const int JMATH::JGauss< ID_t, normalised >::ID
staticinherited

Definition at line 1942 of file JMathlib.hh.

◆ center

double JMATH::JGauss< ID_t, normalised >::center
inherited

center

Definition at line 2016 of file JMathlib.hh.

◆ sigma

double JMATH::JGauss< ID_t, normalised >::sigma
inherited

sigma

Definition at line 2017 of file JMathlib.hh.

◆ parameters

parameter_list<JGauss, 2> JMATH::JGauss< ID_t, normalised >::parameters
staticconstexprinherited

Definition at line 2019 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 file: