Jpp  19.1.0-rc.1
the software that should make you happy
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
JMATH::JGauss2D< ID_t, normalise > Struct Template Reference

2D correlated Gauss function. More...

#include <JMathlib2D.hh>

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

Public Member Functions

 JGauss2D ()
 Default constructor. More...
 
 JGauss2D (const double mean, const double sigma)
 Constructor. More...
 
double getValue (const double x, const double y) const
 Function value. More...
 
const JGauss2DgetGradient (const double x, const double y) const
 Get gradient. More...
 
double operator() (const Args &...args) const
 Function value. More...
 
double getValue (const double x) const
 Function value. More...
 
double getDerivative (const double x) const
 Derivative value. More...
 
double getDerivative (const double x) const
 Derivative value. More...
 
double operator() (const double x) const
 Function value. More...
 
double operator() (const Args &...args) const
 Function value. More...
 
const JGauss_tgetGradient (const double x) const
 Get gradient. More...
 
bool equals (const JGauss_t &gauss, const double eps=std::numeric_limits< double >::min()) const
 Equality. More...
 
JGauss_tadd (const JGauss_t &gauss)
 Add gauss. More...
 
JGauss< ID_t > & add (const JGauss< ID_t > &f1)
 Add function. More...
 
JGauss_tsub (const JGauss_t &gauss)
 Subtract gauss. More...
 
JGauss< ID_t > & sub (const JGauss< ID_t > &f1)
 Subtract function. More...
 
JGauss_tmul (const double factor)
 Scale gauss. More...
 
JGauss_tmul (const JSecond_t &object)
 Multiply with object. More...
 
JGauss< ID_t > & mul (const double factor)
 Scale function. More...
 
JGauss< ID_t > & negate ()
 Negate function. More...
 
JGauss< ID_t > & div (const double factor)
 Scale function. More...
 

Public Attributes

double center
 center More...
 
double sigma
 sigma More...
 
double mean
 
double signal
 
double background
 

Static Public Attributes

static const int ID
 
static const parameter_list< JGaussparameters
 parameters More...
 

Private Member Functions

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

Private Attributes

JGauss_t gradient
 

Detailed Description

template<int ID_t, bool normalise = false>
struct JMATH::JGauss2D< ID_t, normalise >

2D correlated Gauss function.

Definition at line 182 of file JMathlib2D.hh.

Member Typedef Documentation

◆ parameter_type

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

Type definition of fit parameter.

Definition at line 179 of file JGauss.hh.

Constructor & Destructor Documentation

◆ JGauss2D() [1/2]

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

Default constructor.

Definition at line 192 of file JMathlib2D.hh.

193  {}

◆ JGauss2D() [2/2]

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

Constructor.

Parameters
meanmean
sigmasigma

Definition at line 202 of file JMathlib2D.hh.

203  :
205  {}
double mean
Definition: JGauss.hh:161
Gauss function object.
Definition: JGauss.hh:175

Member Function Documentation

◆ getValue() [1/2]

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

Function value.

Parameters
xabscissa value
yabscissa value
Returns
function value

Definition at line 215 of file JMathlib2D.hh.

216  {
218 
219  return (static_cast<const JGauss_t&>(*this).getValue(x) *
220  static_cast<const JGauss_t&>(*this).getValue(y));
221  }
Gauss model.
Definition: JGauss.hh:32
JGauss_t()
Default constructor.
Definition: JGauss.hh:36

◆ getGradient() [1/2]

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

Get gradient.

Parameters
xabscissa value
yabscissa value
Returns
gradient

Definition at line 231 of file JMathlib2D.hh.

232  {
233  static JGauss2D gradient;
234 
236 
237  static_cast<JGauss_t&>(gradient) = JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(x)).mul(static_cast<const JGauss_t&>(*this).getValue(y));
238  static_cast<JGauss_t&>(gradient) += JGauss_t(static_cast<const JGauss_t&>(*this).getGradient(y)).mul(static_cast<const JGauss_t&>(*this).getValue(x));
239 
240  return gradient;
241  }
2D correlated Gauss function.
Definition: JMathlib2D.hh:185
JGauss_t & mul(const double factor)
Scale gauss.
Definition: JGauss.hh:120

◆ operator()() [1/3]

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

◆ 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 u[N+1]
Definition: JPolint.hh:865
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 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  }
data_type w[N+1][M+1]
Definition: JPolint.hh:867

◆ 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
Function value.
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 362 of file JMathlib.hh.

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

◆ 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  }
double sigma
Definition: JGauss.hh:162

◆ 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  }
static const double PI
Mathematical constants.

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

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

◆ 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

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

◆ center

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

center

Definition at line 1664 of file JMathlib.hh.

◆ sigma

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

sigma

Definition at line 1665 of file JMathlib.hh.

◆ parameters

const parameter_list< JGauss< ID_t, normalised > > JMATH::JGauss< ID_t, normalised >::parameters
staticinherited

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 file: