Changeset 7254:f69ced541e37


Ignore:
Timestamp:
11/03/07 11:24:07 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Fix trac #790 -- rational reconstruction failing for p-adics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/rings/padics/padic_generic_element.pyx

    r7016 r7254  
    776776    def rational_reconstruction(self): 
    777777        r""" 
    778         Returns a rational approximation to this p-adic number 
    779  
     778        Returns the unique rational approximation to this p-adic 
     779        number with certain properties, or raises a ValueError (see 
     780        OUTPUT below).  Uses the rational reconstruction algorithm 
     781        applied to the unit part of this rational number. 
     782         
    780783        INPUT: 
    781784            self -- a p-adic element 
     785             
    782786        OUTPUT: 
    783             rational -- an approximation to self 
     787             Numerator and denominator n, d of the unique rational            
     788             number r=n/d, if it exists, with                                 
     789                |n| and |d| <= sqrt(N/2), 
     790             where N = p^prec, i.e., where the *unit part* of self 
     791             is ... + O(p^prec).  If no such r exists, a ValueError 
     792             is raised.  
     793              
    784794        EXAMPLES: 
    785795            sage: R = Zp(5,20,'capped-rel') 
     
    789799            ...               continue 
    790800            ...           assert i/j == R(i/j).rational_reconstruction() 
     801 
     802        A ValueError is raised when a rational reconstruction of 
     803        the unit part does not exist: 
     804            sage: R = Zp(5, 5) 
     805            sage: R(1413*5).rational_reconstruction() 
     806            Traceback (most recent call last): 
     807            ... 
     808            ValueError: Rational reconstruction of 1413 (mod 3125) does not exist. 
    791809        """ 
    792810        if self.is_zero(self.precision_absolute()): 
Note: See TracChangeset for help on using the changeset viewer.