Somebody can explain me what does this function do?
class fastfrac:
def __init__(self,top,bot=1):
if parent(top) == ZZ or parent(top) == R:
self.top = R(top)
self.bot = R(bot)
elif top.__class__ == fastfrac:
self.top = top.top
self.bot = top.bot * bot
else:
self.top = R(numerator(top))
self.bot = R(denominator(top)) * bot
For example, parent() function I don't know what does it do. I search information but I didn't find nothing.
Thank you so much
In Sage, every mathematical object has a parent structure.
For example, an integer's parent would be the ring of integers, a matrix's parents would be a matrix space, a polynomial's parent would be the corresponding polynomial ring, etc.
To know what the object's parent is, one can use the function
parentor the methodparentof this object.For example, having defined:
and
you could see that they all display as 3 but all have different parents.