Currently, when user types
sage: x = continued_fraction(pi)
sage: y = 3*x
an TypeError is raised saying
TypeError: unsupported operand parent(s) for '*': 'Integer Ring' and '<class 'sage.rings.continued_fraction.ContinuedFraction_real'>'
I understand that Sage tries to find common parent of Integer element and ContinuedFraction_real
and fails. It seems that continued fractions in Sage are not implemented as elements of any particular field, and are derived directly from SageObject
.
I am implementing an algorithm for arithmetical operations on continued fractions. Is it possible to make Sage call a particular method when the user tries to perform an arithmetical binary operation, where one of the operands is a continued fraction?
I have found those 1, 2, 3 links, but it seems that the topic of coercion is rather extensive and I don't know what to look for, as I don't know what the correct solution to the problem is.
Thank you for any response!