def __init__(self, prec=53): self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__(self, self._real_field(), ('I', ), False, category=Fields())
def __init__(self, coordinate_patch = None): """ Construct the algebra of differential forms on a given coordinate patch. See ``DifferentialForms`` for details. INPUT:: - ``coordinate_patch`` -- Coordinate patch where the algebra lives. If no coordinate patch is given, a default coordinate patch with coordinates (x, y, z) is used. EXAMPLES:: sage: p, q = var('p, q') sage: U = CoordinatePatch((p, q)); U Open subset of R^2 with coordinates p, q sage: F = DifferentialForms(U); F Algebra of differential forms in the variables p, q """ from sage.categories.graded_algebras_with_basis \ import GradedAlgebrasWithBasis from sage.structure.parent_gens import ParentWithGens if not coordinate_patch: x, y, z = var('x, y, z') coordinate_patch = CoordinatePatch((x, y, z)) if not isinstance(coordinate_patch, CoordinatePatch): raise TypeError("%s not a valid Coordinate Patch" % coordinate_patch) self._patch = coordinate_patch ParentWithGens.__init__(self, SR, \ category = GradedAlgebrasWithBasis(SR))
def __init__(self, prec=53): """ Initialize ``self``. TESTS:: sage: C = ComplexField(200) sage: C.category() Join of Category of fields and Category of infinite sets and Category of complete metric spaces sage: TestSuite(C).run() sage: CC.is_field() True sage: CC.is_finite() False """ self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__( self, self._real_field(), ('I', ), False, category=Fields().Infinite().Metric().Complete()) # self._populate_coercion_lists_() self._populate_coercion_lists_( coerce_list=[RRtoCC(self._real_field(), self)])
def __init__(self, group, base_ring = IntegerRing()): r""" Create the given group algebra. INPUT: -- (Group) group: a generic group. -- (Ring) base_ring: a commutative ring. OUTPUT: -- a GroupAlgebra instance. EXAMPLES:: sage: from sage.algebras.group_algebra import GroupAlgebra doctest:1: DeprecationWarning:... sage: GroupAlgebra(GL(3, GF(7))) Group algebra of group "General Linear Group of degree 3 over Finite Field of size 7" over base ring Integer Ring sage: GroupAlgebra(1) Traceback (most recent call last): ... TypeError: "1" is not a group sage: GroupAlgebra(SU(2, GF(4, 'a')), IntegerModRing(12)).category() Category of group algebras over Ring of integers modulo 12 """ if not base_ring.is_commutative(): raise NotImplementedError("Base ring must be commutative") if not is_Group(group): raise TypeError('"%s" is not a group' % group) ParentWithGens.__init__(self, base_ring, category = GroupAlgebras(base_ring)) self._formal_sum_module = FormalSums(base_ring) self._group = group
def __init__(self): """ TEST:: sage: sage.rings.infinity.InfinityRing_class() is sage.rings.infinity.InfinityRing_class() is InfinityRing True """ ParentWithGens.__init__(self, self, names=('oo', ), normalize=False)
def __init__(self): """ TEST:: sage: sage.rings.infinity.InfinityRing_class() is sage.rings.infinity.InfinityRing_class() is InfinityRing True """ ParentWithGens.__init__(self, self, names=('oo',), normalize=False)
def __init__(self): """ TESTS:: sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() is UnsignedInfinityRing True """ ParentWithGens.__init__(self, self, names=("oo",), normalize=False)
def __init__(self): """ Initialize ``self``. TESTS:: sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() is UnsignedInfinityRing True """ ParentWithGens.__init__(self, self, names=('oo', ), normalize=False)
def __init__(self, prec=53): """ Initialize ``self``. EXAMPLES:: sage: ComplexIntervalField() Complex Interval Field with 53 bits of precision sage: ComplexIntervalField(200) Complex Interval Field with 200 bits of precision """ self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__(self, self._real_field(), ('I',), False, category = Fields())
def __init__(self, polynomial, names, category=CAT): """ Create a function field defined as an extension of another function field by adjoining a root of a univariate polynomial. INPUT: - ``polynomial`` -- a univariate polynomial over a function field - ``names`` -- variable names (as a tuple of length 1 or string) - ``category`` -- a category (defaults to category of function fields) EXAMPLES:: We create an extension of function fields:: sage: K.<x> = FunctionField(QQ); R.<y> = K[] sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L Function field in y defined by y^5 + x*y - x^3 - 3*x Note the type:: sage: type(L) <class 'sage.rings.function_field.function_field.FunctionField_polymod_with_category'> We can set the variable name, which doesn't have to be y:: sage: L.<w> = K.extension(y^5 - x^3 - 3*x + x*y); L Function field in w defined by y^5 + x*y - x^3 - 3*x """ from sage.rings.polynomial.all import is_Polynomial if names is None: names = (polynomial.variable_name(), ) if not is_Polynomial(polynomial): raise TypeError, "polynomial must be a polynomial" if polynomial.degree() <= 0: raise ValueError, "polynomial must have positive degree" base_field = polynomial.base_ring() if not isinstance(base_field, FunctionField): raise TypeError, "polynomial must be over a function" self._base_field = base_field self._polynomial = polynomial ParentWithGens.__init__(self, base_field, names=names, category=category) self._hash = hash(polynomial) self._ring = self._polynomial.parent() self._populate_coercion_lists_(coerce_list=[base_field, self._ring]) self._gen = self(self._ring.gen())
def __init__(self, prec=53): """ TESTS:: sage: C = ComplexField(200) sage: C.category() Category of fields sage: TestSuite(C).run() """ self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__(self, self._real_field(), ('I',), False, category = Fields()) # self._populate_coercion_lists_() self._populate_coercion_lists_(coerce_list=[complex_number.RRtoCC(self._real_field(), self)])
def __init__(self, polynomial, names, category=CAT): """ Create a function field defined as an extension of another function field by adjoining a root of a univariate polynomial. INPUT: - ``polynomial`` -- a univariate polynomial over a function field - ``names`` -- variable names (as a tuple of length 1 or string) - ``category`` -- a category (defaults to category of function fields) EXAMPLES:: We create an extension of function fields:: sage: K.<x> = FunctionField(QQ); R.<y> = K[] sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L Function field in y defined by y^5 + x*y - x^3 - 3*x Note the type:: sage: type(L) <class 'sage.rings.function_field.function_field.FunctionField_polymod_with_category'> We can set the variable name, which doesn't have to be y:: sage: L.<w> = K.extension(y^5 - x^3 - 3*x + x*y); L Function field in w defined by y^5 + x*y - x^3 - 3*x """ from sage.rings.polynomial.all import is_Polynomial if names is None: names = (polynomial.variable_name(), ) if not is_Polynomial(polynomial): raise TypeError, "polynomial must be a polynomial" if polynomial.degree() <= 0: raise ValueError, "polynomial must have positive degree" base_field = polynomial.base_ring() if not isinstance(base_field, FunctionField): raise TypeError, "polynomial must be over a function" self._base_field = base_field self._polynomial = polynomial ParentWithGens.__init__(self, base_field, names=names, category = category) self._hash = hash(polynomial) self._ring = self._polynomial.parent() self._populate_coercion_lists_(coerce_list=[base_field, self._ring]) self._gen = self(self._ring.gen())
def __init__(self): """ Initialize ``self``. TESTS:: sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() is UnsignedInfinityRing True Sage can understand SymPy's complex infinity (:trac:`17493`):: sage: import sympy sage: SR(sympy.zoo) Infinity """ ParentWithGens.__init__(self, self, names=('oo', ), normalize=False)
def __init__(self, prec=53): """ Initialize ``self``. TESTS:: sage: C = ComplexField(200) sage: C.category() Join of Category of fields and Category of complete metric spaces sage: TestSuite(C).run() """ self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__(self, self._real_field(), ('I',), False, category=Fields().Metric().Complete()) # self._populate_coercion_lists_() self._populate_coercion_lists_(coerce_list=[RRtoCC(self._real_field(), self)])
def __init__(self): """ Initialize ``self``. TESTS:: sage: sage.rings.infinity.UnsignedInfinityRing_class() is sage.rings.infinity.UnsignedInfinityRing_class() is UnsignedInfinityRing True Sage can understand SymPy's complex infinity (:trac:`17493`):: sage: import sympy sage: SR(sympy.zoo) Infinity """ ParentWithGens.__init__(self, self, names=('oo',), normalize=False)
def __init__(self, coordinate_patch=None): """ Construct the algebra of differential forms on a given coordinate patch. See ``DifferentialForms`` for details. INPUT: - ``coordinate_patch`` -- Coordinate patch where the algebra lives. If no coordinate patch is given, a default coordinate patch with coordinates (x, y, z) is used. EXAMPLES:: sage: p, q = var('p, q') sage: U = CoordinatePatch((p, q)); U doctest:...: DeprecationWarning: Use Manifold instead. See http://trac.sagemath.org/24444 for details. Open subset of R^2 with coordinates p, q sage: F = DifferentialForms(U); F doctest:...: DeprecationWarning: For the set of differential forms of degree p, use U.diff_form_module(p), where U is the base manifold (type U.diff_form_module? for details). See http://trac.sagemath.org/24444 for details. Algebra of differential forms in the variables p, q """ from sage.categories.graded_algebras_with_basis \ import GradedAlgebrasWithBasis from sage.structure.parent_gens import ParentWithGens from sage.misc.superseded import deprecation deprecation( 24444, 'For the set of differential forms of degree p, ' + 'use U.diff_form_module(p), where U is the base ' + 'manifold (type U.diff_form_module? for details).') if not coordinate_patch: x, y, z = var('x, y, z') coordinate_patch = CoordinatePatch((x, y, z)) if not isinstance(coordinate_patch, CoordinatePatch): raise TypeError("%s not a valid Coordinate Patch" % coordinate_patch) self._patch = coordinate_patch ParentWithGens.__init__(self, SR, \ category = GradedAlgebrasWithBasis(SR))
def __init__(self, coordinate_patch = None): """ Construct the algebra of differential forms on a given coordinate patch. See ``DifferentialForms`` for details. INPUT: - ``coordinate_patch`` -- Coordinate patch where the algebra lives. If no coordinate patch is given, a default coordinate patch with coordinates (x, y, z) is used. EXAMPLES:: sage: p, q = var('p, q') sage: U = CoordinatePatch((p, q)); U doctest:...: DeprecationWarning: Use Manifold instead. See http://trac.sagemath.org/24444 for details. Open subset of R^2 with coordinates p, q sage: F = DifferentialForms(U); F doctest:...: DeprecationWarning: For the set of differential forms of degree p, use U.diff_form_module(p), where U is the base manifold (type U.diff_form_module? for details). See http://trac.sagemath.org/24444 for details. Algebra of differential forms in the variables p, q """ from sage.categories.graded_algebras_with_basis \ import GradedAlgebrasWithBasis from sage.structure.parent_gens import ParentWithGens from sage.misc.superseded import deprecation deprecation(24444, 'For the set of differential forms of degree p, ' + 'use U.diff_form_module(p), where U is the base ' + 'manifold (type U.diff_form_module? for details).') if not coordinate_patch: x, y, z = var('x, y, z') coordinate_patch = CoordinatePatch((x, y, z)) if not isinstance(coordinate_patch, CoordinatePatch): raise TypeError("%s not a valid Coordinate Patch" % coordinate_patch) self._patch = coordinate_patch ParentWithGens.__init__(self, SR, \ category = GradedAlgebrasWithBasis(SR))
def __init__(self, constant_field, names, category=CAT): """ Create a rational function field in one variable. INPUT: - ``constant_field`` -- an arbitrary field - ``names`` -- a string or tuple of length 1 - ``category`` -- default: FunctionFields() EXAMPLES:: sage: K.<t> = FunctionField(CC); K Rational function field in t over Complex Field with 53 bits of precision sage: K.category() Category of function fields sage: FunctionField(QQ[I], 'alpha') Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 Must be over a field:: sage: FunctionField(ZZ, 't') Traceback (most recent call last): ... TypeError: constant_field must be a field """ if names is None: raise ValueError, "variable name must be specified" elif not isinstance(names, tuple): names = (names, ) if not constant_field.is_field(): raise TypeError, "constant_field must be a field" ParentWithGens.__init__(self, self, names=names, category = category) R = constant_field[names[0]] self._hash = hash((constant_field, names)) self._constant_field = constant_field self._ring = R self._field = R.fraction_field() self._populate_coercion_lists_(coerce_list=[self._field]) self._gen = self(R.gen())
def __init__(self, constant_field, names, category=CAT): """ Create a rational function field in one variable. INPUT: - ``constant_field`` -- an arbitrary field - ``names`` -- a string or tuple of length 1 - ``category`` -- default: FunctionFields() EXAMPLES:: sage: K.<t> = FunctionField(CC); K Rational function field in t over Complex Field with 53 bits of precision sage: K.category() Category of function fields sage: FunctionField(QQ[I], 'alpha') Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 Must be over a field:: sage: FunctionField(ZZ, 't') Traceback (most recent call last): ... TypeError: constant_field must be a field """ if names is None: raise ValueError, "variable name must be specified" elif not isinstance(names, tuple): names = (names, ) if not constant_field.is_field(): raise TypeError, "constant_field must be a field" ParentWithGens.__init__(self, self, names=names, category=category) R = constant_field[names[0]] self._hash = hash((constant_field, names)) self._constant_field = constant_field self._ring = R self._field = R.fraction_field() self._populate_coercion_lists_(coerce_list=[self._field]) self._gen = self(R.gen())
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)
def __init__(self, prec=53): self._prec = int(prec) from sage.categories.fields import Fields ParentWithGens.__init__(self, self._real_field(), ('I',), False, category = Fields())
def __init__(self, base_ring, num_gens, name_list, order='negdeglex', default_prec=10, sparse=False): """ Initializes a multivariate power series ring. See PowerSeriesRing for complete documentation. INPUT - ``base_ring`` - a commutative ring - ``num_gens`` - number of generators - ``name_list`` - List of indeterminate names or a single name. If a single name is given, indeterminates will be this name followed by a number from 0 to num_gens - 1. If a list is given, these will be the indeterminate names and the length of the list must be equal to num_gens. - ``order`` - ordering of variables; default is negative degree lexicographic - ``default_prec`` - The default total-degree precision for elements. The default value of default_prec is 10. - ``sparse`` - whether or not power series are sparse EXAMPLES:: sage: R.<t,u,v> = PowerSeriesRing(QQ) sage: g = 1 + v + 3*u*t^2 - 2*v^2*t^2 sage: g = g.add_bigoh(5); g 1 + v + 3*t^2*u - 2*t^2*v^2 + O(t, u, v)^5 sage: g in R True """ order = TermOrder(order,num_gens) self._term_order = order if not base_ring.is_commutative(): raise TypeError("Base ring must be a commutative ring.") n = int(num_gens) if n < 0: raise ValueError("Multivariate Polynomial Rings must have more than 0 variables.") self._ngens = n self._has_singular = False #cannot convert to Singular by default ParentWithGens.__init__(self, base_ring, name_list) Nonexact.__init__(self, default_prec) # underlying polynomial ring in which to represent elements self._poly_ring_ = PolynomialRing(base_ring, self.variable_names(), sparse=sparse, order=order) # because sometimes PowerSeriesRing_generic calls self.__poly_ring self._PowerSeriesRing_generic__poly_ring = self._poly_ring() # background univariate power series ring self._bg_power_series_ring = PowerSeriesRing(self._poly_ring_, 'Tbg', sparse=sparse, default_prec=default_prec) self._bg_indeterminate = self._bg_power_series_ring.gen() ## use the following in PowerSeriesRing_generic.__call__ self._PowerSeriesRing_generic__power_series_class = MPowerSeries self._is_sparse = sparse self._params = (base_ring, num_gens, name_list, order, default_prec, sparse) self._populate_coercion_lists_()
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() Category of quotient fields 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'); b = Q('17/371'); print a, b 19/374 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',) """ from sage.categories.basic import QuotientFields ParentWithGens.__init__(self, self, category = QuotientFields()) self._assign_names(('x',),normalize=False) # ??? self._populate_coercion_lists_(element_constructor=rational.Rational, init_no_parent=True)
def __init__(self, base_ring, num_gens, name_list, order='negdeglex', default_prec=10, sparse=False): """ Initializes a multivariate power series ring. See PowerSeriesRing for complete documentation. INPUT - ``base_ring`` - a commutative ring - ``num_gens`` - number of generators - ``name_list`` - List of indeterminate names or a single name. If a single name is given, indeterminates will be this name followed by a number from 0 to num_gens - 1. If a list is given, these will be the indeterminate names and the length of the list must be equal to num_gens. - ``order`` - ordering of variables; default is negative degree lexicographic - ``default_prec`` - The default total-degree precision for elements. The default value of default_prec is 10. - ``sparse`` - whether or not power series are sparse EXAMPLES:: sage: R.<t,u,v> = PowerSeriesRing(QQ) sage: g = 1 + v + 3*u*t^2 - 2*v^2*t^2 sage: g = g.add_bigoh(5); g 1 + v + 3*t^2*u - 2*t^2*v^2 + O(t, u, v)^5 sage: g in R True """ order = TermOrder(order, num_gens) self._term_order = order if not base_ring.is_commutative(): raise TypeError("Base ring must be a commutative ring.") n = int(num_gens) if n < 0: raise ValueError( "Multivariate Polynomial Rings must have more than 0 variables." ) self._ngens = n self._has_singular = False #cannot convert to Singular by default ParentWithGens.__init__(self, base_ring, name_list) Nonexact.__init__(self, default_prec) # underlying polynomial ring in which to represent elements self._poly_ring_ = PolynomialRing(base_ring, self.variable_names(), sparse=sparse, order=order) # because sometimes PowerSeriesRing_generic calls self.__poly_ring self._PowerSeriesRing_generic__poly_ring = self._poly_ring() # background univariate power series ring self._bg_power_series_ring = PowerSeriesRing(self._poly_ring_, 'Tbg', sparse=sparse, default_prec=default_prec) self._bg_indeterminate = self._bg_power_series_ring.gen() ## use the following in PowerSeriesRing_generic.__call__ self._PowerSeriesRing_generic__power_series_class = MPowerSeries self._is_sparse = sparse self._params = (base_ring, num_gens, name_list, order, default_prec, sparse) self._populate_coercion_lists_()