TMtx::SVDSolve Method

Overload List

#SignatureDescription
1int SVDSolve(TVec *B, TVec *X, TVec *S, double Threshold = 1E-9);Calculates the minimum norm solution to a real linear least squares problem.
2int SVDSolve(TMtx *B, TMtx *X, TVec *S, double Threshold = 1E-9);Matrix version of SVDSolve. Performs a SVDSolve for each U and V matrices columns in single pass.

Overload 1: int SVDSolve(TVec *B, TVec *X, TVec *S, double Threshold = 1E-9);

Calculates the minimum norm solution to a real linear least squares problem.

#NameTypeDescription
1BTVec *
2XTVec *
3STVec *
4Threshold = 1E-9double
Remarks:

Calculates the minimum norm solution to a real linear least squares problem.

Minimize 2-norm(| b - A*x |).

using the singular value decomposition (SVD) of the calling matrix A. A is an Rows-by-Cols matrix which may be rank-deficient. Several right hand side vectors b and solution vectors x can be handled in a single call. The effective rank of A is determined by treating as zero those singular values which are less than Threshold times the largest singular value and is returned by the function. The S vector holds the singular values on the output.

Examples
#include "MtxVec.h"
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    TVec *X, *B, *D;
    TMtx* V;

    CreateIt(X, B, D);
    CreateIt(V);
    B->SetIt(false, DewArray<double>{0, 2, 3});
    V->SetIt(3, 3, false, DewArray<double>{1, 2, 3, 3, 4, 5, 6, 7, 7});

    V->SVDSolve(B, X, D); // matrix V can be non-quadratic
    FreeIt(X, B, D);
    FreeIt(V);
}
See Also: TMtx::SVD
Declared in Dew::Math::TMtx · Dew.Math/MtxVec.h · Cross-compiler

Overload 2: int SVDSolve(TMtx *B, TMtx *X, TVec *S, double Threshold = 1E-9);

Matrix version of SVDSolve. Performs a SVDSolve for each U and V matrices columns in single pass.

#NameTypeDescription
1BTMtx *
2XTMtx *
3STVec *
4Threshold = 1E-9double
Declared in Dew::Math::TMtx · Dew.Math/MtxVec.h · Cross-compiler