Ejemplo n.º 1
0
 def __init__(self, base_ring, n, names, order):
     from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
     order = TermOrder(order, n)
     MPolynomialRing_generic.__init__(self, base_ring, n, names, order)
     # Construct the generators
     v = [0 for _ in xrange(n)]
     one = base_ring(1)
     self._gens = []
     C = self._poly_class()
     for i in xrange(n):
         v[i] = 1  # int's!
         self._gens.append(C(self, {tuple(v): one}))
         v[i] = 0
     self._gens = tuple(self._gens)
     self._zero_tuple = tuple(v)
     self._has_singular = can_convert_to_singular(self)
     # This polynomial ring should belong to Algebras(base_ring).
     # Algebras(...).parent_class, which was called from MPolynomialRing_generic.__init__,
     # tries to provide a conversion from the base ring, if it does not exist.
     # This is for algebras that only do the generic stuff in their initialisation.
     # But here, we want to use PolynomialBaseringInjection. Hence, we need to
     # wipe the memory and construct the conversion from scratch.
     if n:
         from sage.rings.polynomial.polynomial_element import PolynomialBaseringInjection
         base_inject = PolynomialBaseringInjection(base_ring, self)
         self.register_coercion(base_inject)
Ejemplo n.º 2
0
 def __init__(self, base_ring, n, names, order):
     from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
     order = TermOrder(order,n)
     MPolynomialRing_generic.__init__(self, base_ring, n, names, order)
     # Construct the generators
     v = [0 for _ in xrange(n)]
     one = base_ring(1);
     self._gens = []
     C = self._poly_class()
     for i in xrange(n):
         v[i] = 1  # int's!
         self._gens.append(C(self, {tuple(v):one}))
         v[i] = 0
     self._gens = tuple(self._gens)
     self._zero_tuple = tuple(v)
     self._has_singular = can_convert_to_singular(self)
     # This polynomial ring should belong to Algebras(base_ring).
     # Algebras(...).parent_class, which was called from MPolynomialRing_generic.__init__,
     # tries to provide a conversion from the base ring, if it does not exist.
     # This is for algebras that only do the generic stuff in their initialisation.
     # But here, we want to use PolynomialBaseringInjection. Hence, we need to
     # wipe the memory and construct the conversion from scratch.
     if n:
         from sage.rings.polynomial.polynomial_element import PolynomialBaseringInjection
         base_inject = PolynomialBaseringInjection(base_ring, self)
         self.register_coercion(base_inject)
 def __init__(self, base_ring, n, names, order):
     from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
     order = TermOrder(order, n)
     # MPolynomialRing_base.__init__() normally initialises the base ring,
     # but it also needs the generators to construct a coercion map from the
     # base ring, and the base ring must be set to initialise the generators.
     # We set the base ring manually to break this circular dependency.
     self._base = base_ring
     # Construct the generators
     v = [0] * n
     one = base_ring.one()
     self._gens = []
     for i in range(n):
         v[i] = 1  # int's!
         self._gens.append(self.Element_hidden(self, {tuple(v): one}))
         v[i] = 0
     self._gens = tuple(self._gens)
     self._zero_tuple = tuple(v)
     MPolynomialRing_base.__init__(self, base_ring, n, names, order)
     self._has_singular = can_convert_to_singular(self)