Test_Factors Namespace Reference


Functions

def Test
def Mersenne_Test
def Lucas_Lehmer_Test
def Mixed_Test
def power2mod
def isMersennePrime
def isMersennePrimeXXX
def test_2_25
def profile

Variables

tuple beg = time.time( )
 use_batch = True
tuple p = pstats.Stats('profile.out')
tuple tokens = re.split( ",", arg )
tuple min = int( tokens[ 1 ] )
tuple max = int( tokens[ 2 ] )
tuple fin = time.time( )

Function Documentation

def Test_Factors::isMersennePrime (   q  ) 

Definition at line 139 of file Test_Factors.py.

00139                         :
00140     pydb.debugger( )
00141     f = Factors.Factors( q )
00142     return f.isLucasLehmerPrime( q )
00143 
def isMersennePrimeXXX( p ):

def Test_Factors::isMersennePrimeXXX (   p  ) 

Definition at line 144 of file Test_Factors.py.

00144                            :
00145     f = Factors.Factors( gmpy.mpz( 2 ) ** gmpy.mpz( p ) - gmpy.mpz( 1 ) )
00146 
00147     beg = time.time( )
00148     if f.isPrime( ):
00149         result = f.magnitude( )
00150         msg = result
00151     else:
00152         msg = "xxx"
00153         result = 0
00154     fin = time.time( )
00155 
00156     if verbose:
00157         tim = TimeStamp.TimeStamp( "p" )
00158         print "  m: %s %8.2f %3d %s" % ( tim, fin - beg, q, msg )
00159 
00160     return result
00161 
def test_2_25( ):

def Test_Factors::Lucas_Lehmer_Test (   min,
  max 
)

Definition at line 105 of file Test_Factors.py.

00105                                  :
00106 
00107     if verbose > 0:
00108         print "Factors.Lucas_Lehmer_Test:"
00109 
00110     f = Factors.Factors( )
00111     for q in range( min, max, 2 ):
00112         if f.isLucasLehmerPrime( q ):
00113             print q,
00114             sys.stdout.flush()
00115 
def Mixed_Test( min, max ):

def Test_Factors::Mersenne_Test (   min,
  max 
)

Definition at line 71 of file Test_Factors.py.

00071                              :
00072 
00073     print "Factors.Mersenne_Test:"
00074 
00075     for n in range( min, max, 2 ):
00076         v = isMersennePrime( n )
00077         if v != 0:
00078             print "  %d %d" % ( n, v )
00079 
00080 # Factors.Lucas_Lehmer_Test:
00081 #                 div                  mod wo shift            mod wi shift                sipr01 (shift)          relsondt1
00082 #     3   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00083 #     5   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00084 #     7   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00085 #    13   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00086 #    17   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.02
00087 #    19   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00088 #    31   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00089 #    61   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00090 #    89   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00091 #   107   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00092 #   127   05/20 20:32:07   0.00    05/21 20:29:39   0.00   05/25 06:54:20   0.00    05/25 11:55:24   0.00    05/21 12:30:13   0.00
00093 #   521   05/20 20:32:09   0.02    05/21 20:29:40   0.02   05/25 06:54:20   0.01    05/25 11:55:24   0.00    05/21 12:30:14   0.02
00094 #   607   05/20 20:32:10   0.05    05/21 20:29:40   0.04   05/25 06:54:20   0.02    05/25 11:55:24   0.00    05/21 12:30:14   0.02
00095 #  1279   05/20 20:32:34   0.67    05/21 20:29:52   0.26   05/25 06:54:23   0.06    05/25 11:55:25   0.03    05/21 12:30:21   0.14
00096 #  2203   05/20 20:35:21   2.10    05/21 20:31:11   1.18   05/25 06:54:40   0.20    05/25 11:55:30   0.07    05/21 12:31:04   0.66
00097 #  2281   05/20 20:35:44   2.92    05/21 20:31:25   1.35   05/25 06:54:43   0.22    05/25 11:55:31   0.08    05/21 12:31:12   0.73
00098 #  3217   05/20 20:46:24   8.78    05/21 20:35:51   3.56   05/25 06:55:29   0.57    05/25 11:55:46   0.18    05/21 12:33:28   1.86
00099 #  4253   05/20 21:10:19  10.70    05/21 20:47:51   7.93   05/25 06:57:19   1.03    05/25 11:56:22   0.41    05/21 12:39:33   4.26
00100 #  4423   05/20 21:15:06  15.32    05/21 20:50:31   8.89   05/25 06:57:42   1.24    05/25 11:56:30   0.43    05/21 12:40:58   4.88
00101 #  9689   05/21 03:26:12  81.40    05/21 18:53:58   9.33   05/25 07:44:24   8.35    05/25 12:14:29   3.92    05/21 15:27:25  29.73
00102 #  9941   05/21 04:09:05  87.43    05/21 18:58:49   9.98   05/25 07:48:45   8.93    05/25 12:16:32   4.20    05/21 15:42:50  32.06
00103 #                7:36:58                    55:17                   54:52                    21:08                  3:12:37
00104 
def Lucas_Lehmer_Test( min, max ):

