2008/5/23 Barton Willis <willisb at unk.edu>:
> Try setting ratmx to true:
>
> (%i27) m :
> matrix([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4],[1,0,2,1,2,1,3,2,2,1,3,2,3,2,4,3],
>
> [1,2,0,1,2,3,1,2,2,3,1,2,3,4,2,3],[2,1,1,0,3,2,2,1,3,2,2,1,4,3,3,2],
>
> [1,2,2,3,0,1,1,2,2,3,3,4,1,2,2,3],[2,1,3,2,1,0,2,1,3,2,4,3,2,1,3,2],
>
> [2,3,1,2,1,2,0,1,3,4,2,3,2,3,1,2],[3,2,2,1,2,1,1,0,4,3,3,2,3,2,2,1],
>
> [1,2,2,3,2,3,3,4,0,1,1,2,1,2,2,3],[2,1,3,2,3,2,4,3,1,0,2,1,2,1,3,2],
>
> [2,3,1,2,3,4,2,3,1,2,0,1,2,3,1,2],[3,2,2,1,4,3,3,2,2,1,1,0,3,2,2,1],
>
> [2,3,3,4,1,2,2,3,1,2,2,3,0,1,1,2],[3,2,4,3,2,1,3,2,2,1,3,2,1,0,2,1],
>
> [3,4,2,3,2,3,1,2,2,3,1,2,1,2,0,1],[4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0])$
> (%i28) ratmx : true$
>
>
> (%i29) charpoly(m,'x);
> Evaluation took 0.0100 seconds (0.0100 elapsed)
> (%o29) x^16-640*x^14-10240*x^13-61440*x^12-131072*x^11
>
> Question: Should charpoly automatically set ratmx to true?
Sometimes with ratmx=true, charpoly is slower:
(%i2) M:genmatrix(g, 6, 6)$
Evaluation took 0.0000 seconds (0.0000 elapsed) using 6.539 KB.
(%i3) charpoly(M, x), ratmx=false$
Evaluation took 0.0000 seconds (0.0000 elapsed) using 49.727 KB.
(%i4) charpoly(M, x), ratmx=true$
Evaluation took 0.8600 seconds (1.2800 elapsed) using 40.262 MB.
With ratmx=false charpoly you can compute characteristic polynomial of
7x7 matrix, ratmx=true takes at least a minute (I interrupted the
computation). I think it is better to leave the decision to the user.
--
Andrej