[Numpy-discussion] Norm of array of vectors
Andrey N. Sobolev
inconnu@list...
Thu Mar 17 23:21:01 CDT 2011
Hi eat and Gary,
Thanks a lot for your suggestions, I've tried them in my code and
achieved similar speedup of ~270% for both of them. So I guess I'll
stick to one of those.
Regards,
Andrey.
> Hi,
>
> On Thu, Mar 17, 2011 at 10:44 AM, Andrey N. Sobolev <inconnu@list.ru>
> wrote:
>
> > Dear all,
> >
> > Sorry if that's a noob question, but anyway. I have several
> > thousands of vectors stacked in 2d array. I'd like to get new array
> > containing Euclidean norms of these vectors and get the vector with
> > minimal norm.
> >
> > Is there more efficient way to do this than
> > argmin(array([sqrt(dot(x,x)) for x in vec_array]))?
> >
> Try
> argmin(sum(vec_array** 2, 0)** 0.5)
>
> Regards,
> eat
>
> >
> > Thanks in advance.
> > Andrey.
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
More information about the NumPy-Discussion
mailing list