How can a list of vectors be elegantly normalized, in NumPy?
Here is an example that does not work:
from numpy import * vectors = array([arange
Alright: NumPy's array shape broadcast adds dimensions to the left of the array shape, not to its right. NumPy can however be instructed to add a dimension to the right of the norms array:
norms
print vectors.T / norms[:, newaxis]
does work!