This is my currently used function for calculating the inverse Matrix. I hope it's complete. For the MatrixDeterminant-Routine see the link I gave in the first post.

[pascal]Function MatrixInverse(Const M: TMatrix): TMatrix;
Var
S: TMatrixSize;
// X, Y: Integer;
// I, J, K: Integer;
// Swapped: Boolean;
// Temp: TMatrix;
Det: Extended;
Begin
//Get the dimensions of the matrix
S := GetMatrixDim(M);

//Check if both Matrizes have at least one col and row
If (S.X <= 0) Or (S.Y <= 0) Then
Raise EMathError.Create(FmtInvalidDim);
If S.X <> S.Y Then
Raise EMathError.Create(FmtInvalidDim);

Det := MatrixDeterminant(M);
If Det = 0 Then
Raise EMathError.Create(FmtMatrixNotInversable);

Result := MatrixRMul(MatrixAdjoint(M), 1 / Det);
End;

Function MatrixAdjoint(Const M: TMatrix): TMatrix;
Var
S: TMatrixSize;
T: TMatrix;

Function MinorAndCofactor(X, Y: Integer): Extended;
Var
I, J: Integer;
A, B: Integer;
C: TMatrix;
Begin
C := SetupMatrix(S.Y - 1, S.X - 1);
B := 0;
For J := 0 To S.Y - 2 Do
Begin
If B = Y Then
Inc(B);

A := 0;
For I := 0 To S.X - 2 Do
Begin
If A = X Then
Inc(A);
C[J, I] := T[B, A];
Inc(A);
End;

Inc(B);
End;

Asm
// Result := MatrixDeterminant(C);
MOV EAX, DWORD PTR [C]
CALL MatrixDeterminant
//Apply the cofactor sign change rule
MOV EAX, DWORD PTR [X]
XOR EAX, DWORD PTR [Y]
AND EAX, $00000001
JZ @@Finish
//Change the sign
FCHS
@@Finish:
FSTP Result
End;
End;

Var
X, Y: Integer;
Begin
S := GetMatrixDim(M);

If (S.X = 0) Or (S.X <> S.Y) Then
Raise EMathError.Create(FmtInvalidDim);

T := MatrixTranspose(M);

Result := SetupMatrix(S);

For Y := 0 To S.Y - 1 Do
For X := 0 To S.X - 1 Do
Result[Y, X] := MinorAndCofactor(X, Y);
End;[/pascal]

Any improvement possible?