Say I have a numpy array
a = np.array([[1,2,3],[2,3,4]])
I want make this two vectors into unit vectors. The working code is
for i in range(2):
a[i] = a[i]/np.linalg.norm(a[i])
In the end, the result a become:
a =
array([[0, 0, 0],
[0, 0, 0]])
while if I run the calculation and print out the results like
for i in range(2):
print(a[i],i,np.linalg.norm(a[i]))
The code would print out correct results as unit vectors.
Hence my question are : 1. Why the numpy array become zero if I assign it to the unit vector results. 2. what is the correct way to change a list of vectors into unit vectors by numpy array?
Thank you all very much!
aisintdtype. values are truncated.