Oct-24-2019, 10:24 PM
I'm relatively new in Python, I did a lots of programs in Octave but now try to transfer them in PyThon.
One of my program divide a vector by a matrix, strangely the results is very different from the one I
obtain from Octave. The Octave results looks OK because the output final result is in accordance with the real
result of the publish examples.
The Python program (reduce to the essential)
Thanks for your help
Dennis
One of my program divide a vector by a matrix, strangely the results is very different from the one I
obtain from Octave. The Octave results looks OK because the output final result is in accordance with the real
result of the publish examples.
The Python program (reduce to the essential)
import numpy as np a=np.array([10,10,10]) b=np.array([[1,1,1],[2,2,2],[3,3,3]]) print(a) print(b) c=np.divide(a,b) print("np.divide(a,b) = ") print (c)The Python results:
Output:[10 10 10]
[[1 1 1]
[2 2 2]
[3 3 3]]
np.divide(a,b) = Output:[[10. 10. 10. ]
[ 5. 5. 5. ]
[ 3.33333333 3.33333333 3.33333333]]
The Octave results for the same operation:Output:0.71429 , 1.42847 , 2.14286
I Try different configuration of the vector (horizontal,Vertical)Thanks for your help
Dennis