Re: [Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Nathaniel Smith
On 27 Feb 2013 12:57, "Jorge Scandaliaris" wrote: > > Hi, > First of all excuse me if this is a trivial question. I have the feeling it is, > but searching and looking through the docs has proven unsuccesful so far. > > I have an ndarray A of shape (M,2,2) representing M 2 x 2 matrices. Now I want

Re: [Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Jorge Scandaliaris
Jaime Fernández del Río gmail.com> writes: > np.einsum makes a lot of these easier to figure out: > In [7]: np.einsum('ijk, kl', A, T) > Out[7]:  > array([[[ 7, 10], >         [15, 22]], > >        [[23, 34], >         [31, 46]], > >        [[39, 58], >         [47, 70]]]) > Thanks, I will h

Re: [Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Jaime Fernández del Río
On Wed, Feb 27, 2013 at 5:41 AM, Jorge Scandaliaris wrote: > Jorge Scandaliaris yahoo.es> writes: > > I have an ndarray A of shape (M,2,2) representing M 2 x 2 matrices. > > Now I want to apply a transform T of shape (2,2) to each of matrix. > np.einsum makes a lot of these easier to figure out:

Re: [Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Jorge Scandaliaris
Jorge Scandaliaris yahoo.es> writes: <...> > I have an ndarray A of shape (M,2,2) representing M 2 x 2 matrices. > Now I want to apply a transform T of shape (2,2) to each of matrix. > The way I do this now is by iterating over all rows of A > multiplying the matrices using numpy.dot(): > > for

[Numpy-discussion] Apply transform to many small matrices

2013-02-27 Thread Jorge Scandaliaris
Hi, First of all excuse me if this is a trivial question. I have the feeling it is, but searching and looking through the docs has proven unsuccesful so far. I have an ndarray A of shape (M,2,2) representing M 2 x 2 matrices. Now I want to apply a transform T of shape (2,2) to each of matrix. The