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_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)