#define Real Double Const CrLf=Chr(10, 13) 'corrected version Sub PrMat(Titel As String, C() As Real, Vk As Integer=5, Nk As Integer=4) Var MatForm="+" &String(Vk, "#"), i=0, j=0, m=LBound(C), n=UBound(C) Print Titel If Nk>0 Then MatForm+="." &String(Nk, "#") MatForm+=" " For i=m To n For j=m To n Print Using MatForm;c(i, j); *IIF(j=n, @"+", @CrLf); Next Print Next End Sub Function dMpy(i As Integer, j As Integer, k As Integer, LftMat() As Real, RgtMat() As Real) As Real 'only used by Determinant().. Dim d As Real For m As Integer=LBound(LftMat) To i d+=LftMat(j, m)*RgtMat(m, k) Next Return d End Function Function Determinant(A() As Real) As Real 'Determinant, computation 'stolen' from magazine mc (doesn't exist anymore) Dim As Integer m=LBound(A), n=UBound(A), i, j, k Dim As Real LftMat(n, n), RgtMat(n, n), d=1.0 rgtmat(m, m)=d lftmat(m, m)=A(m, m) For k=m To n-1 If lftmat(k, k)=0.0 Then Return 0.0 i=k+1 For j=m To k rgtmat(j, i)=(a(j, i)-dMpy(j-1, j, i, lftmat(), rgtmat()))/lftmat(j, j) lftmat(i, j)=a(i, j)-dMpy(j-1, i, j, lftmat(), rgtmat()) lftmat(i, i)=a(i, i)-dMpy(k, i, i, lftmat(), rgtmat()) rgtmat(i, i)=d Next Next For i=m To n d*=lftmat(i, i) Next Erase LftMat, RgtMat Return d 'return the result End Function Dim As Real A(2, 2)={{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} Dim As Real B(2, 2)={{1, 2, 3}, {4, 5, 6}, {7, 8, 8}} PrMat("Matrix A", A()) Print "det(A)=" &Determinant(A()) PrMat("Matrix B", B()) Print "det(B)=" &Determinant(B()) GetKey