root / pobysoPythonSage / src / sageSLZ / runSLZ-53.sage.py @ 280
Historique | Voir | Annoter | Télécharger (5,74 ko)
| 1 | 253 | storres | # This file was *autogenerated* from the file ./runSLZ-53.sage
|
|---|---|---|---|
| 2 | 253 | storres | from sage.all_cmdline import * # import sage library |
| 3 | 253 | storres | _sage_const_3 = Integer(3); _sage_const_2 = Integer(2); _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_6 = Integer(6); _sage_const_5 = Integer(5); _sage_const_4 = Integer(4); _sage_const_1023 = Integer(1023); _sage_const_1022 = Integer(1022); _sage_const_10 = Integer(10); _sage_const_53 = Integer(53)#! /opt/sage/sage |
| 4 | 253 | storres | # @file runSLZ-113.sage
|
| 5 | 253 | storres | #
|
| 6 | 253 | storres | # Run SLZ for p=113
|
| 7 | 253 | storres | #from scipy.constants.codata import precision
|
| 8 | 253 | storres | def initialize_env(): |
| 9 | 253 | storres | """
|
| 10 | 253 | storres | Load all necessary modules.
|
| 11 | 253 | storres | """
|
| 12 | 253 | storres | compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx"
|
| 13 | 253 | storres | if compiledSpyxDir not in sys.path: |
| 14 | 253 | storres | sys.path.append(compiledSpyxDir) |
| 15 | 253 | storres | if not 'mpfi' in sage.misc.cython.standard_libs: |
| 16 | 253 | storres | sage.misc.cython.standard_libs.append('mpfi')
|
| 17 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
|
| 18 | 253 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
|
| 19 | 253 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
|
| 20 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
|
| 21 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
|
| 22 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
|
| 23 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
|
| 24 | 253 | storres | # Matrix operations are loaded by polynomial operations.
|
| 25 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
|
| 26 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
|
| 27 | 253 | storres | |
| 28 | 253 | storres | |
| 29 | 253 | storres | print "Running SLZ..." |
| 30 | 253 | storres | initialize_env() |
| 31 | 253 | storres | from sageMpfr import * |
| 32 | 253 | storres | from sageGMP import * |
| 33 | 253 | storres | import sys |
| 34 | 253 | storres | from subprocess import call |
| 35 | 253 | storres | #
|
| 36 | 253 | storres | ## Main variables and parameters.
|
| 37 | 253 | storres | x = var('x')
|
| 38 | 253 | storres | __tmp__=var("x"); func = symbolic_expression(exp(x)).function(x)
|
| 39 | 253 | storres | precision = _sage_const_53 |
| 40 | 253 | storres | emin = -_sage_const_1022 |
| 41 | 253 | storres | emax = _sage_const_1023 |
| 42 | 253 | storres | RRR = RealField(precision) |
| 43 | 253 | storres | degree = _sage_const_0 |
| 44 | 253 | storres | alpha = _sage_const_0 |
| 45 | 253 | storres | htrn = _sage_const_0 |
| 46 | 253 | storres | intervalCenter = _sage_const_0 |
| 47 | 253 | storres | intervalRadius = _sage_const_0 |
| 48 | 253 | storres | debugMode = False
|
| 49 | 253 | storres | ## Local functions
|
| 50 | 253 | storres | #
|
| 51 | 253 | storres | def usage(): |
| 52 | 253 | storres | write = sys.stderr.write |
| 53 | 253 | storres | write("\nUsage:\n")
|
| 54 | 253 | storres | write(" " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n") |
| 55 | 253 | storres | write(" <numberOfNumbers> [debug]\n")
|
| 56 | 253 | storres | write("\nArguments:\n")
|
| 57 | 253 | storres | write(" degree the degree of the polynomial (integer)\n")
|
| 58 | 253 | storres | write(" alpha alpha (integer)\n")
|
| 59 | 253 | storres | write(" htrn hardness-to-round - a number of bits (integer)\n")
|
| 60 | 253 | storres | write(" intervalCenter the interval center (a floating-point number)\n")
|
| 61 | 253 | storres | write(" numberOfNumbers the number of floating-point numbers in the interval\n")
|
| 62 | 253 | storres | write(" as a positive integral expression\n")
|
| 63 | 253 | storres | write(" debug debug mode (\"debug\", in any case)\n\n")
|
| 64 | 253 | storres | sys.exit(_sage_const_2 ) |
| 65 | 253 | storres | # End usage.
|
| 66 | 253 | storres | #
|
| 67 | 253 | storres | argsCount = len(sys.argv)
|
| 68 | 253 | storres | scriptName = os.path.basename(__file__) |
| 69 | 253 | storres | if argsCount < _sage_const_5 :
|
| 70 | 253 | storres | usage() |
| 71 | 253 | storres | for index in xrange(_sage_const_1 ,argsCount): |
| 72 | 253 | storres | if index == _sage_const_1 :
|
| 73 | 253 | storres | degree = int(sys.argv[index])
|
| 74 | 253 | storres | elif index == _sage_const_2 :
|
| 75 | 253 | storres | alpha = int(sys.argv[index])
|
| 76 | 253 | storres | elif index == _sage_const_3 :
|
| 77 | 253 | storres | htrn = int(eval(sys.argv[index])) |
| 78 | 253 | storres | elif index == _sage_const_4 :
|
| 79 | 253 | storres | try:
|
| 80 | 253 | storres | intervalCenter = QQ(sage_eval(sys.argv[index])) |
| 81 | 253 | storres | except:
|
| 82 | 253 | storres | intervalCenter = RRR(sys.argv[index]) |
| 83 | 253 | storres | intervalCenter = RRR(intervalCenter) |
| 84 | 253 | storres | elif index == _sage_const_5 :
|
| 85 | 253 | storres | ## Can be read as rational number but must end up as an integer.
|
| 86 | 253 | storres | numberOfNumbers = QQ(sage_eval(sys.argv[index])) |
| 87 | 253 | storres | if numberOfNumbers != numberOfNumbers.round():
|
| 88 | 253 | storres | raise Exception("Invalid number of numbers: " + sys.argv[index] + ".") |
| 89 | 253 | storres | numberOfNumbers = numberOfNumbers.round() |
| 90 | 253 | storres | ## The number must be strictly positive.
|
| 91 | 253 | storres | if numberOfNumbers <= _sage_const_0 :
|
| 92 | 253 | storres | raise Exception("Invalid number of numbers: " + sys.argv[index] + ".") |
| 93 | 253 | storres | elif index == _sage_const_6 :
|
| 94 | 253 | storres | debugMode = sys.argv[index].upper() |
| 95 | 253 | storres | debugMode = (debugMode == "DEBUG")
|
| 96 | 253 | storres | # Done with command line arguments collection.
|
| 97 | 253 | storres | #
|
| 98 | 253 | storres | ## Debug printing
|
| 99 | 253 | storres | print "degree :", degree |
| 100 | 253 | storres | print "alpha :", alpha |
| 101 | 253 | storres | print "htrn :", htrn |
| 102 | 253 | storres | print "interval center:", intervalCenter.n(prec=_sage_const_10 ).str(truncate=False) |
| 103 | 253 | storres | print "num of nums :", RR(numberOfNumbers).log2().n(prec=_sage_const_10 ).str(truncate=False) |
| 104 | 253 | storres | print "debug mode :", debugMode |
| 105 | 253 | storres | print
|
| 106 | 253 | storres | #
|
| 107 | 253 | storres | ## Set the terminal window title.
|
| 108 | 253 | storres | terminalWindowTitle = ['stt', str(degree), str(alpha), str(htrn), |
| 109 | 253 | storres | intervalCenter.n(prec=_sage_const_10 ).str(truncate=False),
|
| 110 | 253 | storres | RRR(numberOfNumbers).log2().n(prec=_sage_const_10 ).str(truncate=False)]
|
| 111 | 253 | storres | call(terminalWindowTitle) |
| 112 | 253 | storres | #
|
| 113 | 253 | storres | intervalCenterBinade = slz_compute_binade(intervalCenter) |
| 114 | 253 | storres | intervalRadius = \ |
| 115 | 253 | storres | _sage_const_2 **intervalCenterBinade * _sage_const_2 **(-precision + _sage_const_1 ) * numberOfNumbers / _sage_const_2 |
| 116 | 253 | storres | srs_run_SLZ_v05(inputFunction=func, |
| 117 | 253 | storres | inputLowerBound = intervalCenter - intervalRadius, |
| 118 | 253 | storres | inputUpperBound = intervalCenter + intervalRadius, |
| 119 | 253 | storres | alpha = alpha, |
| 120 | 253 | storres | degree = degree, |
| 121 | 253 | storres | precision = precision, |
| 122 | 253 | storres | emin = emin, |
| 123 | 253 | storres | emax = emax, |
| 124 | 253 | storres | targetHardnessToRound = htrn, |
| 125 | 253 | storres | debug = debugMode) |