Matrix Multiplication

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

  1. 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
     
    amitsoni.1984, Jun 17, 2007
    #1
    1. Advertisements

  2. :
    First hit on google for "python matrix":
    http://matpy.sourceforge.net/
     
    Thomas Wittek, Jun 17, 2007
    #2
    1. Advertisements

  3. amitsoni.1984

    sturlamolden Guest

    Use numpy: www.scipy.org

    NumPy has a matrix type that overloads the * operator.
     
    sturlamolden, Jun 17, 2007
    #3
  4. 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, Jun 18, 2007
    #4
  5. amitsoni.1984

    Will McGugan Guest

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

    sturlamolden Guest


    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. 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, Jun 19, 2007
    #7
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.