Ticket #1863: trac_1863_change_ring.patch

File trac_1863_change_ring.patch, 1.1 KB (added by malb, 12 years ago)
  • sage/rings/polynomial/multi_polynomial.pyx

    # HG changeset patch
    # User Martin Albrecht <malb@informatik.uni-bremen.de>
    # Date 1206705996 0
    # Node ID 052c3316ebee57851b1690718510b6d5bd2a6437
    # Parent  f05f0dbe324fd38b100c6c7ef536e8e85cf15fde
    implement f.change_ring for f \in multivariate polynomial ring (fixes #1863)
    
    diff -r f05f0dbe324f -r 052c3316ebee sage/rings/polynomial/multi_polynomial.pyx
    a b cdef class MPolynomial(CommutativeRingEl 
    535535        """
    536536        q,r = self.quo_rem(other)
    537537        return r
     538
     539    def change_ring(self, R):
     540        """
     541        Return a copy of this polynomial but with coefficients in R,
     542        if at all possible.
     543
     544        INPUT:
     545            R -- a ring
     546
     547        EXAMPLE:
     548            sage: R.<x,y> = QQ[]
     549            sage: f = x^3 + 3/5*y + 1
     550            sage: f.change_ring(GF(7))
     551            x^3 + 2*y + 1
     552        """
     553        P = self._parent
     554        P = P.change_ring(R)
     555        return P(self)
    538556           
    539557cdef remove_from_tuple(e, int ind):
    540558    w = list(e)