DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


InvertMatrix

Declaration: InvertMatrix (var Data: TDouble2DArray): integer;
The function InvertMatrix inverts the (square) matrix Data. The inverse matrix is stored on top of the original data (thereby destroying the original contents). The matrix inversion is carried out using the LU-decomposition procedure (decomposition into two triangle matrices). It must not be applied to non-quadratic matrices.

The function returns the following error codes:

 0 ... everything is OK
-1 ... Data is not a square matrix
-2 ... not enough memory on heap
-3 ... LU decomposition was not possible (the matrix is singular)
In the case of a non-zero return code the resulting matrix is undefined.

Hint: The lower limit of the necessary free heap memory can be calculated by the equation n*((n+2)*8+2) (bytes), with 'n' being the number of columns of the matrix.