root / pobysoPythonSage / src / sageSLZ / runSLZ-53-binade.sage @ 280
Historique | Voir | Annoter | Télécharger (5,31 ko)
| 1 | 253 | storres | #! /opt/sage/sage |
|---|---|---|---|
| 2 | 253 | storres | # @file runSLZ-113proj.sage |
| 3 | 253 | storres | # |
| 4 | 253 | storres | #@par Changes from runSLZ-113.sage |
| 5 | 253 | storres | # LLL reduction is not performed on the matrix itself but rather on the |
| 6 | 253 | storres | # product of the matrix with a uniform random matrix. |
| 7 | 253 | storres | # The reduced matrix obtained is discarded but the transformation matrix |
| 8 | 253 | storres | # obtained is used to multiply the original matrix in order to reduced it. |
| 9 | 253 | storres | # If a sufficient level of reduction is obtained, we stop here. If not |
| 10 | 253 | storres | # the product matrix obtained above is LLL reduced. But as it has been |
| 11 | 253 | storres | # pre-reduced at the above step, reduction is supposed to be much faster. |
| 12 | 253 | storres | # |
| 13 | 253 | storres | # Both reductions combined should hopefully be faster than a straight single |
| 14 | 253 | storres | # reduction. |
| 15 | 253 | storres | # |
| 16 | 253 | storres | # Run SLZ for p=113 |
| 17 | 253 | storres | #from scipy.constants.codata import precision |
| 18 | 253 | storres | def initialize_env(): |
| 19 | 253 | storres | """ |
| 20 | 253 | storres | Load all necessary modules. |
| 21 | 253 | storres | """ |
| 22 | 253 | storres | compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx" |
| 23 | 253 | storres | if compiledSpyxDir not in sys.path: |
| 24 | 253 | storres | sys.path.append(compiledSpyxDir) |
| 25 | 253 | storres | if not 'mpfi' in sage.misc.cython.standard_libs: |
| 26 | 253 | storres | sage.misc.cython.standard_libs.append('mpfi')
|
| 27 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
|
| 28 | 253 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
|
| 29 | 253 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
|
| 30 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
|
| 31 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
|
| 32 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
|
| 33 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
|
| 34 | 253 | storres | # Matrix operations are loaded by polynomial operations. |
| 35 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
|
| 36 | 253 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
|
| 37 | 253 | storres | |
| 38 | 253 | storres | |
| 39 | 253 | storres | print "Running SLZ..." |
| 40 | 253 | storres | initialize_env() |
| 41 | 253 | storres | from sageMpfr import * |
| 42 | 253 | storres | from sageGMP import * |
| 43 | 253 | storres | import sys |
| 44 | 253 | storres | from subprocess import call |
| 45 | 253 | storres | # |
| 46 | 253 | storres | ## Main variables and parameters. |
| 47 | 253 | storres | x = var('x')
|
| 48 | 253 | storres | func(x) = exp(x) |
| 49 | 253 | storres | precision = 53 |
| 50 | 253 | storres | emin = -1022 |
| 51 | 253 | storres | emax = 1023 |
| 52 | 253 | storres | RRR = RealField(precision) |
| 53 | 253 | storres | degree = 0 |
| 54 | 253 | storres | alpha = 0 |
| 55 | 253 | storres | htrn = 0 |
| 56 | 253 | storres | signAsString = "" |
| 57 | 253 | storres | binade = 0 |
| 58 | 253 | storres | debugMode = False |
| 59 | 253 | storres | ## Local functions |
| 60 | 253 | storres | # |
| 61 | 253 | storres | def usage(): |
| 62 | 253 | storres | write = sys.stderr.write |
| 63 | 253 | storres | write("\nUsage:\n")
|
| 64 | 253 | storres | write(" " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
|
| 65 | 253 | storres | write(" <numberOfNumbers> [debug]\n")
|
| 66 | 253 | storres | write("\nArguments:\n")
|
| 67 | 253 | storres | write(" degree the degree of the polynomial (integer)\n")
|
| 68 | 253 | storres | write(" alpha alpha (integer)\n")
|
| 69 | 253 | storres | write(" htrn hardness-to-round - a number of bits (integer)\n")
|
| 70 | 253 | storres | write(" binade the binade we want to explore\n")
|
| 71 | 253 | storres | write(" as a positive integral expression\n")
|
| 72 | 253 | storres | write(" sign the sign of the interval we want to expolore\n")
|
| 73 | 253 | storres | write(" either \"pos\" or \"neg\"\n")
|
| 74 | 253 | storres | write(" debug debug mode (\"debug\", in any case)\n\n")
|
| 75 | 253 | storres | sys.exit(2) |
| 76 | 253 | storres | # End usage. |
| 77 | 253 | storres | # |
| 78 | 253 | storres | argsCount = len(sys.argv) |
| 79 | 253 | storres | scriptName = os.path.basename(__file__) |
| 80 | 253 | storres | if argsCount < 6: |
| 81 | 253 | storres | usage() |
| 82 | 253 | storres | for index in xrange(1,argsCount): |
| 83 | 253 | storres | if index == 1: |
| 84 | 253 | storres | degree = int(sys.argv[index]) |
| 85 | 253 | storres | elif index == 2: |
| 86 | 253 | storres | alpha = int(sys.argv[index]) |
| 87 | 253 | storres | elif index == 3: |
| 88 | 253 | storres | htrn = int(eval(sys.argv[index])) |
| 89 | 253 | storres | elif index == 4: |
| 90 | 253 | storres | binade = int(eval(sys.argv[index])) |
| 91 | 253 | storres | elif index == 5: |
| 92 | 253 | storres | signAsString = sys.argv[index] |
| 93 | 254 | storres | signAsString = signAsString.lower() |
| 94 | 253 | storres | elif index == 6: |
| 95 | 253 | storres | debugMode = sys.argv[index].upper() |
| 96 | 253 | storres | debugMode = (debugMode == "DEBUG") |
| 97 | 253 | storres | # Done with command line arguments collection. |
| 98 | 253 | storres | # |
| 99 | 253 | storres | ## Set the terminal window title. |
| 100 | 253 | storres | terminalWindowTitle = ['stt', |
| 101 | 253 | storres | str(degree), |
| 102 | 253 | storres | str(alpha), |
| 103 | 253 | storres | str(htrn), |
| 104 | 253 | storres | str(binade), |
| 105 | 253 | storres | signAsString] |
| 106 | 253 | storres | call(terminalWindowTitle) |
| 107 | 253 | storres | # |
| 108 | 253 | storres | binadeUlp = 2^(binade - precision + 1) |
| 109 | 253 | storres | if signAsString == "pos": |
| 110 | 253 | storres | lowerBound = RRR(2^binade) |
| 111 | 253 | storres | upperBound = RRR(2^(binade+1)) - binadeUlp |
| 112 | 253 | storres | elif signAsString == "neg": |
| 113 | 253 | storres | lowerBound = -RRR(2^(binade+1)) + binadeUlp |
| 114 | 253 | storres | upperBound = -RRR(2^binade) |
| 115 | 253 | storres | else: |
| 116 | 253 | storres | exceptionErrorMess = "\"" + signAsString + "\" is an invalid sign." \ |
| 117 | 253 | storres | ". Aborting!\n" |
| 118 | 253 | storres | raise Exception(exceptionErrorMess) |
| 119 | 254 | storres | # |
| 120 | 254 | storres | ## Debug printing |
| 121 | 254 | storres | print "degree :", degree |
| 122 | 254 | storres | print "alpha :", alpha |
| 123 | 254 | storres | print "htrn :", htrn |
| 124 | 254 | storres | print "binade :", binade |
| 125 | 254 | storres | print "lower bound :", lowerBound.str(truncate=False) |
| 126 | 254 | storres | print "upper bound :", upperBound.str(truncate=False) |
| 127 | 254 | storres | print "sign :", signAsString |
| 128 | 254 | storres | print "debug mode :", debugMode |
| 129 | 254 | storres | |
| 130 | 254 | storres | # |
| 131 | 253 | storres | srs_run_SLZ_v05(inputFunction=func, |
| 132 | 253 | storres | inputLowerBound = lowerBound, |
| 133 | 253 | storres | inputUpperBound = upperBound, |
| 134 | 253 | storres | alpha = alpha, |
| 135 | 253 | storres | degree = degree, |
| 136 | 253 | storres | precision = precision, |
| 137 | 253 | storres | emin = emin, |
| 138 | 253 | storres | emax = emax, |
| 139 | 253 | storres | targetHardnessToRound = htrn, |
| 140 | 253 | storres | debug = debugMode) |