[Numpy-discussion] Simplified question on tensordot
Fri Sep 3 06:59:24 CDT 2010
On Fri, Sep 3, 2010 at 7:48 AM, Rick Muller <firstname.lastname@example.org> wrote:
> Sorry for the rapid repost, but I thought of a much easier way to ask the
> question I asked a few minutes ago.
> I have two matrices, A and B, both of which are n x m. n is big (~10,000),
> and m is small (~10).
> I want to take the product AB such that I get a length-n vector, as in:
>>>> AB = zeros(n,'d')
>>>> for i in xrange(n):
>>>> AB[i] = dot(A[i,:],B[i,:])
Isn't this just (A*B).sum(1) ?
> only I don't want the for-loop. The various things I've tried with dot and
> tensordot inevitably give me a n x n matrix, which isn't what I want. Can
> anyone help me find an easier way to do this?
> Rick Muller
> NumPy-Discussion mailing list
More information about the NumPy-Discussion