Bugs and strange behaviours of Maxima with ratmx and sparse set to true



I am working with a linear system with a big sparse matrix (K) of 
coefficients, and I need to solve a system like this

Ku = f

with respect to u, so I write

u : K^^-1 . f

I don't use invert(K) because, in general, it is much slower than ^^-1. 
But, because I have to deal with matrices being of high order, also ^^-1 
is very very slow. But fortunately these are sparse matrices, so I 
thought it could be useful to set

ratmx:true;
sparse:true;

to use the special algorithm to compute the determinant, therefore 
performing the inverse with invert() could be faster, because it 
computes the determinants of the minors ok K. But with ratmx and sparse 
set to true, determinant no longer works:


(%i5) determinant(K);

Maxima encountered a Lisp error:

FUNCALL: undefined function TMLATTICE

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.


obviously, using invert, which calls determinant, the error is the same. 
Only matrices of order greater or equal to 3 produce the error on 
invert, and the ones of order greater or equal to 2 produce the error on 
determinant.

This is the bug, now comes a strange behaviour related to ratmx and 
sparse as well.


I said I am trying to compute the inverse of a big sparse matrix, called 
K. With the default values of sparse and ratmx (false), the computation 
of K^^-1 take a very very long time. If one sets:

(%i7) sparse:true;
(%o7) true
(%i8) ratmx:true;
(%o8) true

the computation of K^^-1 is still very long. But if I do:

(%i10) kill(all)
(%o0) done
(%i1) K : matrix(....);
(%o1)....
(%i2) K^^-1;

sparse and ratmx are not affected by kill(all), but now the computation 
of K^^-1 takes only few seconds. Why? Is ^^-1 also somehow affected by 
the values of sparse and ratmx?
Therefore, to speed up the computation, in my program I started the .mac 
file with these lines:

sparse:true;
ratmx:true;
kill(all);

and it works perfectly. There is nothing to kill at the beginning but it 
works... But could someone explain me why I have to do a kill(all) do 
get all tehe things working?
If you want to try, here it is the 42x42 sparse matrix I used:


K : matrix([1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0],
             
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0],
             
[0,0,4*E*I/l,0,0,0,3*sqrt(3)*E*I/l^2,-3*E*I/l^2,2*E*I/l,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,(A*E+bk*l)/l,0,0,0,0,0,0,0,0,0,0,0,-A*E/l,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,(12*E*I+bk*l^3)/l^3,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,
              
-12*E*I/l^3,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0],
             [0,0,0,0,6*E*I/l^2,4*E*I/l,0,0,0,0,0,0,0,0,0,0,-6*E*I/l^2,
              2*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,3*sqrt(3)*E*I/l^2,0,0,0,
              (12*sqrt(3)^2*E*I+l^2*A*E+4*bk*l^3)/(4*l^3),
              
-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,-bk,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0],
             
[0,0,-3*E*I/l^2,0,0,0,-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+4*bk*l^3)/(4*l^3),-3*E*I/l^2,0,-bk,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,2*E*I/l,0,0,0,3*sqrt(3)*E*I/l^2,-3*E*I/l^2,4*E*I/l,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,-bk,0,0,(12*sqrt(3)^2*E*I+l^2*A*E+8*bk*l^3)/(4*l^3),
              
(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,-bk,
              0,0,0,0,0,-(12*sqrt(3)^2*E*I+l^2*A*E)/(4*l^3),
              
-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,-bk,0,(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+8*bk*l^3)/(4*l^3),3*E*I/l^2,0,-bk,0,0,
              0,0,-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
-(12*E*I+sqrt(3)^2*l^2*A*E)/(4*l^3),3*E*I/l^2,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,3*sqrt(3)*E*I/l^2,3*E*I/l^2,4*E*I/l,0,0,0,0,0,
              
0,-3*sqrt(3)*E*I/l^2,-3*E*I/l^2,2*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,-bk,0,0,(A*E+bk*l)/l,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,-A*E/l,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,-bk,0,0,(12*E*I+bk*l^3)/l^3,6*E*I/l^2,0,0,0,
              
0,0,0,0,0,0,0,0,0,0,-12*E*I/l^3,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,0,
              0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,6*E*I/l^2,4*E*I/l,0,0,0,0,0,0,0,0,0,0,
              0,0,0,-6*E*I/l^2,2*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,-A*E/l,0,0,0,0,0,0,0,0,0,0,0,(A*E+bk*l)/l,0,0,-bk,0,0,0,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,-12*E*I/l^3,-6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,
              
(12*E*I+bk*l^3)/l^3,-6*E*I/l^2,0,-bk,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0],
             [0,0,0,0,6*E*I/l^2,2*E*I/l,0,0,0,0,0,0,0,0,0,0,-6*E*I/l^2,
              4*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,-(12*sqrt(3)^2*E*I+l^2*A*E)/(4*l^3),
              
-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),-3*sqrt(3)*E*I/l^2,0,
              0,0,-bk,0,0,(12*sqrt(3)^2*E*I+l^2*A*E+8*bk*l^3)/(4*l^3),
              
