Matrix Multiplication

Discussion in 'Python' started by amitsoni.1984@gmail.com, Jun 17, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. Thomas Wittek, Jun 17, 2007
    #2
    1. Advertising

  3. sturlamolden Guest

    On Jun 17, 10:52 pm, "" <amitsoni.
    > 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?


    Use numpy: www.scipy.org

    NumPy has a matrix type that overloads the * operator.
    sturlamolden, Jun 17, 2007
    #3
  4. 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/
    Jeremy Sanders, Jun 18, 2007
    #4
  5. Will McGugan Guest

    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
    Will McGugan, Jun 18, 2007
    #5
  6. sturlamolden Guest

    On Jun 18, 11:20 am, Jeremy Sanders <jeremy
    > wrote:

    > > 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...
    sturlamolden, Jun 18, 2007
    #6
  7. 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/
    Jeremy Sanders, Jun 19, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    2
    Views:
    2,301
    joris
    Mar 24, 2010
  2. Michael Bader
    Replies:
    11
    Views:
    12,031
    Michael Bader
    Mar 3, 2004
  3. robix

    matrix multiplication

    robix, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    497
    Rouben Rostamian
    Nov 13, 2003
  4. Sssasss

    matrix Multiplication

    Sssasss, Oct 18, 2006, in forum: Python
    Replies:
    7
    Views:
    356
    Sssasss
    Oct 18, 2006
  5. William Hughes
    Replies:
    13
    Views:
    1,194
    Ben Bacarisse
    Mar 15, 2010
Loading...

Share This Page