cisst-saw
Loading...
Searching...
No Matches
nmrFnJacobianSolver Class Reference

#include <nmrFnJacobianSolver.h>

Public Member Functions

 nmrFnJacobianSolver (void)
 nmrFnJacobianSolver (CISSTNETLIB_INTEGER n)
 nmrFnJacobianSolver (vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
void Allocate (CISSTNETLIB_INTEGER n)
void Allocate (vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
template<int __instanceLineF, class __elementTypeF, int __instanceLineJ, class __elementTypeJ>
void Solve (nmrCallBackFunctionF< __instanceLineF, __elementTypeF > &callBackF, nmrCallBackFunctionJ< __instanceLineJ, __elementTypeJ > &callBackJ, vctDynamicVector< CISSTNETLIB_DOUBLE > &X, vctDynamicVector< CISSTNETLIB_DOUBLE > &F, vctDynamicVector< CISSTNETLIB_DOUBLE > &J, CISSTNETLIB_DOUBLE tolerance) throw (std::runtime_error)

Protected Attributes

CISSTNETLIB_INTEGER N
CISSTNETLIB_INTEGER Ldfjac
CISSTNETLIB_DOUBLE Tolerance
CISSTNETLIB_INTEGER Info
CISSTNETLIB_INTEGER Lwork
vctDynamicVector< CISSTNETLIB_DOUBLE > Work

Detailed Description

Algorithm Fn: Solve nonlinear set of equations using Powell's method The purpose of this class is to find a zero of a system of N nonlinear functions in N variables by a modification of the powell hybrid method. the user must provide a subroutine which calculates the functions and the jacobian.

The data members of this class are:

  • N: The number of variables and also the equations. N >= 0.
  • Tolerance: A nonnegative input variable. Termination occurs when the algorithm estimates either that the relative error in the sum of squares is at most Tolerance or that the relative error between X and the solution is at most Tolerance. (Default set to 1.0e-6).
  • Work: A working vector of length N*(N+13)/2
  • LWork: Length of working array.
  • Info: = info is an integer output variable. if the user has terminated execution, info is set to the (negative) value of Flag. see description of FunctionPointer. otherwise, info is set as follows.

    info = 0 improper input parameters.

    info = 1 algorithm estimates that the relative error between x and the solution is at most tol.

    info = 2 number of calls to user function with iflag = 1 has reached 100*(n+1).

    info = 3 tol is too small. no further improvement in the approximate solution x is possible.

    info = 4 iteration is not making good progress.

The input/output from this class is:

  • X: On entry, the inital estimate of solution vector. On exit, final estimate of solution vector.
  • callBack: Is object of type nmrCallBackFnSolver used to supply the user method. The user method which belongs to a user defined class 'Cfoo' has the following definition int Cfoo::Mbar (vctDynamicVectorRef<double> &X, vctDynamicVectorRef<double> &F, vctDynamicMatrixRef<double> &J, long int &Flag) if Flag = 1 calculate the functions at X and return this vector in F. do not alter J. if Flag = 2 calculate the jacobian at X and return this matrix in J. do not alter F. the value of Flag should not be changed by Mbar unless the user wants to terminate execution of Solver. in this case set Flag to a negative integer.
  The solver calls this method when needed to obtain value for function for
  a given variable values X.

  The following constructor can be used to contruct the nmrCallBackFnSolver object
  required to be passed to the Solve() method. This object needs to be created
  only once per given set of nonlinear functions to be minized.
      nmrCallBackFnSolver<nmrUNIQUE_IDENTIFIER_LINE, Cfoo> callBackObject(this, &Cfoo::Mbar);
Note
This code relies on the ERC CISST cnetlib library. Since cnetlib is optional, make sure that CISST_HAS_CNETLIB has been turned ON during the configuration with CMake.

Constructor & Destructor Documentation

◆ nmrFnJacobianSolver() [1/3]

nmrFnJacobianSolver::nmrFnJacobianSolver ( void )
inline

Default constructor. This constructor doesn't allocate any memory. If you use this constructor, you will need to use one of the Allocate() methods before you can use the Solve method.

◆ nmrFnJacobianSolver() [2/3]

nmrFnJacobianSolver::nmrFnJacobianSolver ( CISSTNETLIB_INTEGER n)
inline

Constructor with memory allocation. This constructor allocates the memory based on N. It relies on the method Allocate(). The next call to the Solve() method will check that the parameters match the dimension.

Parameters
nNumber of variables This order will be used for the output as well.

◆ nmrFnJacobianSolver() [3/3]

nmrFnJacobianSolver::nmrFnJacobianSolver ( vctDynamicVector< CISSTNETLIB_DOUBLE > & X)
inline

Constructor with memory allocation. This constructor allocates the memory based on the actual input of the Solve() method. It relies on the method Allocate(). The next call to the Solve() method will check that the parameters match the dimension and storage order.

Member Function Documentation

◆ Allocate() [1/2]

void nmrFnJacobianSolver::Allocate ( CISSTNETLIB_INTEGER n)
inline

This method allocates the memory based on N. The next call to the Solve() method will check that the parameters match the dimension.

Parameters
nNumber of variables

◆ Allocate() [2/2]

void nmrFnJacobianSolver::Allocate ( vctDynamicVector< CISSTNETLIB_DOUBLE > & X)
inline

Allocate memory to solve this problem. This method provides a convenient way to extract the required sizes from the input containers. The next call to the Solve() method will check that the parameters match the dimension.

◆ Solve()

template<int __instanceLineF, class __elementTypeF, int __instanceLineJ, class __elementTypeJ>
void nmrFnJacobianSolver::Solve ( nmrCallBackFunctionF< __instanceLineF, __elementTypeF > & callBackF,
nmrCallBackFunctionJ< __instanceLineJ, __elementTypeJ > & callBackJ,
vctDynamicVector< CISSTNETLIB_DOUBLE > & X,
vctDynamicVector< CISSTNETLIB_DOUBLE > & F,
vctDynamicVector< CISSTNETLIB_DOUBLE > & J,
CISSTNETLIB_DOUBLE tolerance )
throw (std::runtime_error )
inline

This computes the solves nonlinear equations problem invloving N functions in N variables. On input, X contains the starting point, On output, X contains the final estimate F contains the final values

Member Data Documentation

◆ Info

CISSTNETLIB_INTEGER nmrFnJacobianSolver::Info
protected

◆ Ldfjac

CISSTNETLIB_INTEGER nmrFnJacobianSolver::Ldfjac
protected

◆ Lwork

CISSTNETLIB_INTEGER nmrFnJacobianSolver::Lwork
protected

◆ N

CISSTNETLIB_INTEGER nmrFnJacobianSolver::N
protected

◆ Tolerance

CISSTNETLIB_DOUBLE nmrFnJacobianSolver::Tolerance
protected

◆ Work

vctDynamicVector<CISSTNETLIB_DOUBLE> nmrFnJacobianSolver::Work
protected

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