469,329 Members | 1,460 Online

# 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
 7 posts views Thread by 2mc | last post: by 5 posts views Thread by C. Barnes | last post: by reply views Thread by Bernard Xhumga | last post: by 22 posts views Thread by J | last post: by 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 3 posts views Thread by fbitonti | last post: by reply views Thread by ioana budai | last post: by 1 post views Thread by CARIGAR | last post: by reply views Thread by SioSio | last post: by reply views Thread by shivambhatele | last post: by reply views Thread by suresh191 | last post: by reply views Thread by haryvincent176 | last post: by reply views Thread by mgbsher | last post: by reply views Thread by NeoPa | last post: by reply views Thread by dDule | last post: by