Slow calculation of a determinant?



1.  try newdet( ); it seems to be much faster, and, I thought
THAT was the program to use minor expansion. It took 6 seconds
on my computer.

2. The determinant() program is supposed to use gaussian elimination, and
in fact if you look at the source file mat.lisp you will see an implementation
of fraction free Gaussian elimination, which appears to be
what Andrej re-implemented.

3. if you set ratmx:true, the time it takes on my machine
it takes 0.20 seconds.

4. if you leave ratmx:false, the time it takes is minutes. I have
no idea what algorithm it is using.



Of course, if you specialize the algorithm
  to numbers, especially floats, it may be much faster.

RJF

Andrej Vodopivec wrote:

> Maxima uses minor expansion to calculate determinants. This is the best
> algorithm for calculating (small) symbolic determinants. But this
> algorithm is not the best choice for large matrices with integer entries.
> I use this code  for larger matrices:
> 
>   http://wxmaxima.sourceforge.net/files/idet.lisp
> 
> HTH,
> Andrej
> 
> 
> 
>>I'm just experimenting with Maxima, and comparing it to two systems I
>>already have: MuPAD and Scilab. Just for fun, I decided to get each system
>>to evaluate the determinant of a 16x16 matrix with entries randomly chosen
>>from the integers 0..9. I timed each one:
>>
>>MuPAD:
>>
>>
>>>>m:=matrix(16,16,(i,j)->random() mod 10)
>>>>time(linalg::det(m))
>>
>>95
>>
>>(Output is in milliseconds).
>>
>>Scilab:
>>
>>-->m=floor(rand(16,16)*10)
>>-->tic,det(m),toc
>>ans
>>6.137E+13
>>ans
>>0.04
>>
>>(Output in seconds.)
>>
>>Maxima:
>>
>>(%i1) showtime:true;
>>(%i2) f[i,j]:=random(10)$
>>(%i3) m:genmatrix(f,16,16);
>>(%i4) determinant(m);
>>Evaluation took 817.71 seconds (866.82 elapsed) using 94.295 MB.
>>(%o4) 470231216693085
>>
>>That's nearly 14 minutes! What's going on here? Surely such a
>>straightforward calculation as this should be nearly instantaneous? And
>>look
>>at the memory usage!
>>
>>-Alasdair
>>
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima@math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima