[SciPy-dev] Dangerous Matrix +/- Scalar behavior

Norbert Nemec Norbert.Nemec.list at gmx.de
Fri Nov 4 10:00:04 CST 2005


Hi there,

just got bitten by the same bug as often before:

In physics, it is not unusual to abbreviate the notation
    E*eye(n) - H
for a scalar value E and a n*n-matrix H by simply writing
    E - H

With the current definition of the matrix class, however, this will be
interpreted as
elementwise subtraction and lead to a hard-to-find error.

Since elementwise addition/subtraction of a scalar value to a matrix
appears extremely
rarely in linear algebra, wouldn't it be an idea to disallow this
operation on matrices
(which usually indicates an error) and raise an exception instead?

Greetings,
Norbert




More information about the Scipy-dev mailing list