Re:Python 3.5 to Ship with Matrix Multiplication Operator
by GFK_of_xmaspast on Tuesday April 08, 2014 @05:15PM
(#7556067)
"""If you want to multiply scalars or otherwise do element-wise operations, you have to prefix the '*' operator with a '.'. """
what???
Re:Python 3.5 to Ship with Matrix Multiplication Operator
by quux on Tuesday April 08, 2014 @05:39PM
(#7556194)
You don't have to use .* and friends when operating in 2 scalers, 2 * 3 works just fine. But if you have 2 matrices A and B, A * B does a matrix multiplication, And A .* B is needed for element wise multiplication.
I'm still new to matlab, but the place where this has bitten me is if I'm trying to write code that works on either a scalar or vector of scAlars, if you aren't specific, the code my run fine against a single scalar, but blow up or do the wrong thing with a vector.
MATLAB went down the matrix rabbit hole so far, they made ordinary scalars second-class types. If you want to multiply scalars or otherwise do element-wise operations, you have to prefix the '*' operator with a '.'. If Python can make their language more linear-algebra friendly while avoiding that sort of silliness, I'm all for it.