Hi Chris,

On Sat, Mar 15, 2014 at 4:15 AM, Chris Laumann <chris.laum...@gmail.com> wrote:
> Hi all,
>
> Let me preface my two cents by saying that I think the best part of @ being
> accepted is the potential for deprecating the matrix class — the syntactic
> beauty of infix for matrix multiply is a nice side effect IMHO :) This may
> be why my basic attitude is:
>
> I don’t think it matters very much but I would vote (weakly) for weak-right.
> Where there is ambiguity, I suspect most practitioners will just put in
> parentheses anyway — especially with combinations of * and @, where I don’t
> think there is a natural intuitive precedence relationship. At least,
> element-wise multiplication is very rare in math/physics texts as an
> explicitly defined elementary operation so I’d be surprised if anybody had a
> strong intuition about the precedence of the ‘*’ operator. And the binding
> order doesn’t matter if it is scalar multiplication.

"It doesn't matter" and "no-one has strong intuitions" are generally
arguments for same-left, since that allows everyone to reason about @
in the same way they reason about all of Python's operators.

> I have quite a bit of code with large matrices where the order of
> matrix-vector multiplies is an important optimization and I would certainly
> have a few simpler looking expressions for op @ op @ vec, hence the weak
> preference for right-associativity. That said, I routinely come across
> situations where the optimal matrix multiplication order is more complicated
> than can be expressed as left-right or right-left (because some matrices
> might be diagonal, CSR or CSC), which is why the preference is only weak. I
> don’t see a down-side in the use-case that it is actually associative (as in
> matrix-matrix-vector).

Would you mind taking a more systematic look through this code, or
sharing some examples so the rest of us can look? "Certainly have a
few simpler looking expressions" is a good start, but when we're
talking about changing the grammar of one of the most popular
programming languages in the world it seems worth the effort to gather
some more careful data :-).

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to