Révision 192 pobysoPythonSage/src/sageSLZ/runSLZ-01.sage

runSLZ-01.sage (revision 192)
328 328
                    for tRoot in tRootsList:
329 329
                        reducedPolynomialsRootsSet.add((iRoot[0], tRoot[0]))
330 330
        # End of roots computation
331
    ## Prepare for results.
332
    intervalResultsList = []
333
    intervalResultsList.append((lb, ub))
334
    ## Check roots.
335
    rootsResultsList = []
336
    rootsComputationTime        = cputime()
337
    for root in reducedPolynomialsRootsSet:
338
        specificRootResultsList = []
339
        failingBounds = []
340
        intIntPdivN = intIntP(root[0], root[1]) / N
341
        if int(intIntPdivN) != intIntPdivN:
342
            continue # Next root
343
        # Root qualifies for modular equation, test it for hardness to round.
344
        hardToRoundCaseAsFloat = RRR((icAsInt + root[0]) / toIntegerFactor)
345
        #print "Before unscaling:", hardToRoundCaseAsFloat.n(prec=precision)
346
        #print scalingFunction
347
        scaledHardToRoundCaseAsFloat = scalingFunction(hardToRoundCaseAsFloat) 
348
        print "Candidate HTRNc at x =", scaledHardToRoundCaseAsFloat.n().str(base=2),
349
        if slz_is_htrn(scaledHardToRoundCaseAsFloat,
350
                       f,
351
                       2^-(targetHardnessToRound),
352
                       RRR):
353
            print hardToRoundCaseAsFloat, "is HTRN case."
354
            if lb <= hardToRoundCaseAsFloat and hardToRoundCaseAsFloat <= ub:
355
                print "Found in interval."
356
            else:
357
                print "Found out of interval."
358
            specificRootResultsList.append(hardToRoundCaseAsFloat.n().str(base=2))
359
            # Check the root is in the bounds
360
            if abs(root[0]) > iBound or abs(root[1]) > tBound:
361
                print "Root", root, "is out of bounds."
362
                if abs(root[0]) > iBound:
363
                    print "root[0]:", root[0]
364
                    print "i bound:", iBound
365
                    failingBounds.append('i')
366
                    failingBounds.append(root[0])
367
                    failingBounds.append(iBound)
368
                if abs(root[1]) > tBound:
369
                    print "root[1]:", root[1]
370
                    print "t bound:", tBound
371
                    failingBounds.append('t')
372
                    failingBounds.append(root[1])
373
                    failingBounds.append(tBound)
374
            if len(failingBounds) > 0:
375
                specificRootResultsList.append(failingBounds)
376
        else: # From slz_is_htrn...
377
            print "is not an HTRN case."
378
        if len(specificRootResultsList) > 0:
379
            rootsResultsList.append(specificRootResultsList)
380
    rootsComputationsFullTime       =   cputime(rootsComputationTime)
381
    rootsComputationsCount          +=  1
382
    if len(rootsResultsList) > 0:
383
        intervalResultsList.append(rootsResultsList)
384
    ## An intervalResultsList has at least the bounds.
385
    globalResultsList.append(intervalResultsList)   
331
        ##### Prepare for results.
332
        intervalResultsList = []
333
        intervalResultsList.append((lb, ub))
334
        #### Check roots.
335
        rootsResultsList = []
336
        rootsComputationTime        = cputime()
337
        for root in reducedPolynomialsRootsSet:
338
            specificRootResultsList = []
339
            failingBounds = []
340
            intIntPdivN = intIntP(root[0], root[1]) / N
341
            if int(intIntPdivN) != intIntPdivN:
342
                continue # Next root
343
            # Root qualifies for modular equation, test it for hardness to round.
344
            hardToRoundCaseAsFloat = RRR((icAsInt + root[0]) / toIntegerFactor)
345
            #print "Before unscaling:", hardToRoundCaseAsFloat.n(prec=precision)
346
            #print scalingFunction
347
            scaledHardToRoundCaseAsFloat = \
348
                scalingFunction(hardToRoundCaseAsFloat) 
349
            print "Candidate HTRNc at x =", \
350
                scaledHardToRoundCaseAsFloat.n().str(base=2),
351
            if slz_is_htrn(scaledHardToRoundCaseAsFloat,
352
                           f,
353
                           2^-(targetHardnessToRound),
354
                           RRR):
355
                print hardToRoundCaseAsFloat, "is HTRN case."
356
                if lb <= hardToRoundCaseAsFloat and hardToRoundCaseAsFloat <= ub:
357
                    print "Found in interval."
358
                else:
359
                    print "Found out of interval."
360
                specificRootResultsList.append(hardToRoundCaseAsFloat.n().str(base=2))
361
                # Check the root is in the bounds
362
                if abs(root[0]) > iBound or abs(root[1]) > tBound:
363
                    print "Root", root, "is out of bounds."
364
                    if abs(root[0]) > iBound:
365
                        print "root[0]:", root[0]
366
                        print "i bound:", iBound
367
                        failingBounds.append('i')
368
                        failingBounds.append(root[0])
369
                        failingBounds.append(iBound)
370
                    if abs(root[1]) > tBound:
371
                        print "root[1]:", root[1]
372
                        print "t bound:", tBound
373
                        failingBounds.append('t')
374
                        failingBounds.append(root[1])
375
                        failingBounds.append(tBound)
376
                if len(failingBounds) > 0:
377
                    specificRootResultsList.append(failingBounds)
378
            else: # From slz_is_htrn...
379
                print "is not an HTRN case."
380
            if len(specificRootResultsList) > 0:
381
                rootsResultsList.append(specificRootResultsList)
382
        rootsComputationsFullTime       =   cputime(rootsComputationTime)
383
        rootsComputationsCount          +=  1
384
        if len(rootsResultsList) > 0:
385
            intervalResultsList.append(rootsResultsList)
386
        #### An intervalResultsList has at least the bounds.
387
        globalResultsList.append(intervalResultsList)   
386 388
        #### End loop flesh.
387 389
        #### Compute an incremented width for next upper bound, only
388 390
        #    if not Coppersmith condition nor resultant condition
......
463 465
precision = 53
464 466
RRR = RealField(precision)
465 467
run_SLZ_v01(inputFunction=func, 
466
            inputLowerBound = 1/4, 
467
            inputUpperBound = RRR(1/2) - RRR(1/4).ulp(), 
468
            inputLowerBound = 6/16, 
469
            inputUpperBound = 7/16, 
468 470
            alpha = 2, 
469 471
            degree = 10, 
470 472
            precision = 53, 
......
472 474
            emax = 1023, 
473 475
            targetHardnessToRound =  precision+50, 
474 476
            debug = True)
477

  
478
#inputUpperBound = RRR(1/2) - RRR(1/4).ulp(), 

Formats disponibles : Unified diff