Ticket #8993: 8993_poly_quotient_in_singular.patch

File 8993_poly_quotient_in_singular.patch, 2.8 KB (added by SimonKing, 9 years ago)

Implement polynomial quotient rings in singular interface

  • sage/rings/polynomial/polynomial_quotient_ring.py

    # HG changeset patch
    # User Simon King <simon.king@nuigalway.ie>
    # Date 1274287397 -3600
    # Node ID 1c1c868eb12e633c745c3f20a40908a9f201238f
    # Parent  b863b0bd2d339b2740caf20783aabf3832531de8
    #8993: Implementing representation of univariate polynomial quotient rings and their elements in Singular
    
    diff -r b863b0bd2d33 -r 1c1c868eb12e sage/rings/polynomial/polynomial_quotient_ring.py
    a b  
    331331        if c: return c
    332332        return cmp(self.modulus(), other.modulus())
    333333       
     334    def _singular_init_(self, S=None):
     335        """
     336        Represent ``self`` in the Singular interface.
     337
     338        TEST::
     339
     340            sage: P.<x> = QQ[]
     341            sage: Q = P.quo([(x^2+1)])
     342            sage: singular(Q)        # indirect doctest
     343            //   characteristic : 0
     344            //   number of vars : 1
     345            //        block   1 : ordering lp
     346            //                  : names    xbar
     347            //        block   2 : ordering C
     348            // quotient ring from ideal
     349            _[1]=xbar^2+1
     350            sage: singular(Q.gen())
     351            xbar
     352
     353        """
     354        if S is None:
     355            from sage.all import singular
     356            S = singular
     357        Rpoly = S(self.polynomial_ring())
     358        Rpoly.set_ring()
     359        modulus = S(self.modulus()) # should live in Rpoly
     360        Rtmp = S(self.polynomial_ring().change_var(self.variable_name()))
     361        Rtmp.set_ring()
     362        self.__singular = S("ideal(fetch(%s,%s))"%(Rpoly.name(),modulus.name()),"qring")
     363        return self.__singular
    334364
    335365
    336366    def _repr_(self):
  • sage/rings/polynomial/polynomial_quotient_ring_element.py

    diff -r b863b0bd2d33 -r 1c1c868eb12e sage/rings/polynomial/polynomial_quotient_ring_element.py
    a b  
    8383import sage.rings.commutative_ring_element as commutative_ring_element
    8484import sage.rings.number_field.number_field as number_field
    8585import sage.rings.number_field.number_field_rel as number_field_rel
     86import sage
    8687
    87 
    88 class PolynomialQuotientRingElement(commutative_ring_element.CommutativeRingElement):
     88class PolynomialQuotientRingElement(sage.rings.polynomial.polynomial_singular_interface.Polynomial_singular_repr,commutative_ring_element.CommutativeRingElement):
    8989    """
    9090    Element of a quotient of a polynomial ring.
     91
     92    EXAMPLES::
     93
     94        sage: P.<x> = QQ[]
     95        sage: Q.<xi> = P.quo([(x^2+1)])
     96        sage: xi^2
     97        -1
     98        sage: singular(xi)
     99        xi
     100        sage: (singular(xi)*singular(xi)).NF('std(0)')
     101        -1
     102
    91103    """
    92104    def __init__(self, parent, polynomial, check=True):
    93105        """