You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I regularly get this "error", e.g. when running "solve([[2,1],[3,1]],[12,13])".
I completely agree that there is a unique solution. But why does it give me an error instead of the solution? Am I misunderstanding what the function should be used for? Should I use a different function, when I just want to get an integer solution for a linear equation?
The text was updated successfully, but these errors were encountered:
def intlinsolve(base,image):
try:
return solve(base,image)[0]
except NotImplementedError:
print('unique solution')
return [round(i) for i in np.dot(np.linalg.inv(np.array(base, dtype=np.float64)),image)]
Whenever the integer solution of base*x=image is unique, I let it be calculated as x=base^(-1)*image and round the coefficients of x to assure that they are ints.
I note though that theoretically there could be situations, where there is only one integer solution but several. In this case, np.linalg.inv() would fail, because base would not be invertible.
I regularly get this "error", e.g. when running "solve([[2,1],[3,1]],[12,13])".
I completely agree that there is a unique solution. But why does it give me an error instead of the solution? Am I misunderstanding what the function should be used for? Should I use a different function, when I just want to get an integer solution for a linear equation?
The text was updated successfully, but these errors were encountered: