# HG changeset patch
# User Francis Clarke <F.Clarke@Swansea.ac.uk>
# Date 1282902155 3600
# Node ID d1332380b8b389ff99cbcdf33591c81a764b73e7
# Parent 5b338f2e484f2065d3d30d47bc204d6e9ed13d12
#4376: enhanced pari conversion for power series
diff r 5b338f2e484f r d1332380b8b3 sage/modular/overconvergent/genus0.py
a

b


1637  1637  def _pari_(self): 
1638  1638  r""" 
1639  1639  Return the Pari object corresponding to self, which is just the 
1640   `q`expansion of self as a formal power series. At present conversion of 
1641   power series to Pari is only implemented if the base ring is 
1642   `\QQ`. 
 1640  `q`expansion of self as a formal power series. 
1643  1641  
1644   (At present, in 3.4.1.alpha0, if the base ring isn't QQ then a silly 
1645   error message comes up because of a trivial typo in 
1646   sage/rings/power_series_ring_element.py  isinstance is being given a 
1647   constructor function, not a class, due to code refactoring. The really 
1648   silly thing is that there was no doctest to catch this when IntegerRing 
1649   became a function rather than a class. It's really somewhat astonishing 
1650   nobody has noticed since.) 
1651   
1652  1642  EXAMPLES:: 
1653  1643  
1654  1644  sage: f = OverconvergentModularForms(3, 0, 1/2).1 
1655  1645  sage: pari(f) # indirect doctest 
1656  1646  27*q + 324*q^2 + 2430*q^3 + 13716*q^4 + 64557*q^5 + 265356*q^6 + 983556*q^7 + 3353076*q^8 + 10670373*q^9 + 32031288*q^10 + 91455804*q^11 + 249948828*q^12 + 657261999*q^13 + 1669898592*q^14 + 4113612864*q^15 + 9853898292*q^16 + 23010586596*q^17 + 52494114852*q^18 + 117209543940*q^19 + O(q^20) 
1657   sage: pari(f.base_extend(Qp(3))) # misleading error message! 
1658   Traceback (most recent call last): 
1659   ... 
1660   TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types 
 1647  sage: pari(f.base_extend(Qp(3))) # indirect doctest 
 1648  (3^3 + O(3^23))*q + (3^4 + 3^5 + O(3^24))*q^2 + (3^5 + 3^7 + O(3^25))*q^3 + (3^3 + 3^4 + 2*3^5 + 2*3^8 + O(3^23))*q^4 + (2*3^4 + 3^5 + 3^6 + 2*3^7 + 3^10 + O(3^24))*q^5 + (3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + O(3^26))*q^6 + (2*3^3 + 3^4 + 2*3^6 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + O(3^23))*q^7 + (2*3^4 + 3^5 + 3^8 + 2*3^9 + 2*3^10 + 2*3^13 + O(3^24))*q^8 + (3^7 + 2*3^9 + 2*3^12 + 2*3^14 + O(3^27))*q^9 + (2*3^5 + 3^8 + 3^9 + 2*3^10 + 2*3^13 + 2*3^15 + O(3^25))*q^10 + (3^4 + 2*3^5 + 2*3^6 + 3^8 + 2*3^9 + 3^12 + 3^14 + 2*3^16 + O(3^24))*q^11 + (3^5 + 3^6 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^17 + O(3^25))*q^12 + (2*3^3 + 2*3^4 + 2*3^5 + 3^8 + 2*3^9 + 2*3^11 + 3^13 + 2*3^14 + 2*3^17 + 3^18 + O(3^23))*q^13 + (2*3^4 + 2*3^6 + 2*3^7 + 3^8 + 2*3^9 + 3^10 + 3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^18 + 3^19 + O(3^24))*q^14 + (2*3^6 + 3^7 + 3^9 + 3^10 + 3^11 + 2*3^14 + 3^15 + 2*3^16 + 3^17 + 3^18 + 3^20 + O(3^26))*q^15 + (3^3 + 2*3^4 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + 2*3^14 + 2*3^15 + 3^17 + 3^18 + 2*3^19 + 2*3^20 + O(3^23))*q^16 + (2*3^5 + 2*3^7 + 2*3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^13 + 3^14 + 3^15 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^25))*q^17 + (3^8 + 3^9 + 2*3^10 + 2*3^11 + 3^12 + 3^14 + 3^15 + 3^16 + 3^17 + 2*3^21 + 3^22 + O(3^28))*q^18 + (2*3^3 + 3^5 + 2*3^6 + 2*3^8 + 2*3^9 + 3^11 + 2*3^12 + 3^13 + 3^14 + 2*3^15 + 3^16 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^23))*q^19 + O(q^20) 
1661  1649  """ 
1662  1650  return self.q_expansion()._pari_() 
diff r 5b338f2e484f r d1332380b8b3 sage/rings/power_series_ring_element.pyx
a

b


1720  1720  """ 
1721  1721  Return PARI power series corresponding to this series. 
1722  1722  
1723   This is currently only implemented over QQ and ZZ. 
1724   
 1723  There are currently limits to the possible base rings over which this 
 1724  function works. See the documentation for 
 1725  ``sage.rings.polynomial.polynomial_element.Polynomial._pari_`` 
 1726  
1725  1727  EXAMPLES:: 
1726  1728  
1727  1729  sage: k.<w> = QQ[[]] 
1728  1730  sage: f = 1+17*w+15*w^3+O(w^5) 
1729   sage: pari(f) 
 1731  sage: pari(f) # indirect doctest 
1730  1732  1 + 17*w + 15*w^3 + O(w^5) 
1731   sage: pari(1  19*w + w^5) 
 1733  sage: pari(1  19*w + w^5) # indirect doctest 
1732  1734  Traceback (most recent call last): 
1733  1735  ... 
1734   RuntimeError: series precision must be finite for conversion to pari object. 
 1736  ValueError: series precision must be finite for conversion to pari object. 
 1737  sage: R.<x> = Zmod(6)[[]] 
 1738  sage: pari(1 + x + 8*x^3 + O(x^8)) # indirect doctest 
 1739  Mod(1, 6) + Mod(1, 6)*x + Mod(2, 6)*x^3 + O(x^8) 
1735  1740  """ 
1736   if not isinstance(self.parent().base_ring(), 
1737   (rational_field.RationalField, integer_ring.IntegerRing)): 
1738   raise NotImplementedError 
1739   if self.prec() is infinity: 
1740   raise RuntimeError, "series precision must be finite for conversion to pari object." 
1741   return sage.libs.pari.all.pari(str(self)) 
1742   
1743   
1744   
 1741  n = self.prec() 
 1742  if n is infinity: 
 1743  raise ValueError, "series precision must be finite for conversion to pari object." 
 1744  s = '+'.join([str(self.truncate()._pari_()), 'O(%s^%s)' % (self.variable(), n)]) 
 1745  return sage.libs.pari.all.pari(s) 
1745  1746  
1746  1747  def _solve_linear_de(R, N, L, a, b, f0): 
1747  1748  r""" 