472,124 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,124 software developers and data experts.

Matrix Multiplication

Hi,

Is there any direct function for matrix multiplication in Python or
any of its packages? or do we have to multiply element by element?

Thank you,
Amit

Jun 17 '07 #1
6 16317
am***********@gmail.com:
Is there any direct function for matrix multiplication in Python or
any of its packages? or do we have to multiply element by element?
First hit on google for "python matrix":
http://matpy.sourceforge.net/

--
Thomas Wittek
http://gedankenkonstrukt.de/
Jabber: st*********@jabber.i-pobox.net
Jun 17 '07 #2
On Jun 17, 10:52 pm, "amitsoni.1...@gmail.com" <amitsoni.
1...@gmail.comwrote:
Hi,

Is there any direct function for matrix multiplication in Python or
any of its packages? or do we have to multiply element by element?
Use numpy: www.scipy.org

NumPy has a matrix type that overloads the * operator.

Jun 17 '07 #3
sturlamolden wrote:
Use numpy: www.scipy.org

NumPy has a matrix type that overloads the * operator.
Just a tiny followup, which may be important unless you carefully read the
documentation. The "*" operator doesn't do matrix multiplication for normal
numpy arrays - you do need to use its special matrix type to get this. You
can use the dot function to get matrix multiplication with its normal
arrays.

Jeremy

--
Jeremy Sanders
http://www.jeremysanders.net/
Jun 18 '07 #4
am***********@gmail.com wrote:
Hi,

Is there any direct function for matrix multiplication in Python or
any of its packages? or do we have to multiply element by element?
If you want a pure Python module for 4x4 matrices, then you may want to
look at Game Objects

http://code.google.com/p/gameobjects/

Will McGugan
--
http://www.willmcgugan.com
Jun 18 '07 #5
On Jun 18, 11:20 am, Jeremy Sanders <jeremy
+complangpyt...@jeremysanders.netwrote:
NumPy has a matrix type that overloads the * operator.
Just a tiny followup, which may be important unless you carefully read the
documentation. The "*" operator doesn't do matrix multiplication for normal
numpy arrays

That's what I wrote: "NumPy has a matrix type." It is called called
numpy.matrix.

I did not suggest using the array type numpy.array.

Reading carefully is indeed important...



Jun 18 '07 #6
sturlamolden wrote:
That's what I wrote: "NumPy has a matrix type." It is called called
numpy.matrix.

I did not suggest using the array type numpy.array.

Reading carefully is indeed important...
I know what you wrote and you are strictly correct. I was just clarifying it
for a reader who may not have instantly realised that there were multiple
array types in numpy (I didn't for a while), and could have wasted many
hours and been discouraged.

Explaining clearly is indeed important.

--
Jeremy Sanders
http://www.jeremysanders.net/
Jun 19 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by christopher diggins | last post: by
3 posts views Thread by robix | last post: by
14 posts views Thread by amitnanda | last post: by
20 posts views Thread by Frank-O | last post: by
3 posts views Thread by crazygrey | last post: by
1 post views Thread by Sozos | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.