def Test_Factors::Mixed_Test (   min,
  max 
)

Definition at line 116 of file Test_Factors.py.

00116                           :
00117 
00118 #   print "Factors.Mixed_Test:"
00119 
00120     for p in range( min, max ):
00121         f = Factors.Factors( p )
00122         if f.isPrime( ):
00123             if f.isLucasLehmerPrime( p ):
00124                 print "%d " % p,
00125 #           print "Lucas: %s -> %s" % ( p, l )
00126 
00127 #           m = f.isMersennePrime( p )
00128 #           print "Mersenne: %s -> %s" % ( p, m )
00129 
def power2mod( val, mer, exp ):

def Test_Factors::power2mod (   val,
  mer,
  exp 
)

Definition at line 130 of file Test_Factors.py.

00130                               :
00131     rslt = ( val & mer ) + ( val >> exp )
00132     if rslt >= mer:
00133         rslt -= mer
00134     if rslt >= mer:
00135         rslt -= mer
00136         print "power2mod:  %d  %d  %d" % ( val, mer, exp )
00137     return rslt
00138 
def isMersennePrime( q ):

def Test_Factors::profile (  ) 

Definition at line 171 of file Test_Factors.py.

00171               :
00172     # profile_24765392501809
00173     arg = "24765392501809";
00174     globals.quiet = True
00175     f = FromString( arg )
00176     print "%s -> %s" % ( arg, f )
00177 
if __name__ == '__main__':

def Test_Factors::Test (  ) 

Definition at line 16 of file Test_Factors.py.

