[GiNaC-list] (no subject) has to be: avoid expansion in matrix
operations
Richard B. Kreckel
kreckel at ginac.de
Wed Mar 8 23:24:55 CET 2006
Sheplyakov Alexei wrote:
>You can try this silly patch:
>
>Index: ginac/matrix.cpp
>===================================================================
>RCS file: /home/cvs/GiNaC/ginac/matrix.cpp,v
>retrieving revision 1.99.2.5
>diff -u -r1.99.2.5 matrix.cpp
>--- ginac/matrix.cpp 19 Oct 2005 21:21:56 -0000 1.99.2.5
>+++ ginac/matrix.cpp 8 Mar 2006 18:51:06 -0000
>@@ -583,7 +583,7 @@
> if (m[r1*col+c].is_zero())
> continue;
> for (unsigned r2=0; r2<other.cols(); ++r2)
>- prod[r1*other.col+r2] += (m[r1*col+c] * other.m[c*other.col+r2]).expand();
>+ prod[r1*other.col+r2] += (m[r1*col+c] * other.m[c*other.col+r2]);
> }
> }
> return matrix(row, other.col, prod);
>
>
I think the expansion was unintentional and I have applied this patch to
the trunk. Thanks.
In matrix operations, in particularl in the elimination algorithms, one
frequently needs to try a bit harder than if (foo.is_zero())... to test
for zeros. One also needs to take some care to avoid excessively long
terms to build up. For the elements of a matrix product, I see no need
for the former, but I do see need for the latter. For instance,
consider evalm([[(a+b),0],[0,(c+d)]]^666); in ginsh notation.
Cheers
-richy.
--
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
More information about the GiNaC-list
mailing list