[Numpy-discussion] [IPython-dev] Discussion with Guido van Rossum and (hopefully) core python-dev on scientific Python and Python3

Dag Sverre Seljebotn d.s.seljebotn@astro.uio...
Tue Feb 14 11:16:19 CST 2012

On 02/14/2012 08:59 AM, Chris Barker wrote:
> On Mon, Feb 13, 2012 at 6:19 PM, Mark Wiebe<mwwiebe@gmail.com>  wrote:
>> It might be nice to turn the matrix class into a short class hierarchy,
> am I confused, or did a thread get mixed in? This seems to be a
> numpy/scipy thing, not a Python3 thing. Or is there some support in
> Python itself required for this to be practical?

It was about the need for a dedicated matrix multiplication operator.

The idea is that if you have more decent, first-class matrices, 
inherently different from arrays, that people tend to use for real-world 
production code, then having a matrix-multiplication operator invoking 
np.dot in Python 3 is less of an issue, because then it's obvious that 
if you have a matrix then * can mean linear algebra multiplication 
rather than elementwise multiplication. (The difference from the current 
situation being that people avoid np.matrix because it's so similar to 
np.ndarray that you too easily get confused).

I myself never missed a matrix multiplication operator, precisely 
because my matrices are very often diagonal or triangular or sparse or 
something else, so having syntax candy simply to invoke np.dot wouldn't 
help me.


>> something like this:
>> class MatrixBase
>> class DenseMatrix(MatrixBase)
>> class TriangularMatrix(MatrixBase) # Maybe a few variations of upper/lower
>> triangular and whether the diagonal is stored
>> class SymmetricMatrix(MatrixBase)
> and while we're at it -- first class support for "row vector" and
> "column vector" -- it seems that the use of the MAtrix class has never
> really caught on, and the fact that there is no way to represent these
> two vectors cleanly is perhaps one important missing feature. See the
> numpy list from I think a couple years ago for discussion -- we had
> great idea, no one who knew how cared enough to implement them.
> -Chris

More information about the NumPy-Discussion mailing list