# Combination of element-wise and matrix multiplication

Jonno jonnojohnson at gmail.com
Tue Jul 1 23:46:35 CEST 2008

```I have two 2x2 arrays a & b.
a=(([c,d],[e,f]))
b=(([g,h],[i,j]))
Each of c,d,e,f,g,h,i,j are all 1xN arrays
I want to matrix multiply a & b to create a 2x2 array x, where the elements
of x are created with element-wise math and result in the following:
x[0,0] = c*g+d*i
x[0,1] = c*h+d*j
x[1,0] = e*g+f*i
x[1,1] = e*h+f*j

What is the simplest way to do this? I ended up doing the matrix
multiplication manually as above but this doesn't scale very nicely if a & b
become larger size.

Cheers,

Jonno.
--
"If a theory can't produce hypotheses, can't be tested, can't be disproven,
and can't make predictions, then it's not a theory and certainly not
science." by spisska on Slashdot, Monday April 21, 2008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080701/8f883063/attachment.html>
```

More information about the Python-list mailing list