[Numpy-discussion] tensor contractions

Gideon Simpson simpson@math.toronto....
Fri Jan 16 21:14:16 CST 2009

Suppose I have a 3d array, A, with dimensions 2 x 2 x N, and a 2d  2 x  
N array, u.  I interpret A as N 2x2 matrices and u as N 2d vectors.   
Suppose I want to apply the mth matrix to the mth vector, i.e.

A[, , m] u[, m] = v[, m]

Aside from doing
A[0,0,:] u[0,:]  + A[0,1,:] u[1,:] = v[0,:]
A[1,0,:] u[0,:]  + A[1,1,:] u[1,:] = v[1,:]
is there a smart way to perform this computation?


More information about the Numpy-discussion mailing list