Skip to content

Commit 41ad65f

Browse files
authored
Add util.normalize_rows() (#194)
useful function to get unit length rows
1 parent a779b80 commit 41ad65f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sfs/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ def normalize_vector(x):
338338
return x / np.linalg.norm(x)
339339

340340

341+
def normalize_rows(x):
342+
"""Normalize a list of vectors."""
343+
x = asarray_of_rows(x)
344+
return x / np.linalg.norm(x, axis=1, keepdims=True)
345+
346+
341347
def db(x, *, power=False):
342348
"""Convert *x* to decibel.
343349

0 commit comments

Comments
 (0)