[Numpy-discussion] Simple multi-arg wrapper for dot()

Anne Archibald peridot.faceted at gmail.com
Sat Mar 24 05:29:33 EDT 2007


On 24/03/07, Bill Baxter <wbaxter at gmail.com> wrote:

> Nice, but how does that fare on things like mdot(a,(b,c),d) ?  I'm
> pretty sure it doesn't handle it.
> I think an mdot that can only multiply things left to right comes up
> short compared to an infix operator that can easily use parentheses to
> control order.

Well, since exact dotting is associative, the parenthesization doesn't
matter there; if you're worried about roundoff or efficiency, you're
going to have to be more explicit. Unfortunately your approach
requires tuples to be treated differently from arrays. Most functions
in numpy will happily treat a tuple of length n, a list of length n,
and an array of length n the same way. You could do this, and for your
own code maybe it's worth it, but I think it would be confusing in the
library.

Anne



More information about the NumPy-Discussion mailing list