Helios++
Helios software for LiDAR simulations
MarquardtFitter Class Reference

Class to compute Marquardt fitter. More...

#include <MarquardtFitter.h>

Collaboration diagram for MarquardtFitter:

Public Member Functions

 MarquardtFitter (std::vector< std::vector< double >> &apMatrix)
 Base constructor for MarquardtFitter. More...
 
void setData (const std::vector< double > &zvalues)
 Set the values of the original data points that are going to be fit. More...
 
std::vector< double > getParameters ()
 Obtain marquardt fitter current arguments/parameters. More...
 
void setParameters (const std::vector< double > &parameters)
 Set the arguments/parameters for the fitter. More...
 
std::vector< std::vector< double > > getMatrix (std::vector< std::vector< double >> &A, std::vector< int > &r, int j0, int j1)
 Get a submatrix. More...
 
double evaluate (const std::vector< double > &values, const std::vector< double > &params)
 Evaluate the marquardt fitter. More...
 
double calculateErrors ()
 Compute the cumulative error for current values. More...
 
double calculateDerivative (int k, std::vector< double > &values, std::vector< double > &params)
 Given a set of parameters, and inputs, calculates the derivative of the k'th parameter. More...
 
void calculateDerivativeFast (double x, double c, double d, double coefficient, std::vector< double > &dvec)
 Alternative method for faster derivative computation. More...
 
void calculateDerivatives ()
 Compute matrix of partial derivatives. More...
 
void calculateDerivativesFast ()
 Alternative method for faster computation of partial derivatives matrix. More...
 
void createBetaMatrix ()
 Create the beta matrix.
 
void createAlphaPrimeMatrix ()
 Create the alpha prime matrix.
 
void iterateValues ()
 Iterate over values considering the current error and arguments/parameters and compute the changes.
 
void initializeWorkspace ()
 Initializes the workspace for the Marquardt fitter.
 
void fitData ()
 Iterate until fitting is finished.
 
void updateLambda (double value)
 Update lambda. More...
 
std::string printMatrix ()
 Build a string representing the alpha prime matrix together with beta vector for debugging purposes. More...
 
std::string printMatrix (std::vector< std::vector< double >> &matrix)
 Build a string representing given matrix for debugging purposes. More...
 

Private Attributes

std::vector< std::vector< double > > X
 X input vector.
 
std::vector< double > Z
 Z output vecctor.
 
std::vector< double > A
 A arguments vector.
 
size_t alphaPrimeN = 0
 Alpha prime vector dimensionality.
 
std::vector< std::vector< double > > & ALPHA_PRIME
 Reference to alpha prime vector.
 
std::vector< std::vector< double > > DERIVATIVES
 Vector containing derivatives (jacobian vector)
 
std::vector< double > BETA
 Beta vector.
 
std::vector< double > LAMBDA
 Lambda vector.
 
std::vector< double > ERR
 Error vector.
 
double DELTA = 1e-6
 Delta for numerical derivatives.
 
double MINERROR = 1e-9
 Mnimum error for evaluating. It is no longer used and it might be removed in the future.
 
double MINCHANGE = 1e-3
 Minimum change. It is no longer used and it might be removed in the future.
 

Detailed Description

Class to compute Marquardt fitter.

Constructor & Destructor Documentation

◆ MarquardtFitter()

MarquardtFitter::MarquardtFitter ( std::vector< std::vector< double >> &  apMatrix)
inlineexplicit

Base constructor for MarquardtFitter.

Parameters
apMatrixReference to the alpha prime matrix. It is passed this way to reduce the number of memory management operations, mainly due to using multiple marquardt fitters

Member Function Documentation

◆ calculateDerivative()

double MarquardtFitter::calculateDerivative ( int  k,
std::vector< double > &  values,
std::vector< double > &  params 
)

Given a set of parameters, and inputs, calculates the derivative of the k'th parameter.

\[ \frac{\partial{f}}{\partial{a_{k}}} \]

Parameters
kIndex of the parameter that the derivative is being taken of
paramsArray that will be used to calculate derivatives, note params will be modified.
xSet of values to use.
Returns
Computed derivative
See also
MarquardtFitter::calculateDerivativeFast( double, double, double, double, std::vector<double>&)

◆ calculateDerivativeFast()

void MarquardtFitter::calculateDerivativeFast ( double  x,
double  c,
double  d,
double  coefficient,
std::vector< double > &  dvec 
)

Alternative method for faster derivative computation.

Parameters
xInput for the Marquardt fitter
cThird argument (index 2)
dFourth argument (index 3)
coefficientCoefficient calculated with respect to second argument (index 1)
[out]dvecVector of partial derivatives (where the output is stored)
See also
MarquardtFitter::calculateDerivative(int, std::vector<double>&, std::vector<double>&)

◆ calculateDerivatives()

void MarquardtFitter::calculateDerivatives ( )

Compute matrix of partial derivatives.

See also
calculateDerivativesFast

◆ calculateDerivativesFast()

void MarquardtFitter::calculateDerivativesFast ( )

Alternative method for faster computation of partial derivatives matrix.

See also
calculateDerivatives

◆ calculateErrors()

double MarquardtFitter::calculateErrors ( )

Compute the cumulative error for current values.

Returns
Cumulative error for current values

◆ evaluate()

double MarquardtFitter::evaluate ( const std::vector< double > &  values,
const std::vector< double > &  params 
)

Evaluate the marquardt fitter.

Parameters
valuesValues to evaluate over. At the moment values[0] is the only considered one.
paramsArguments/parameters which define the evaluation
Returns
Marquardt fitter evaluation

◆ getMatrix()

vector< vector< double > > MarquardtFitter::getMatrix ( std::vector< std::vector< double >> &  A,
std::vector< int > &  r,
int  j0,
int  j1 
)

Get a submatrix.

Parameters
AMatrix where values are taken from
rArray of row indices
j0Initial column index
j1Final column index
Returns

◆ getParameters()

vector< double > MarquardtFitter::getParameters ( )

Obtain marquardt fitter current arguments/parameters.

Returns
Marquardt fitter current arguments/parameters

◆ printMatrix() [1/2]

string MarquardtFitter::printMatrix ( )

Build a string representing the alpha prime matrix together with beta vector for debugging purposes.

Returns
String representing the alpha prime matrix together with beta vector

◆ printMatrix() [2/2]

std::string MarquardtFitter::printMatrix ( std::vector< std::vector< double >> &  matrix)

Build a string representing given matrix for debugging purposes.

Parameters
matrixMatrix to be debugged
Returns
String representing given matrix

◆ setData()

void MarquardtFitter::setData ( const std::vector< double > &  zvalues)

Set the values of the original data points that are going to be fit.

Parameters
zvaluesValues of the original data points

◆ setParameters()

void MarquardtFitter::setParameters ( const std::vector< double > &  parameters)

Set the arguments/parameters for the fitter.

Parameters
parametersParameters for the fitter

◆ updateLambda()

void MarquardtFitter::updateLambda ( double  value)

Update lambda.

When value is less than $0$, then lambda is multiplied by $10$. Otherwise it is multiplied by $0.1$.

Parameters
valueUpdate value

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