Re: [Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread SimonPalmer
sorry, 1D array this is perfect, thanks. On Aug 27, 10:18 pm, Gary Ruben <[EMAIL PROTECTED]> wrote: > I don't know what you mean by a 1D vector, but for a 3-vector, you can > do this (also works for N-dimensions) > > In [1]: a=r_[1.,2.,3.] > In [2]: a > Out[2]: array([ 1., 2., 3.]) > In [3]: b=

Re: [Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread Gary Ruben
I don't know what you mean by a 1D vector, but for a 3-vector, you can do this (also works for N-dimensions) In [1]: a=r_[1.,2.,3.] In [2]: a Out[2]: array([ 1., 2., 3.]) In [3]: b=a/norm(a) In [4]: b Out[4]: array([ 0.26726124, 0.53452248, 0.80178373]) Gary R > bit of a newb question, is t

[Numpy-discussion] normalizing a vector so it has magnitude 1

2008-08-27 Thread SimonPalmer
bit of a newb question, is there a method for normalising a 1D vector so it ends up with magnitude 1? I can do it manually but I was hoping there was a neat numpy - or scipy - trick. I've been web surfing but nothing really leaps out ___ Numpy-discussi