469,329 Members | 1,460 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

using numpy to do linear algebra

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

Feb 3 '07 #1
1 1854
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

Feb 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by nikie | last post: by
13 posts views Thread by Gary Wessle | last post: by
13 posts views Thread by RS | last post: by
18 posts views Thread by robert | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.