[Numpy-discussion] Simple multi-arg wrapper for dot()
Sun Mar 25 15:28:29 CDT 2007
On 3/25/07, Colin J. Williams <email@example.com> wrote:
> Bill Baxter wrote:
> > On 3/25/07, Robert Kern <firstname.lastname@example.org> wrote:
> >> Bill Baxter wrote:
> >> I don't know. Given our previous history with convenience functions with
> >> different calling semantics (anyone remember rand()?), I think it probably will
> >> confuse some people.
> >> I'd really like to see it on a cookbook page, though. I'd use it.
> > Done.
> > http://www.scipy.org/Cookbook/MultiDot
> > --bb
> I wasn't able to connect to this link
Scipy.org seems to be down now.
> but I gather that the proposal was
> to used dot(A, B, C) to represent the product of the 3 arrays.
More or less, but the idea of modifying dot itself was quickly dropped.
> if A, B and C were matrices then this could more clearly be written as
> A * B * C
Yep, if they were, that would work great.
But If you're not sure if they are matrices or not you need to either
use dot to make sure you get the matrix multiply behavior, or convert
to matrices. Actually I think converting just the first one to a
matrix suffices, so you could write it
mat(A) * B * C
But that won't preserve the array type of the inputs.
More information about the Numpy-discussion