# math_NewtonFunctionSetRoot Class Reference

This class computes the root of a set of N functions of N variables, knowing an initial guess at the solution and using the Newton Raphson algorithm. Knowledge of all the partial derivatives (Jacobian) is required. More...

`#include <math_NewtonFunctionSetRoot.hxx>`

## Public Member Functions

math_NewtonFunctionSetRoot (math_FunctionSetWithDerivatives &theFunction, const math_Vector &theXTolerance, const Standard_Real theFTolerance, const Standard_Integer tehNbIterations=100)
Initialize correctly all the fields of this class. The range (1, F.NbVariables()) must be especially respected for all vectors and matrix declarations. More...

math_NewtonFunctionSetRoot (math_FunctionSetWithDerivatives &theFunction, const Standard_Real theFTolerance, const Standard_Integer theNbIterations=100)
This constructor should be used in a sub-class to initialize correctly all the fields of this class. The range (1, F.NbVariables()) must be especially respected for all vectors and matrix declarations. The method SetTolerance must be called before performing the algorithm. More...

virtual ~math_NewtonFunctionSetRoot ()
Destructor. More...

void SetTolerance (const math_Vector &XTol)
Initializes the tolerance values for the unknowns. More...

void Perform (math_FunctionSetWithDerivatives &theFunction, const math_Vector &theStartingPoint)
The Newton method is done to improve the root of the function from the initial guess point. The solution is found when: abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;. More...

void Perform (math_FunctionSetWithDerivatives &theFunction, const math_Vector &theStartingPoint, const math_Vector &theInfBound, const math_Vector &theSupBound)
The Newton method is done to improve the root of the function from the initial guess point. Bounds may be given, to constrain the solution. The solution is found when: abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;. More...

virtual Standard_Boolean IsSolutionReached (math_FunctionSetWithDerivatives &F)
This method is called at the end of each iteration to check if the solution is found. Vectors DeltaX, Fvalues and Jacobian Matrix are consistent with the possible solution Vector Sol and can be inspected to decide whether the solution is reached or not. More...

Standard_Boolean IsDone () const
Returns true if the computations are successful, otherwise returns false. More...

const math_VectorRoot () const
Returns the value of the root of function F. Exceptions StdFail_NotDone if the algorithm fails (and IsDone returns false). More...

void Root (math_Vector &Root) const
outputs the root vector in Root. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Root is not equal to the range of the StartingPoint. More...

Standard_Integer StateNumber () const
Outputs the state number associated with the solution vector root. More...

const math_MatrixDerivative () const
Returns the matrix value of the derivative at the root. Exception NotDone is raised if the root was not found. More...

void Derivative (math_Matrix &Der) const
Outputs the matrix value of the derivative at the root in Der. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Der is not equal to the range of the StartingPoint. More...

const math_VectorFunctionSetErrors () const
Returns the vector value of the error done on the functions at the root. Exception NotDone is raised if the root was not found. More...

void FunctionSetErrors (math_Vector &Err) const
Outputs the vector value of the error done on the functions at the root in Err. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Err is not equal to the range of the StartingPoint. More...

Standard_Integer NbIterations () const
Returns the number of iterations really done during the computation of the Root. Exception NotDone is raised if the root was not found. More...

void Dump (Standard_OStream &o) const
Prints information on the current state of the object. Is used to redefine the operator <<. More...

## Protected Attributes

math_Vector TolX

Standard_Real TolF

math_IntegerVector Indx

math_Vector Scratch

math_Vector Sol

math_Vector DeltaX

math_Vector FValues

math_Matrix Jacobian

## Detailed Description

This class computes the root of a set of N functions of N variables, knowing an initial guess at the solution and using the Newton Raphson algorithm. Knowledge of all the partial derivatives (Jacobian) is required.

## ◆ math_NewtonFunctionSetRoot() [1/2]

 math_NewtonFunctionSetRoot::math_NewtonFunctionSetRoot ( math_FunctionSetWithDerivatives & theFunction, const math_Vector & theXTolerance, const Standard_Real theFTolerance, const Standard_Integer tehNbIterations = `100` )

Initialize correctly all the fields of this class. The range (1, F.NbVariables()) must be especially respected for all vectors and matrix declarations.

## ◆ math_NewtonFunctionSetRoot() [2/2]

 math_NewtonFunctionSetRoot::math_NewtonFunctionSetRoot ( math_FunctionSetWithDerivatives & theFunction, const Standard_Real theFTolerance, const Standard_Integer theNbIterations = `100` )

