To prevent floating point issues I'm migrating my code to use Fraction.
I'm getting an issue where numpy doesn't seem to be able to Handle numbers cast as Fractions. Would someone know if there is a way for numpy to do its mathematical operations using a Fraction data type?
pl1.d
and pl2.d
are both instances of the Fraction class.
A = np.array([a_vec, b_vec, aXb_vec])
d = np.array([-pl1.d, -pl2.d, 0.]).reshape(3,1)
if np.linalg.det(A) == 0: return None
p_inter = np.linalg.solve(A, d).T
I've also tried setting the dtype of the np.array to Fraction with no success.
A = np.array([a_vec, b_vec, aXb_vec])
d = np.array([-pl1.d, -pl2.d, Fraction(0,1)], dtype=Fraction).reshape(3,1)
if np.linalg.det(A) == 0: return None
p_inter = np.linalg.solve(A, d).T
The Exception for both code snippets is thrown on p_inter = np.linalg.solve(A, d).T
and has the message No loop matching the specified signature and casting was found for ufunc solve
I've updated my post since I've now converted all variables to instances of the Fraction class and the same exception is now thrown on if np.linalg.det(A) == 0: return None