Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Andre Alexander Bell
On 09/16/2010 08:24 AM, Andre Alexander Bell wrote: or you could write the loop >>> m1m2 = np.empty_like(m1) >>> for i in range(m1m2.shape[0]): ... m1m2[i] = np.dot(m1, m2) This should have been ... m1m2[i] = np.dot(m1[i], m2[i]) Sorry for the typo. Andre -- http://mail.python.org/mailma

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Andre Alexander Bell
Hi, I assume you have arrays like these: >>> import numpy as np >>> m1 = np.random.rand(size=(4,3,3)) >>> m2 = np.random.rand(size=(4,3,3)) So that m1[0] is a 3x3 Matrix and m1[1] is another one, i.e. you have four matrices. On 09/15/2010 01:54 AM, Gregory Ewing wrote: I had thought that do

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Carl Banks
On Sep 14, 4:54 pm, Gregory Ewing wrote: > Suppose I have two N+2 dimensional arrays, representing > N-d arrays of 2-d matrices. I want to perform matrix > multiplication between corresponding matrices in these > arrays. > > I had thought that dot() might do this, but it appears > not, because e.g

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Robert Kern
On 9/15/10 11:36 AM, Colin J. Williams wrote: On 14-Sep-10 19:54 PM, Gregory Ewing wrote: Suppose I have two N+2 dimensional arrays, representing N-d arrays of 2-d matrices. I want to perform matrix multiplication between corresponding matrices in these arrays. I had thought that dot() might do

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Shashwat Anand
On Tue, Sep 14, 2010 at 7:54 PM, Gregory Ewing wrote: > Suppose I have two N+2 dimensional arrays, representing > N-d arrays of 2-d matrices. I want to perform matrix > multiplication between corresponding matrices in these > arrays. > > I had thought that dot() might do this, but it appears > not

Re: Numpy: Multiplying arrays of matrices

2010-09-15 Thread Colin J. Williams
On 14-Sep-10 19:54 PM, Gregory Ewing wrote: Suppose I have two N+2 dimensional arrays, representing N-d arrays of 2-d matrices. I want to perform matrix multiplication between corresponding matrices in these arrays. I had thought that dot() might do this, but it appears not, because e.g. applyin

Numpy: Multiplying arrays of matrices

2010-09-14 Thread Gregory Ewing
Suppose I have two N+2 dimensional arrays, representing N-d arrays of 2-d matrices. I want to perform matrix multiplication between corresponding matrices in these arrays. I had thought that dot() might do this, but it appears not, because e.g. applying it to two 3-d arrays gives a 4-d array, not