Re: [Numpy-discussion] Is there a better way to write a stacked matrix

2017-10-26 Thread Peter Creasey
> > On Thu, Oct 26, 2017 at 12:11 PM, Daniele Nicolodi > > wrote: > > > >> is there a better way to write the dot product between a stack of > >> matrices? In my case I need to compute > >> > >> y = A.T @ inv(B) @ A > >> > >> with A a 3x1 matrix and B a 3x3 matrix, N times, with N in the few > >>

Re: [Numpy-discussion] Is there a better way to write a stacked matrix multiplication

2017-10-26 Thread Stephan Hoyer
I would certainly use einsum. It is almost perfect for these use cases, e.g., np.einsum('ki,kij,kj->k', A, inv(B), A) On Thu, Oct 26, 2017 at 12:38 PM Charles R Harris wrote: > On Thu, Oct 26, 2017 at 12:11 PM, Daniele Nicolodi > wrote: > >> Hello, >> >> is there a better way to write the dot p

Re: [Numpy-discussion] Is there a better way to write a stacked matrix multiplication

2017-10-26 Thread Charles R Harris
On Thu, Oct 26, 2017 at 12:11 PM, Daniele Nicolodi wrote: > Hello, > > is there a better way to write the dot product between a stack of > matrices? In my case I need to compute > > y = A.T @ inv(B) @ A > > with A a 3x1 matrix and B a 3x3 matrix, N times, with N in the few > hundred thousands ra

[Numpy-discussion] Is there a better way to write a stacked matrix multiplication

2017-10-26 Thread Daniele Nicolodi
Hello, is there a better way to write the dot product between a stack of matrices? In my case I need to compute y = A.T @ inv(B) @ A with A a 3x1 matrix and B a 3x3 matrix, N times, with N in the few hundred thousands range. I thus "vectorize" the thing using stack of matrices, so that A is a