Révision 90

pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 90)
1
"""
2
module: sageSLZ.sage
3

  
4
Sage core function needed for the implementation of SLZ.
5

  
6
Created on 2013-08
7

  
8
moduleauthor:: S.T.
9
"""
1 10
print "sageSLZ loading..."
2 11
def slz_compute_polynomial_and_interval(functionSo, degreeSo, lowerBoundSa, 
3 12
                                        upperBoundSa, approxPrecSa, 
......
331 340
                                                variable1,
332 341
                                                variable2):
333 342
    """
334
    Creates a new polynomial with integer coefficients for use with the
335
    Coppersmith method.
343
    Creates a new multivariate polynomial with integer coefficients for use
344
     with the Coppersmith method.
336 345
    A the same time it computes :
337 346
    - 2^K (N);
338
    - 2^k
347
    - 2^k (bound on the second variable)
339 348
    - lcm
349

  
350
    :param ratPolyOfInt: a polynomial with rational coefficients and integer
351
                         variables.
352
    :param precision: the precision of the floating-point coefficients.
353
    :param targetHardnessToRound: the hardness to round we want to check.
354
    :param variable1: the first variable of the polynomial (an expression).
355
    :param variable2: the second variable of the polynomial (an expression).
356
    
357
    :returns: a 4 elements tuple:
358
                - the polynomial;
359
                - the module (N);
360
                - the lcm used to compute the integral coefficients and the 
361
                  module.
340 362
    """
341 363
    # Create a new integer polynomial ring.
342 364
    IP = PolynomialRing(ZZ, name=str(variable1) + "," + str(variable2))
......
346 368
    coefficientDenominators = sro_denominators(ratPolyCoefficients)
347 369
    coefficientDenominators.append(2^precision)
348 370
    coefficientDenominators.append(2^(targetHardnessToRound + 1))
349
    # Compute the lcm
350 371
    leastCommonMultiple = lcm(coefficientDenominators)
351 372
    # Compute the expression corresponding to the new polynomial
352 373
    coefficientNumerators =  sro_numerators(ratPolyCoefficients)
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 90)
357 357
    return ((protoMatrixRows, knownMonomials))
358 358
# End spo_polynomial_to_proto_matrix
359 359

  
360
def spo_proto_to_column_matrix(protoMatrixColumns):
360
def spo_proto_to_column_matrix(protoMatrixColumns, \
361
                               knownMonomialsList, \
362
                               boundVar1, \
363
                               boundVar2):
361 364
    """
362 365
    Create a column (each row holds the coefficients of one monomial) matrix.
363 366
    protoMatrixRows.
......
376 379
    baseMatrix = matrix(ZZ, numRows, numColumns)
377 380
    for colIndex in xrange(0, numColumns):
378 381
        for rowIndex in xrange(0, len(protoMatrixColumns[colIndex])):
379
            baseMatrix[rowIndex, colIndex] = \
380
            protoMatrixColumns[colIndex][rowIndex]
382
            if protoMatrixColumns[colIndex][rowIndex] != 0:
383
                baseMatrix[rowIndex, colIndex] = \
384
                    protoMatrixColumns[colIndex][rowIndex] * \
385
                    knownMonomialsList[rowIndex](boundVar1, boundVar2)
381 386
    return baseMatrix
382 387
# End spo_proto_to_column_matrix.
383 388
#
......
386 391
                            boundVar1, \
387 392
                            boundVar2):
388 393
    """
389
    Create a row (each column holds the coefficients of one monomial) matrix.
394
    Create a row (each column holds the evaluation one monomial at boundVar1 and
395
    boundVar2 values) matrix.
390 396
    protoMatrixRows.
391 397
    
392 398
    Parameters

Formats disponibles : Unified diff