[Numpy-discussion] Simplified question on tensordot

Rick Muller rpmuller at gmail.com
Fri Sep 3 08:28:19 EDT 2010


Josef and Pauli,

Wow, you guys rock! I'm amazed you could pull that out so quickly.

I thank you, and PyQuante thanks you (hopefully this will make for faster
density functional theory grids).

Rick

On Fri, Sep 3, 2010 at 5:59 AM, <josef.pktd at gmail.com> wrote:

> On Fri, Sep 3, 2010 at 7:48 AM, Rick Muller <rpmuller at gmail.com> 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)  ?
>
> Josef
>
> >
> > 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
> > rpmuller at gmail.com
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Rick Muller
rpmuller at gmail.com
505-750-7557
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100903/da025d6e/attachment.html>


More information about the NumPy-Discussion mailing list