Statistiques
| Révision :

root / pobysoPythonSage / src / sageSLZ / runHtrn-01.sage @ 230

Historique | Voir | Annoter | Télécharger (3,09 ko)

1
#! /opt/sage/sage
2
#from scipy.constants.codata import precision
3
def initialize_env():
4
    """
5
    Load all necessary modules.
6
    """
7
    if not 'mpfi' in sage.misc.cython.standard_libs:
8
        sage.misc.cython.standard_libs.append('mpfi')
9
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
10
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
11
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
12
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
13
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
14
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
15
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
16
    # Matrix operations are loaded by polynomial operations.
17
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
18
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
19

    
20

    
21
print "Running HTRN..."
22
initialize_env()
23
#
24
f(x)                  = exp(x)
25
precision             = 53
26
htrAccuracyShift      = 50#58
27
precisionRF           = RealField(precision)
28
precPlusOneRF         = RealField(precisionRF.prec()+1)
29
quasiExactRF          = RealField(1024)
30
targetAccuracy        = 2^-(precision + htrAccuracyShift)
31
binade                = 2^-31
32
binadeAbsLowerBound   = precisionRF(binade)
33
binadeUlp             = binadeAbsLowerBound.ulp() 
34

    
35
binadeLowerBound      = binadeAbsLowerBound
36
htrnc                 = precisionRF("1.9E9CBBFD6080B",16)  * 2^-31
37

    
38
print binade.n()
39
print binadeAbsLowerBound.n()
40

    
41
htrncOffset  = htrnc - binadeLowerBound
42
iterStep     = binadeUlp * 2^22
43
iterVar      = binadeLowerBound + floor(htrncOffset/iterStep) * iterStep
44
iterLimit    = iterVar + iterStep
45

    
46
print iterVar.n()
47
print htrnc.n()
48
print iterLimit.n()
49

    
50
iterCount = 0
51
iterationsStartTime = cputime()
52
kiloIterStartTime = cputime()
53
kiloIterCount     = 0
54
kiloIterCountStep = 2^20
55
print "Starting iterations..."
56
while iterVar < iterLimit:
57
    if iterVar == htrnc:
58
        print "Found at iter count:", iterCount
59
        print "After:", cputime(iterationsStartTime)
60
    if slz_is_htrn(argument=iterVar, 
61
                  function=f, 
62
                  targetAccuracy=targetAccuracy, 
63
                  targetRF=precisionRF, 
64
                  targetPlusOnePrecRF=precPlusOneRF, 
65
                  quasiExactRF=quasiExactRF):
66
        print "HTRN candidate:", iterVar.n().str(base=2)
67
        print "HTRN candidate:", iterVar.n().str(base=10)
68
        print "HTRN candidate:", iterVar.n().str(base=16)
69
        print
70
    if kiloIterCount == kiloIterCountStep:
71
        print "1024 iterations computed in:", 
72
        print cputime(kiloIterStartTime), "s"
73
        kiloIterCount = 0
74
        kiloIterStartTime = cputime()
75
        
76
    # End if
77
    iterVar         += binadeUlp
78
    iterCount       += 1
79
    kiloIterCount   += 1
80
iterationsFullTime = cputime(iterationsStartTime)
81
print "Iterations terminates in", iterationsStartTime, "s."
82