15 #ifndef itkRayleighFunction_h
16 #define itkRayleighFunction_h
18 #include <vnl/vnl_least_squares_function.h>
26 vnl_vector< double > &xData,
27 vnl_vector< double > &yData,
29 : vnl_least_squares_function(2, nDataPoints,
30 flgUseGradient ? use_gradient : no_gradient)
32 m_nDataPoints = nDataPoints;
39 double compute(
unsigned int i,
double k,
double s)
41 return compute( (*m_xData)[i], k, s );
48 return k*x*exp( -x*x/(2.*sSq) )/sSq;
54 return compute_dydk( (*m_xData)[i], k, s );
61 return x*exp( -x*x/(2.*sSq) )/sSq;
67 return compute_dydsig( (*m_xData)[i], k, s );
74 return x*(k*x*x - 2.*k*sSq)*exp( -x*x/(2.*sSq) )/(sSq*sSq*s);
79 void f(
const vnl_vector<double> &
a, vnl_vector<double> &residual)
override
81 for (
unsigned int i=0; i<m_nDataPoints; ++i)
83 residual[i] = compute(i, a[0], a[1] ) - (*m_yData)[i];
89 void gradf(
const vnl_vector<double> &
a, vnl_matrix<double> &J)
override
91 for (
unsigned int i=0; i<m_nDataPoints; ++i) {
92 J(i,0) = compute_dydk(i, a[0], a[1] );
95 for (
unsigned int i=0; i<m_nDataPoints; ++i) {
96 J(i,1) = compute_dydsig(i, a[0], a[1] );
vnl_vector< double > * m_xData
The 'x' ordinate data values.
Definition: itkRayleighFunction.h:106
RayleighFunction(unsigned int nDataPoints, vnl_vector< double > &xData, vnl_vector< double > &yData, bool flgUseGradient)
Definition: itkRayleighFunction.h:25
double compute(unsigned int i, double k, double s)
Compute the value of the Rayleigh distribution at a given index 'i'.
Definition: itkRayleighFunction.h:39
unsigned int m_nDataPoints
The number of data points.
Definition: itkRayleighFunction.h:103
double compute_dydsig(unsigned int i, double k, double s)
Compute the derivative with respect to 's' at index 'i'.
Definition: itkRayleighFunction.h:65
void f(const vnl_vector< double > &a, vnl_vector< double > &residual) override
Evaluate the vector of residual for parameters 'a'.
Definition: itkRayleighFunction.h:79
Definition: itkRayleighFunction.h:21
double compute(double x, double k, double s)
Compute the value of the Rayleigh distribution at a given 'x'.
Definition: itkRayleighFunction.h:45
double compute_dydk(double x, double k, double s)
Compute the derivative with respect to 'k' at 'x'.
Definition: itkRayleighFunction.h:58
void gradf(const vnl_vector< double > &a, vnl_matrix< double > &J) override
Evaluate the gradient with respect to each parameter.
Definition: itkRayleighFunction.h:89
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8272
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
double compute_dydsig(double x, double k, double s)
Compute the derivative with respect to 's' at 'x'.
Definition: itkRayleighFunction.h:71
double compute_dydk(unsigned int i, double k, double s)
Compute the derivative with respect to 'k' at index 'i'.
Definition: itkRayleighFunction.h:52
vnl_vector< double > * m_yData
The 'y' ordinate data values.
Definition: itkRayleighFunction.h:108
GLdouble s
Definition: glew.h:1374