help with vectorization
I know this must be trivial but I can't seem to get it right I have N 2x2 arrays which perform a rotation. I also have N xy pairs to transpose. What is the simplest way to perform the transformation without looping? Thanks from someone about to punch their screen.
I should add, I'm starting with N rotation angles. So I should rephrase and say I'm starting with N angles and N xy pairs. Mathew Yeates wrote:
I know this must be trivial but I can't seem to get it right
I have N 2x2 arrays which perform a rotation. I also have N xy pairs to transpose. What is the simplest way to perform the transformation without looping?
Thanks from someone about to punch their screen. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Mon, Apr 27, 2009 at 1:24 PM, Mathew Yeates
I should add, I'm starting with N rotation angles. So I should rephrase and say I'm starting with N angles and N xy pairs.
Mathew Yeates wrote:
I know this must be trivial but I can't seem to get it right
I have N 2x2 arrays which perform a rotation. I also have N xy pairs to transpose. What is the simplest way to perform the transformation without looping?
Well, in two dimensions complex multiplication should do the trick. In [18]: v = array([1]*4, dtype=complex) In [19]: a = arange(4)*pi/2 In [20]: around(exp(1j*a)*v,5) Out[20]: array([ 1.+0.j, 0.+1.j, -1.+0.j, -0.-1.j]) Chuck
participants (2)
-
Charles R Harris
-
Mathew Yeates