MF_inv MD_inv ME_inv
MCF_inv MCD_inv MCE_inv
Functionmatrix inversion
Syntax C/C++#include <MFstd.h>
int MF_inv( fMatrix MInv, fMatrix MA, ui len );
int MF_invwEdit( fMatrix MInv, fMatrix MA, ui len, float thresh );
int MCF_invwEdit( cfMatrix MInv, cfMatrix MA, ui len, float thresh );
C++ MatObj#include <OptiVec.h>
void matrix<T>::inv( const matrix<T>& MA );
void matrix<T>::invwEdit( const matrix<T>& MA, T thresh );
Pascal/Delphiuses MFstd;
function MF_inv( MInv, MA:fMatrix; len:UIntSize ):Integer;
function MF_invwEdit( MInv, MA:fMatrix; len:UIntSize; thresh:Single ):Integer;
function MCF_invwEdit( MInv, MA:cfMatrix; len:UIntSize; thresh:Single ):Integer;
DescriptionThe inverse of the matrix MA is stored in MInv. If MA is non-invertible, the function fails with an error message. Internally, inversion is accomplished via LU decomposition.

In order to prevent the function from failing, you can define a minimum pivot for the decomposition. If you wish to do so for all calls to MF_LUdecompose and to the functions based upon it, namely MF_inv and MF_solve, you can do so by calling MF_LUDsetEdit. However, as this method is not thread-safe, you cannot use it in order to set different thresholds for different calls to the functions mentioned. Instead of defining a default editing threshold then, use their "wEdit" variants, i.e. MF_LUdecomposewEdit, MF_invwEdit or MF_solvewEdit. They take the desired threshold as the additional argument thresh. Note that thresh is always real, also in the complex versions.

The return value of MF_inv and MF_invwEdit indicates if the inversion was successful:
 
Return valueMeaning
0Matrix MA is regular; inversion successful
1Matrix MA is singular; result matrix contains no useful information
2Matrix MA is (nearly) singular; could be inverted only by pivot editing; if the result is still useful, depends on the specific application.

To check if MF_inv was successful, in single-thread programs, you may also call MF_LUDresult, whose return value will be FALSE (0), if the MA could be inverted without problems (and without pivot editing), and TRUE (1) for singular MA. In multi-thread programs, on the other hand, it would not be clear wich instance of MF_inv the call to MF_LUDresult would refer to. So, here, inspection of the return value of MF_inv is the only option.

Return valueCode 0, 1, or 2, see above.
See alsochapter 10

MatrixLib Table of Contents  OptiVec home