[Python-ideas] Fwd: [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power
Ronan Lamy
ronan.lamy at gmail.com
Fri Mar 14 19:40:49 CET 2014
I have a few remarks, in random order:
* The PEP is not just about the multiplication of matrices. The
matrix-vector and vector-vector semantics are required in order to get
nice expressions. This should probably be mentioned more prominently.
* The complicated semantics for higher-dimensional arrays are
effectively incompatible with the matrix-vector and vector-vector cases:
for instance, writing the product of a list of matrices by a list of
vectors requires something like "mats @ vecs[..., np.newaxis]". In other
words, A @ B is AFAICT nearly equivalent to numpy.dot(A, B), therefore
people who cannot use numpy.dot() today will not be able to use "@" either.
* A big part of the problem with np.matrix is that it subclasses
np.ndarray but has a completely different __mul__(). IMHO, the problems
with it are a good argument for the importance of the Liskov
substitution principle, but say rather little about the viability of a
correctly implemented matrix type.
More information about the Python-ideas
mailing list