def __init__(self, R, element_class=fraction_field_element.FractionFieldElement, category=QuotientFields()): """ Create the fraction field of the integral domain R. INPUT: - ``R`` - an integral domain EXAMPLES:: sage: Frac(QQ['x']) Fraction Field of Univariate Polynomial Ring in x over Rational Field sage: Frac(QQ['x,y']).variable_names() ('x', 'y') sage: category(Frac(QQ['x'])) Category of quotient fields """ self._R = R self._element_class = element_class self._element_init_pass_parent = False Parent.__init__(self, base=R, names=R._names, category=category)
def __init__(self): r""" We create the rational numbers `\QQ`, and call a few functions:: sage: Q = RationalField(); Q Rational Field sage: Q.characteristic() 0 sage: Q.is_field() True sage: Q.category() Join of Category of number fields and Category of quotient fields and Category of metric spaces sage: Q.zeta() -1 We next illustrate arithmetic in `\QQ`. :: sage: Q('49/7') 7 sage: type(Q('49/7')) <type 'sage.rings.rational.Rational'> sage: a = Q('19/374'); a 19/374 sage: b = Q('17/371'); b 17/371 sage: a + b 13407/138754 sage: b + a 13407/138754 sage: a * b 19/8162 sage: b * a 19/8162 sage: a - b 691/138754 sage: b - a -691/138754 sage: a / b 7049/6358 sage: b / a 6358/7049 sage: b < a True sage: a < b False Next finally illustrate arithmetic with automatic coercion. The types that coerce into the rational field include ``str, int, long, Integer``. :: sage: a + Q('17/371') 13407/138754 sage: a * 374 19 sage: 374 * a 19 sage: a/19 1/374 sage: a + 1 393/374 TESTS:: sage: TestSuite(QQ).run() sage: QQ.variable_name() 'x' sage: QQ.variable_names() ('x',) sage: QQ._element_constructor_((2, 3)) 2/3 sage: QQ.is_finite() False sage: QQ.is_field() True """ from sage.categories.basic import QuotientFields from sage.categories.number_fields import NumberFields ParentWithGens.__init__( self, self, category=[QuotientFields().Metric(), NumberFields()]) self._assign_names(('x', ), normalize=False) # ????? self._populate_coercion_lists_(init_no_parent=True)