This constructor should be used in a sub-class to initialize correctly all the fields of this class. The range (1, F.NbVariables()) must be especially respected for all vectors and matrix declarations. The method SetTolerance must be called before performing the algorithm.

## ◆ ~math_NewtonFunctionSetRoot()

 virtual math_NewtonFunctionSetRoot::~math_NewtonFunctionSetRoot ( )
virtual

Destructor.

## ◆ Derivative() [1/2]

 const math_Matrix& math_NewtonFunctionSetRoot::Derivative ( ) const

Returns the matrix value of the derivative at the root. Exception NotDone is raised if the root was not found.

## ◆ Derivative() [2/2]

 void math_NewtonFunctionSetRoot::Derivative ( math_Matrix & Der ) const

Outputs the matrix value of the derivative at the root in Der. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Der is not equal to the range of the StartingPoint.

## ◆ Dump()

 void math_NewtonFunctionSetRoot::Dump ( Standard_OStream & o ) const

Prints information on the current state of the object. Is used to redefine the operator <<.

## ◆ FunctionSetErrors() [1/2]

 const math_Vector& math_NewtonFunctionSetRoot::FunctionSetErrors ( ) const

Returns the vector value of the error done on the functions at the root. Exception NotDone is raised if the root was not found.

## ◆ FunctionSetErrors() [2/2]

 void math_NewtonFunctionSetRoot::FunctionSetErrors ( math_Vector & Err ) const

Outputs the vector value of the error done on the functions at the root in Err. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Err is not equal to the range of the StartingPoint.

## ◆ IsDone()

 Standard_Boolean math_NewtonFunctionSetRoot::IsDone ( ) const

Returns true if the computations are successful, otherwise returns false.

## ◆ IsSolutionReached()

 virtual Standard_Boolean math_NewtonFunctionSetRoot::IsSolutionReached ( math_FunctionSetWithDerivatives & F )
virtual

This method is called at the end of each iteration to check if the solution is found. Vectors DeltaX, Fvalues and Jacobian Matrix are consistent with the possible solution Vector Sol and can be inspected to decide whether the solution is reached or not.

## ◆ NbIterations()

 Standard_Integer math_NewtonFunctionSetRoot::NbIterations ( ) const

Returns the number of iterations really done during the computation of the Root. Exception NotDone is raised if the root was not found.

## ◆ Perform() [1/2]

 void math_NewtonFunctionSetRoot::Perform ( math_FunctionSetWithDerivatives & theFunction, const math_Vector & theStartingPoint )

The Newton method is done to improve the root of the function from the initial guess point. The solution is found when: abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;.

## ◆ Perform() [2/2]

 void math_NewtonFunctionSetRoot::Perform ( math_FunctionSetWithDerivatives & theFunction, const math_Vector & theStartingPoint, const math_Vector & theInfBound, const math_Vector & theSupBound )

The Newton method is done to improve the root of the function from the initial guess point. Bounds may be given, to constrain the solution. The solution is found when: abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;.

## ◆ Root() [1/2]

 const math_Vector& math_NewtonFunctionSetRoot::Root ( ) const

Returns the value of the root of function F. Exceptions StdFail_NotDone if the algorithm fails (and IsDone returns false).

## ◆ Root() [2/2]

 void math_NewtonFunctionSetRoot::Root ( math_Vector & Root ) const

outputs the root vector in Root. Exception NotDone is raised if the root was not found. Exception DimensionError is raised if the range of Root is not equal to the range of the StartingPoint.

## ◆ SetTolerance()

 void math_NewtonFunctionSetRoot::SetTolerance ( const math_Vector & XTol )

Initializes the tolerance values for the unknowns.

## ◆ StateNumber()

 Standard_Integer math_NewtonFunctionSetRoot::StateNumber ( ) const

Outputs the state number associated with the solution vector root.

## ◆ DeltaX

 math_Vector math_NewtonFunctionSetRoot::DeltaX
protected

## ◆ FValues

 math_Vector math_NewtonFunctionSetRoot::FValues
protected

## ◆ Indx

 math_IntegerVector math_NewtonFunctionSetRoot::Indx
protected

## ◆ Jacobian

 math_Matrix math_NewtonFunctionSetRoot::Jacobian
protected

## ◆ Scratch

 math_Vector math_NewtonFunctionSetRoot::Scratch
protected

## ◆ Sol

 math_Vector math_NewtonFunctionSetRoot::Sol
protected

## ◆ TolF

 Standard_Real math_NewtonFunctionSetRoot::TolF
protected

## ◆ TolX

 math_Vector math_NewtonFunctionSetRoot::TolX
protected

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