determinant routine : out of memory (lines doesn't exit),solve ????

Hallo

see :below info what want to do

example
columns : j->1:n rows : i->1:n
! a11 a12 a13!
a= ! a21 a22 a23! => principle (principles recursion)
! a31 a32 a33!

minor (a11) = !a22 a23!
!a32 a33!

determinant = a11*det(a11)-a12*det(a12)+a13*det(a13)

option nolet
!used windows 10
dim aa(1,1),smaller(1,1)
mat redim aa(4,4)
mat read aa
mat print aa
matrix_length = size(aa,1)
if matrix_length = 1 then
print aa(1,1)
else
call determinant(aa(,),smaller(,),matrix_length,sum)
end if
print "determinant = ";sum

data 1,5,6,2.2
data 3.3,9,10,1
data 7,9,3.2,5.1
data 5,8,6.3,2
end

sub determinant(aa(,),smaller(,),matrix_length,sum)
!*************************************************
! What wrong goes out of memory,lines doesn't exit
!*************************************************
! how can be corrected ?????
!*************************************************
sum=0
for ii = 1 to matrix_length
mat redim smaller(matrix_length-1,matrix_length-1)
for i=2 to matrix_length
for j=1 to matrix_length
if(j < ii) then
smaller(i-1,j)=aa(i,j)
else if (j > ii) then
smaller(i-1,j-1)=aa(i,j)
end if
next j
next i
if mod(ii,2) = 0 then
s=1
else
s=-1
end if
call determinant(aa(,),smaller(,),matrix_length,sum)
sum=sum+s*aa(1,ii)
next ii
end sub

Matlab:

function y=mydet(A)

y=0;

[n,n] = size(A);
for i=1:n
y=y+(-1)^(i+1)*A(1,i)*mydet(A(2:n,[1:(i-1) (i+1):n]));
end

Comments

Determinants

Peter, I don't understand the code lines above the OPTION NO LET statement. It is not written in any TrueBasic that I can understand. Nor can I understand any of the code lines written below MATLAB.

Regards,
BigJohn

halo bigjohn

hallo BigJohn

I want to write program to find determinant through recursion.

best from

peter