MF_safeSolve MD_safeSolve ME_safeSolve
Functionsolve a linear system MA * X = B; in case the system is singular, get one solution out of the infinite solution space
Syntax C/C++#include <MFstd.h>
int MF_safeSolve( fVector X, fMatrix MA, fVector B, ui len );
C++ MatObj#include <OptiVec.h>
void vector<T>::safeSolve( const matrix<T>& MA, const vector<T>& B );
Pascal/Delphiuses MFstd;
function MF_safeSolve( X:fVector; MA:fMatrix; B:fVector; len:UIntSize ):Integer;
DescriptionMF_safeSolve is similar to MF_solve with the difference that, in case there is no unique solution of the linear system (i.e., LU decomposition fails), singular value decomposition is employed to obtain at least one solution out of the infinite solution space. Recall that the problem with singular linear systems is not that they don't have a solution, but rather that they are under-determined and have infinitely many solutions. In other words, one or more elements of the solution vector can be chosen arbitrarily. This is what MF_safeSolve does, with the additional constraint that the "smallest" solution vector in the least-squares sense is determined.

A return value of 0 indicates success via LUD, 1 signals success via SVD, and -1 is returned in the very rare case that even SVD fails.

See alsoMF_solve,   chapter 10

MatrixLib Table of Contents  OptiVec home