Xmipp  v3.23.11-Nereus
Public Member Functions | List of all members
GaussianInterpolator Class Reference

#include <numerical_tools.h>

Public Member Functions

void initialize (double xmax, int N, bool normalize=true)
 
double getValue (double x) const
 

Detailed Description

Gaussian interpolator

This class helps to perform a quick evaluation of the N(0,1) Gaussian. 1/sqrt(2*PI)*exp(-x^2)

GI.initialize(6,60000);
double g=GI.getValue(1.96);

Definition at line 104 of file numerical_tools.h.

Member Function Documentation

◆ getValue()

double GaussianInterpolator::getValue ( double  x) const
inline

Value

Definition at line 118 of file numerical_tools.h.

118  {
119  x=fabs(x);
120  if (x>xmax) return 0;
121  else
122  {
123  auto iaux=(int)round(x*ixstep);
124  return DIRECT_A1D_ELEM(v,iaux);
125  }
126  }
doublereal * x
#define DIRECT_A1D_ELEM(v, i)
int round(double x)
Definition: ap.cpp:7245

◆ initialize()

void GaussianInterpolator::initialize ( double  xmax,
int  N,
bool  normalize = true 
)

Constructor. xmax is the maximum value considered by the interpolator. N is the number of samples between 0 and xmax. If normalize is set to true, then the factor 1/sqrt(2*PI) is introduced.

Definition at line 65 of file numerical_tools.cpp.

66 {
67  xmax=_xmax;
68  xstep=xmax/N;
69  ixstep=1.0/xstep;
70  v.initZeros(N);
71  double inorm=1.0/sqrt(2*PI);
73  {
74  double x=i*xstep;
75  v(i)=exp(-x*x/2);
76  if (normalize)
77  v(i)*=inorm;
78  }
79 }
void sqrt(Image< double > &op)
doublereal * x
#define i
quaternion_type< T > normalize(quaternion_type< T > q)
Definition: point.cpp:278
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void initZeros(const MultidimArray< T1 > &op)
#define PI
Definition: tools.h:43

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