A = np.array([[1, -2, 1], [2, 1, -3], [1, -3, 3]])
b = np.array([6, -3, 10])
x = np.linalg.solve(A, b)
print(x)
#[ 1. -2. 1.]
What format is this? This is my first time seeing it. how does it translate to normal numbers?
CodePudding user response:
The number 1.
is a shorter way of writing 1.0
, and indicates that we are not dealing with an integer, but rather a floating point number. Consider following outputs:
>>> import numpy as np
>>> print(np.array([1,-2,1], dtype=float))
[ 1. -2. 1.]
>>> print(np.array([1,-2,1], dtype=int))
[ 1 -2 1]
>>> print(np.array([1,-2,1], dtype=np.float32))
[ 1. -2. 1.]
>>> print(np.array([1,-2,1], dtype=np.float16))
[ 1. -2. 1.]