matrix multiplication (newbie question)

Charles R Harris charlesr.harris at gmail.com
Wed Nov 8 08:48:48 CST 2006


On 11/8/06, Keith Goodman <kwgoodman at gmail.com> wrote:
>
> On 11/8/06, izak marais <izakmarais at yahoo.com> wrote:
>
> > Sorry if this is an obvious question, but what is the easiest way to
> > multiply matrices in numpy? Suppose I want to do A=B*C*D. The ' * '
> operator
> > apparently does element wise multiplication, as does the 'multiply'
> ufunc.
> > All I could find was the numeric function 'matrix_multiply, but this
> only
> > takes two arguments.


Same with the operator *, it takes two arguments but is in infix order, i.e.,
left side and right side.

If B and C and D are matrices, then '*' is matrix multiplication.


And if they are arrays:

A = dot(B,dot(C,D))

Python has a dearth of recognized operators which makes this necessary once
'*' is used for elementwise multiplication, it's a long standing complaint.
You can use matrices in numpy, in which case '*' is used for matrix
multiplication like in matlab, but I think it would be better to get used to
using arrays as they are the numpy core.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061108/a9a0fcdf/attachment-0001.html 
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list