[SciPy-User] Matrix multiplication operator PEP

Geordie McBain gdmcbain@freeshell....
Sun Feb 23 16:26:27 CST 2014


2014-02-22 21:03 GMT+11:00 Dinesh Vadhia <dineshbvadhia@hotmail.com>:
> +1
>
> Btw, what do other languages use as their "@" matrix multiplication
> operator.

I skimmed a few examples from http://rosettacode.org/wiki/Matrix_multiplication:

APL: +.×
IDL: #
J: +/ .*
Julia: *
K: _mul
Mathematica: .
MATLAB/Octave: * (with .* for elementwise)
Maxima: . (with * for elementwise)
Pari/GP: *
R: %*%
Ruby: * (but only for a special matrix class)
TI-83 BASIC: *

I'd say APL's use of non-ASCII characters was historically unpopular.
IDL's hash clashes with Python's comment.  J uses an ASCII reworking
of APL, I think, so it's got a much more elaborate idea of combining
multiple infix operators together; powerful but perhaps not really
Pythonic.  The dot of Mathematica and Maxima is nice but clashes with
Python's object attribute/method/module accessor.  Julia, Octave,
Pari/GP, and TI-83 BASIC's star is nice but would be
backward-incompatible with NumPy's elementwise multiplication; Ruby's
star relies on the subclass idea eloquently rebutted by the original
poster.  R's and K's multicharacter things are pretty ugly.

-- 
G. D. McBain

Theory of Lift - Introductory Computational Aerodynamics in MATLAB/Octave
Out now - http://www.wileyeurope.com/remtitle.cgi?111995228X


More information about the SciPy-User mailing list