473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 16413
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
15
by: christopher diggins | last post by:
Here is some code I wrote for Matrix multiplication for arbitrary dimensionality known at compile-time. I am curious how practical it is. For instance, is it common to know the dimensionality of...
3
by: robix | last post by:
Hi again. I'm now asking your help because of a smal problem i'm getting with my multiplication matrix code. I'll try to give you as many details as possible. My matrix structure: typedef...
14
by: amitnanda | last post by:
Hi Guys, I have a matrix multiplication program in C that multiplies two matrices. When their size is 3*3 or 800*800, the program runs fine. But above that size, I get a "segmentation fault"....
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
0
by: lituncse | last post by:
dear friends, i have come across a problem which is difficult to solve for me.it's about starssen's matrix multiplication.in general matrix multiplication we need 8 multiplications and 4 additions...
3
by: crazygrey | last post by:
Hello, I'm a newbie to C++ so excuse me if my question was trivial but it is important to me. I'm implementing a simple code to find the forward kinematics of a robot: #include "stdafx.h"...
1
by: Sozos | last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help. #define index(i,j,power) (((i)<<(power))+(j)) void...
8
by: joegao1 | last post by:
can some one give me a hint? I want to program the code for matrix multiplication with as less arithmetical / multiplication operations as possible. my task is to calculate the matrix...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.