00016            :
00017     n = Number.Number( 5, 3)
00018 
00019     print "%s" % n
00020     print "%s" % n.magnitude( )
00021     print "p: %s, q: %s, u: %s" % ( n.prime(), n.power(), n.used() )
00022 
00023 #http://primes.utm.edu/mersenne/index.html#known
00024 # ##         p   digits    digits  year  discoverer
00025 #         (exp)   in Mp      in P
00026 #  1         2        1         1  ----  ----
00027 #  2         3        1         2  ----  ----
00028 #  3         5        2         3  ----  ----
00029 #  4         7        3         4  ----  ----
00030 #  5        13        4         8  1456  anonymous
00031 #  6        17        6        10  1588  Cataldi
00032 #  7        19        6        12  1588  Cataldi
00033 #  8        31       10        19  1772  Euler
00034 #  9        61       19        37  1883  Pervushin
00035 # 10        89       27        54  1911  Powers
00036 # 11       107       33        65  1914  Powers
00037 # 12       127       39        77  1876  Lucas
00038 # 13       521      157       314  1952  Robinson
00039 # 14       607      183       366  1952  Robinson
00040 # 15      1279      386       770  1952  Robinson
00041 # 16      2203      664      1327  1952  Robinson
00042 # 17      2281      687      1373  1952  Robinson
00043 # 18      3217      969      1937  1957  Riesel
00044 # 19      4253     1281      2561  1961  Hurwitz
00045 # 20      4423     1332      2663  1961  Hurwitz
00046 # 21      9689     2917      5834  1963  
00047 # 22      9941     2993      5985  1963  Gillies
00048 # 23     11213     3376      6751  1963  Gillies
00049 # 24     19937     6002     12003  1971  Tuckerman
00050 # 25     21701     6533     13066  1978  
00051 # 26     23209     6987     13973  1979  Noll
00052 # 27     44497    13395     26790  1979  Nelson & Slowinski
00053 # 28     86243    25962     51924  1982  Slowinski
00054 # 29    110503    33265     66530  1988  Colquitt & Welsh
00055 # 30    132049    39751     79502  1983  Slowinski
00056 # 31    216091    65050    130100  1985  Slowinski
00057 # 32    756839   227832    455663  1992  Slowinski & Gage et al
00058 # 33    859433   258716    517430  1994  Slowinski & Gage
00059 # 34   1257787   378632    757263  1996  Slowinski & Gage
00060 # 35   1398269   420921    841842  1996  Armengaud, Woltman, et al. GIMPS
00061 # 36   2976221   895932   1791864  1997  Spence, Woltman, et al. (GIMPS)
00062 # 37   3021377   909526   1819050  1998  Clarkson, Woltman, Kurowski, et al. (GIMPS)
00063 # 38   6972593  2098960   4197919  1999  Hajratwala, Woltman, Kurowski, et al. (GIMPS)
00064 # 39  13466917  4053946   8107892  2001  Cameron, Kurowski, et al. (GIMPS)
00065 # ??  20996011  6320430  12640858  2003  Shafer, Woltman, Kurowski, et al. (GIMPS)
00066 # ??  24036583  7235733  14471465  2004  Findley, Woltman, Kurowski, et al. (GIMPS)
00067 # ??  25964951  7816230  15632458  2005  Nowak, Woltman, Kurowski, et al. (GIMPS)
00068 # ??  30402457  9152052  18304103  2005  Cooper, Boone, Woltman, Kurowski, et al. (GIMPS)
00069 # ??  32582657  9808358  19616714  2006  Cooper, Boone, Woltman, Kurowski, et al. (GIMPS, PrimeNet)
00070 
def Mersenne_Test( min, max ):

def Test_Factors::test_2_25 (  ) 

Definition at line 162 of file Test_Factors.py.

00162                 :
00163     for string in ( "2^25", "3^5", "7^2", "13^1", "19^2", "127^1", "683^1", "2731^1", "8191^1" ):
00164         factors = Factors.Factors( string )
00165         print "%s %s %s" % ( string, factors, factors.sgmftr( ) )
00166     print ""
00167     print "*** factors ***"
00168     print globals.FactorCache
00169     print "***************"
00170 
def profile( ):


Variable Documentation

tuple Test_Factors::beg = time.time( )

Definition at line 185 of file Test_Factors.py.

tuple Test_Factors::fin = time.time( )

Definition at line 243 of file Test_Factors.py.

tuple Test_Factors::max = int( tokens[ 2 ] )

Definition at line 235 of file Test_Factors.py.

tuple Test_Factors::min = int( tokens[ 1 ] )

Definition at line 234 of file Test_Factors.py.

tuple Test_Factors::p = pstats.Stats('profile.out')

Definition at line 213 of file Test_Factors.py.

tuple Test_Factors::tokens = re.split( ",", arg )

Definition at line 233 of file Test_Factors.py.

Definition at line 196 of file Test_Factors.py.


Generated on Sun Mar 22 09:59:14 2009 for Multiperfect Number Generator by  doxygen 1.5.8