Apply rat() to every single thing



On 5/13/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> As Barton suggested, try
>
>   ratmx : true$
>   nullspace(rat(m))$

Nope, that doesn't help. I waited for ~10 minutes then canceled. Same for
triangularize(rat(m)).

> If your version of triangularize faster than the built-in one, perhaps you
> should contribute it to Maxima so that others can benefit from it....  Is it
> tuned specially for the sparse case?

No, it is not. It's a general Gaussian procedure.

Here is my code ( R is the 243x270 matrix, type trig(); to triangularize it )

/**************************/
nr : length(R);
nc : length(first(R));

swap_rows(n,m) := block(
       tmp : R[n],
       R[n] : R[m],
       R[m] : tmp
   );

trig_step(n,m) := block(
   /* Find nonzero element */
   i:n,
   for j:n thru nr do
       if R[j,m] # 0 then
           return(0)
       else
           i:i+1,
   /* Return if there is no nonzero element */
   if i = nr+1 then
       return(0),
   /* Swap rows */
   swap_rows(n,i),
   /* Modify rows */
   for j:n+1 thru nr do
       if R[j,m] # 0 then
                   R[j] : rat(R[j] - R[n] * ( R[j,m] / R[n,m] )),
   return(1)
   );

trig() := block(
   l:1,
   for k:1 thru min(nc,nr) do block(
       if trig_step(l,k) # 0 then
           l:l+1,
       display(k,l)
       )
   );
/**************************/

If I change
      R[j] : rat(R[j] - R[n] * ( R[j,m] / R[n,m] ))
to
      R[j] : R[j] - R[n] * ( R[j,m] / R[n,m] )
then my procedure is very slow too.

I also uploaded my matrix dumped with write_data(), so you could see
the speedup(load it with read_matrix()). According to timer_info() it
takes 187.17 sec with rat.

http://gusevfe.googlepages.com/matrix(1)