[Numpy-discussion] Computing the norm of an array of vectors

Ben Gamari bgamari.foss at gmail.com
Tue Feb 8 12:55:48 EST 2011

On Tue, 8 Feb 2011 10:46:34 -0600, Robert Kern <robert.kern at gmail.com> wrote:
> (v*v).sum(axis=1)[:,np.newaxis]
> You can leave off the newaxis bit if you don't really need a column vector.
Fair enough, I unfortunately neglected to mention that I ultimately want
to normalize these vectors, hence the *ones(3) in my original proposal
(although looking back, the shapes would clearly be incompatible). Is
there an elegant way to achieve this?

Thanks again,

- Ben

More information about the NumPy-Discussion mailing list