简体   繁体   中英

reorder list of vectors by norm

I have array A containing a list of nvec 3D-vectors, A.shape==(nvec,3) . I want to reorder rows of A according to the vectors' norms:

norm=numpy.square(A).sum(axis=1)
rank=numpy.argsort(norm)

I tried A[rank,:] but it gives me an error.

只需删除第二个下标:

A[rank]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM