On Wed, Feb 9, 2011 at 9:53 AM, Davide Lasagna <[email protected]>wrote:
> Hi, > > I want to compute the following dot product: > > P = np.array( [[ p11, p12 ], [p21, p22]] ) > C = np.array( [c1, c2] ) > > where c1 and c2 are m*m matrices, so that > > C.shape = (2,m,m) > > I want to compute: > > A = np.array([a1, a2]) > > where a1 and a2 are two matrices m*m, from the dot product of P and C. > > I would expect: > > a1 = p11*c1 + p12*c2 > a2 = p21*c1 + p22*c2 > > The code should be general so that i can multiply any P and C with shapes: > > P.shape = (n, n) > C.shape = (n, m, l) > > and with a result as: > > A.shape = (n, m, l) > > I had a look at np.dot? but i can't sort out how to transpose/reshape the C > array. > > Any help is greatly appreciated. > > Ciao > > tensordot() should do the trick. A = np.tensordot(P, C, axes=1) Ben Root
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
