15 #ifndef itkExponentialDecayFunction_h
16 #define itkExponentialDecayFunction_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 );
53 return compute_dydk( (*m_xData)[i], k, s );
65 return compute_dydsig( (*m_xData)[i], k, s );
71 return -k*x*exp( -s*x );
76 void f(
const vnl_vector<double> &
a, vnl_vector<double> &residual)
override
78 for (
unsigned int i=0; i<m_nDataPoints; ++i)
80 residual[i] = compute(i, a[0], a[1] ) - (*m_yData)[i];
86 void gradf(
const vnl_vector<double> &
a, vnl_matrix<double> &J)
override
88 for (
unsigned int i=0; i<m_nDataPoints; ++i) {
89 J(i,0) = compute_dydk(i, a[0], a[1] );
92 for (
unsigned int i=0; i<m_nDataPoints; ++i) {
93 J(i,1) = compute_dydsig(i, a[0], a[1] );
double compute(double x, double k, double s)
Compute the value of the exponential decay function at a given 'x'.
Definition: itkExponentialDecayFunction.h:45
double compute_dydsig(unsigned int i, double k, double s)
Compute the derivative with respect to 's' at index 'i'.
Definition: itkExponentialDecayFunction.h:63
double compute_dydk(unsigned int i, double k, double s)
Compute the derivative with respect to 'k' at index 'i'.
Definition: itkExponentialDecayFunction.h:51
unsigned int m_nDataPoints
The number of data points.
Definition: itkExponentialDecayFunction.h:100
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8272
void gradf(const vnl_vector< double > &a, vnl_matrix< double > &J) override
Evaluate the gradient with respect to each parameter.
Definition: itkExponentialDecayFunction.h:86
Definition: itkExponentialDecayFunction.h:21
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
void f(const vnl_vector< double > &a, vnl_vector< double > &residual) override
Evaluate the vector of residual for parameters 'a'.
Definition: itkExponentialDecayFunction.h:76
ExponentialDecayFunction(unsigned int nDataPoints, vnl_vector< double > &xData, vnl_vector< double > &yData, bool flgUseGradient)
Definition: itkExponentialDecayFunction.h:25
double compute_dydk(double x, double k, double s)
Compute the derivative with respect to 'k' at 'x'.
Definition: itkExponentialDecayFunction.h:57
vnl_vector< double > * m_yData
The 'y' ordinate data values.
Definition: itkExponentialDecayFunction.h:105
GLdouble s
Definition: glew.h:1374
vnl_vector< double > * m_xData
The 'x' ordinate data values.
Definition: itkExponentialDecayFunction.h:103
double compute(unsigned int i, double k, double s)
Compute the value of the exponential decay function at a given index 'i'.
Definition: itkExponentialDecayFunction.h:39
double compute_dydsig(double x, double k, double s)
Compute the derivative with respect to 's' at 'x'.
Definition: itkExponentialDecayFunction.h:69