On Tue, Feb 8, 2011 at 11:55, Ben Gamari <bgamari.f...@gmail.com> wrote: > On Tue, 8 Feb 2011 10:46:34 -0600, Robert Kern <robert.k...@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?
v / np.hypot.reduce(v, axis=1)[:,np.newaxis] -- 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 _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion