using numpy to do linear algebra

  • Thread starter Michael O'Brien
  • Start date
M

Michael O'Brien

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
 
R

Robert Kern

Michael said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top