Changeset 7637:1d8a27ff390b


Ignore:
Timestamp:
12/05/07 19:21:32 (6 years ago)
Author:
Mike Hansen <mhansen@…>
Branch:
default
Tags:
2.9.alpha7
Message:

Fixed #1398.

Location:
sage/rings
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sage/rings/arith.py

    r7471 r7637  
    16571657    OUTPUT: 
    16581658        Integer 
     1659 
     1660    EXAMPLES: 
     1661        sage: z = 43434 
     1662        sage: z.prime_to_m_part(20) 
     1663        21717         
    16591664    """ 
    16601665    if n == 0: 
  • sage/rings/integer.pyx

    r7471 r7637  
    118118cdef class Integer(sage.structure.element.EuclideanDomainElement) 
    119119 
     120 
    120121import sage.rings.infinity 
    121122import sage.libs.pari.all 
     
    135136cdef public mpz_t* get_value(Integer self): 
    136137    return &self.value 
     138 
     139arith = None 
     140cdef void late_import(): 
     141    global arith 
     142    if arith is None: 
     143        import sage.rings.arith 
     144        arith = sage.rings.arith 
     145 
    137146 
    138147MAX_UNSIGNED_LONG = 2 * sys.maxint 
     
    11381147         
    11391148 
     1149    def prime_to_m_part(self, m): 
     1150        """ 
     1151        Returns the prime-to-m part of self, i.e., the largest divisor 
     1152        of self that is coprime to m. 
     1153 
     1154        INPUT: 
     1155            m -- Integer 
     1156        OUTPUT: 
     1157            Integer 
     1158 
     1159        EXAMPLES: 
     1160            sage: z = 43434 
     1161            sage: z.prime_to_m_part(20) 
     1162            21717 
     1163        """ 
     1164        late_import() 
     1165        return sage.rings.arith.prime_to_m_part(self, m) 
     1166 
     1167    def prime_divisors(self):     
     1168        """ 
     1169        The prime divisors of self, sorted in increasing order.  If n 
     1170        is negative, we do *not* include -1 among the prime divisors, since -1 is 
     1171        not a prime number. 
     1172 
     1173        EXAMPLES: 
     1174            sage: a = 1; a.prime_divisors() 
     1175            [] 
     1176            sage: a = 100; a.prime_divisors() 
     1177            [2, 5] 
     1178            sage: a = -100; a.prime_divisors() 
     1179            [2, 5] 
     1180            sage: a = 2004; a.prime_divisors() 
     1181            [2, 3, 167] 
     1182        """ 
     1183        late_import() 
     1184        return sage.rings.arith.prime_divisors(self) 
     1185 
     1186    def divisors(self): 
     1187        """ 
     1188        Returns a list of all positive integer divisors  
     1189        of the integer self. 
     1190 
     1191        EXAMPLES: 
     1192            sage: a = -3; a.divisors() 
     1193            [1, 3] 
     1194            sage: a = 6; a.divisors() 
     1195            [1, 2, 3, 6] 
     1196            sage: a = 28; a.divisors() 
     1197            [1, 2, 4, 7, 14, 28] 
     1198            sage: a = 2^5; a.divisors() 
     1199            [1, 2, 4, 8, 16, 32] 
     1200            sage: a = 100; a.divisors() 
     1201            [1, 2, 4, 5, 10, 20, 25, 50, 100] 
     1202            sage: a = 1; a.divisors() 
     1203            [1] 
     1204            sage: a = 0; a.divisors() 
     1205            Traceback (most recent call last): 
     1206            ... 
     1207            ValueError: n must be nonzero 
     1208            sage: a = 2^3 * 3^2 * 17; a.divisors() 
     1209            [1, 2, 3, 4, 6, 8, 9, 12, 17, 18, 24, 34, 36, 51, 68, 72, 102, 136, 153, 204, 306, 408, 612, 1224] 
     1210        """ 
     1211        late_import() 
     1212        return sage.rings.arith.divisors(self) 
     1213       
    11401214    def __pos__(self): 
    11411215        """ 
Note: See TracChangeset for help on using the changeset viewer.