Open CASCADE Technology Reference Manual 8.0.2
Loading...
Searching...
No Matches
MathUtils::LinearResidual Class Reference

Linear system residual functor: f(x) = ||Ax - b||^2. Useful for solving overdetermined linear systems via optimization. More...

#include <MathUtils_FunctorVector.hxx>

Public Member Functions

 LinearResidual (const math_Matrix &theA, const math_Vector &theB)
 Constructor from matrix and right-hand side.
bool Value (const math_Vector &theX, double &theY) const
 Evaluates the residual ||Ax - b||^2.
bool Gradient (const math_Vector &theX, math_Vector &theG) const
 Evaluates the gradient: g = 2 * A^T * (Ax - b).
bool Values (const math_Vector &theX, double &theY, math_Vector &theG) const
 Evaluates both value and gradient.

Detailed Description

Linear system residual functor: f(x) = ||Ax - b||^2. Useful for solving overdetermined linear systems via optimization.

Usage:

math_Matrix A(1, 3, 1, 2); // 3x2 overdetermined system
math_Vector b(1, 3);
// ... fill A and b ...
LinearResidual aRes(A, b);
math_Vector aStart(1, 2);
aStart.Init(0.0);
auto aResult = MathOpt::BFGS(aRes, aStart);
GLboolean GLboolean GLboolean b
Definition OpenGl_glext.h:1455
LinearResidual(const math_Matrix &theA, const math_Vector &theB)
Constructor from matrix and right-hand side.
Definition MathUtils_FunctorVector.hxx:633
This class implements the real matrix abstract data type. Matrixes can have an arbitrary range which ...
Definition math_Matrix.hxx:75
math_VectorBase< double > math_Vector
Definition math_Recipes.hxx:25
VectorResult BFGS(Function &theFunc, const math_Vector &theStartingPoint, const Config &theConfig=Config())
BFGS (Broyden-Fletcher-Goldfarb-Shanno) quasi-Newton method. One of the most effective algorithms for...
Definition MathOpt_BFGS.hxx:58

Constructor & Destructor Documentation

◆ LinearResidual()

MathUtils::LinearResidual::LinearResidual ( const math_Matrix & theA,
const math_Vector & theB )
inline

Constructor from matrix and right-hand side.

Parameters
theAcoefficient matrix (m x n)
theBright-hand side vector (m)

Member Function Documentation

◆ Gradient()

bool MathUtils::LinearResidual::Gradient ( const math_Vector & theX,
math_Vector & theG ) const
inline

Evaluates the gradient: g = 2 * A^T * (Ax - b).

Parameters
[in]theXsolution vector
[out]theGgradient vector
Returns
true (always succeeds)

◆ Value()

bool MathUtils::LinearResidual::Value ( const math_Vector & theX,
double & theY ) const
inline

Evaluates the residual ||Ax - b||^2.

Parameters
[in]theXsolution vector (n)
[out]theYsquared residual norm
Returns
true (always succeeds)

◆ Values()

bool MathUtils::LinearResidual::Values ( const math_Vector & theX,
double & theY,
math_Vector & theG ) const
inline

Evaluates both value and gradient.

Parameters
[in]theXsolution vector
[out]theYsquared residual norm
[out]theGgradient vector
Returns
true (always succeeds)

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