(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),-3*sqrt(3)*E*I/l^2,-bk,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              -(12*E*I+sqrt(3)^2*l^2*A*E)/(4*l^3),-3*E*I/l^2,0,0,0,0,-bk,0,
              (12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+8*bk*l^3)/(4*l^3),-3*E*I/l^2,0,-bk,0,
              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,3*sqrt(3)*E*I/l^2,3*E*I/l^2,2*E*I/l,0,0,0,0,0,
              
0,-3*sqrt(3)*E*I/l^2,-3*E*I/l^2,4*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-bk,0,0,
              (12*sqrt(3)^2*E*I+l^2*A*E+8*bk*l^3)/(4*l^3),
              -(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),-3*sqrt(3)*E*I/l^2,
              -bk,0,0,0,0,0,-(12*sqrt(3)^2*E*I+l^2*A*E)/(4*l^3),
              
(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),-3*sqrt(3)*E*I/l^2,0,0,
              0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-bk,0,
              -(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+8*bk*l^3)/(4*l^3),3*E*I/l^2,0,-bk,0,0,
              0,0,(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              -(12*E*I+sqrt(3)^2*l^2*A*E)/(4*l^3),3*E*I/l^2,0,0,0,0,0,0,0,0,
              0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-3*sqrt(3)*E*I/l^2,
              3*E*I/l^2,4*E*I/l,0,0,0,0,0,0,3*sqrt(3)*E*I/l^2,-3*E*I/l^2,
              2*E*I/l,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-bk,0,0,(A*E+bk*l)/l,
              0,0,0,0,0,0,0,0,0,0,0,-A*E/l,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-bk,0,0,
              (12*E*I+bk*l^3)/l^3,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,-12*E*I/l^3,
              6*E*I/l^2,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6*E*I/l^2,
              4*E*I/l,0,0,0,0,0,0,0,0,0,0,-6*E*I/l^2,2*E*I/l,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,-A*E/l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              (A*E+bk*l)/l,0,0,-bk,0,0,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,-12*E*I/l^3,-6*E*I/l^2,0,0,0,0,0,0,0,
              
0,0,0,0,0,0,(12*E*I+bk*l^3)/l^3,-6*E*I/l^2,0,-bk,0,0,0,0,0,0,0,
              0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,6*E*I/l^2,2*E*I/l,0,0,0,0,0,0,0,0,0,0,
              0,0,0,-6*E*I/l^2,4*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              -(12*sqrt(3)^2*E*I+l^2*A*E)/(4*l^3),
              
(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,0,0,
              0,-bk,0,0,(12*sqrt(3)^2*E*I+l^2*A*E+8*bk*l^3)/(4*l^3),
              
-(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,-bk,
              0,0,0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              (12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              -(12*E*I+sqrt(3)^2*l^2*A*E)/(4*l^3),-3*E*I/l^2,0,0,0,0,-bk,0,
              -(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+8*bk*l^3)/(4*l^3),-3*E*I/l^2,0,-bk,0,
              0,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-3*sqrt(3)*E*I/l^2,
              3*E*I/l^2,2*E*I/l,0,0,0,0,0,0,3*sqrt(3)*E*I/l^2,-3*E*I/l^2,
              4*E*I/l,0,0,0,0,0,0,0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-bk,
              0,0,(12*sqrt(3)^2*E*I+l^2*A*E+4*bk*l^3)/(4*l^3),
              
(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),3*sqrt(3)*E*I/l^2,0,0,
              0,0,0,3*sqrt(3)*E*I/l^2],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              -bk,0,(12*sqrt(3)*E*I-sqrt(3)*l^2*A*E)/(4*l^3),
              
(12*E*I+sqrt(3)^2*l^2*A*E+4*bk*l^3)/(4*l^3),3*E*I/l^2,0,0,0,0,0,
              3*E*I/l^2],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,3*sqrt(3)*E*I/l^2,3*E*I/l^2,4*E*I/l,0,0,0,0,0,2*E*I/l],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-A*E/l,0,0,0,0,
              0,0,0,0,0,0,0,(A*E+bk*l)/l,0,0,0,0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-12*E*I/l^3,
              
-6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,(12*E*I+bk*l^3)/l^3,-6*E*I/l^2,0,
              0,0],
             [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6*E*I/l^2,
              2*E*I/l,0,0,0,0,0,0,0,0,0,0,-6*E*I/l^2,4*E*I/l,0,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,1,0,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,0,0,0,0,0,0,0,1,0],
             
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
              0,3*sqrt(3)*E*I/l^2,3*E*I/l^2,2*E*I/l,0,0,0,0,0,4*E*I/l]);


Stefano