next up previous contents
Next: Efficiency issues Up: Design and implementation issues Previous: Vectors as matrices   Contents

Do we need a scalar class?

Superficially scalars can be treated as $1\times1$ matrices. However, this is not the case as scalar multiplication is a different beast from Matrix multiplication. In this regard a should be treated as aI.

On the other hand, A+a in Matlab behaves like $A+a \mathcal 1 \mathcal 1^T$. We adopt this convention here, provisionally, as this is also the default of NumPy. This need more discussions.

At the moment scalar are represented by native Python numbers. However, we also implemented a Scalar wrapper class so that it can have its own class methods such as __repr__ and be subclassed. Hopefully in the future python can have a native Number class.



Huaiyu Zhu
2002-03-23