[GiNaC-list] Bug with matrix subtraction

Martin Sandve Alnæs martinal at simula.no
Thu Mar 22 09:44:03 CET 2007


If I subtract two equal matrices, I get the scalar 0. This messes up
later calculations, since a scalar doesn't have op(i), transpose(),
etc. If I do a+(-b) instead of a-b, I get a zero matrix as wanted.
Note that the code is in Python using the swiginac bindings, which now
calls evalm() automatically between operations.


In [32]: m = matrix(2,2,[x,0,0,0])

In [33]: m-m
Out[33]: 0

In [34]: m+(-m)
Out[34]: [[0,0],[0,0]]


So we have the silly relation that "a-b != a+(-b)", which can only be
called a bug.


-- 
---
Martin Sandve Alnæs
PhD student, Cardiac Computations
Simula Research Laboratory, Norway


More information about the GiNaC-list mailing list