using numpy to do linear algebra

Discussion in 'Python' started by Michael O'Brien, Feb 3, 2007.

  1. Hola~

    I have a large array of points (over a million). I would like to
    multiply each point in the array by a 4x4 matrix. I keep thinking
    there should be an easy way to do this using numpy, but I can't figure
    out the mojo to do it. Is that possible?

    MO
    Michael O'Brien, Feb 3, 2007
    #1
    1. Advertising

  2. Michael O'Brien

    Robert Kern Guest

    Michael O'Brien wrote:
    > Hola~
    >
    > I have a large array of points (over a million). I would like to
    > multiply each point in the array by a 4x4 matrix. I keep thinking
    > there should be an easy way to do this using numpy, but I can't figure
    > out the mojo to do it. Is that possible?


    numpy questions are best asked (and best answered!) on the numpy list.

    http://www.scipy.org/Mailing_Lists

    Now, you haven't given quite enough information for us to answer your question
    definitively. What's the format of your array of points? Is it (N, 4) or (4, N)?
    Is your (4, 4) matrix set up to left-multiply column-vectors or right-multiply
    row-vectors?

    I'm guessing that you have an (N, 4) array of N row-vectors and your (4, 4)
    matrix is set up to left-multiply column-vectors, as is the usual case. Since
    you have row-vectors and your matrix needs column-vectors, you need to transpose
    the matrix and multiply it on the *right* of your vectors array.

    dot(n_x_four, four_x_four.T)

    If the matrix had already been set up to right-multiply row-vectors, then you
    could skip the transpose.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
    Robert Kern, Feb 3, 2007
    #2
    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. ckumar
    Replies:
    2
    Views:
    451
    ckumar
    Jan 17, 2005
  2. Bernard Xhumga
    Replies:
    0
    Views:
    462
    Bernard Xhumga
    Nov 24, 2003
  3. C. Barnes
    Replies:
    5
    Views:
    534
    Szabolcs Nagy
    Sep 11, 2005
  4. Replies:
    0
    Views:
    295
  5. Terry Reedy
    Replies:
    1
    Views:
    317
Loading...

Share This Page