import numpy as np
A = np.array([(2, 3), (1, 2)])
y = np.array([(23, 14)])
print(A)
print(y)
A_inv = np.linalg.inv(A)
x1 = np.dot(A_inv, y)
print(x1)
x1 = np.dot(A_inv, y) File "< array_function internals>", line 5, in dot ValueError: shapes (2,2) and (1,2) not aligned: 2 (dim 1) != 1 (dim 0)
you trying to multiply a 2 2 array by a 1 2 array to fix this add this:
y = np.array([(23, 14)]).reshape(2,1)
or just remove interior parenthesis from that:
y = np.array([23, 14])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.