Révision 98 pobysoPythonSage/src/sageSLZ/sageSLZ.sage

sageSLZ.sage (revision 98)
1 1
"""
2
module: sageSLZ.sage
2
module:: sageSLZ.sage
3 3

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

  
......
83 83
    return((polySo, currentRangeSo, intervalCenterSo, maxErrorSo))
84 84
# End slz_compute_polynomial_and_interval
85 85

  
86
def slz_compute_reduced_polynomials(reducedMatrix,
87
                                    knownMonomials,
88
                                    polynomialRing,
89
                                    var1Bound,
90
                                    var2Bound, ):
91
    """
92
    From a reduced matrix, holding the coefficients, from a monomials list,
93
    from the bounds of each variable, compute the corresponding polynomials
94
    scaled back by dividing by the "right" powers of the variables bounds.
95
    """
96
    # TODO: check input arguments.
97
    if len(knownMonomials) == 0:
98
        return []
99
    (var1, var2) = knownMonomials[0].variables()[0:2]
100
    print "Variable 1:", var1;
101
    print "Variable 2:", var2
102
    reducedPolynomials = []
103
    for matrixRow in reducedMatrix.rows():
104
        currentExpression = 0
105
        for colIndex in xrange(0, len(knownMonomials)):
106
            currentCoefficient = matrixRow[colIndex]
107
            print knownMonomials[colIndex]
108
            currentMonomialAsMvp = polynomialRing(knownMonomials[colIndex])
109
            print "Monomial as multivariate polynomial:", \
110
            currentMonomialAsMvp, type(currentMonomialAsMvp)
111
            degreeInVar1 = currentMonomialAsMvp.degree(var1)
112
            print "Degree in var", var1, ":", degreeInVar1
113
            degreeInVar2 = currentMonomialAsMvp.degree(var2)
114
            if degreeInVar1 != 0:
115
                currentCoefficient  /= (var1Bound^degreeInVar1)
116
            if degreeInVar2 != 0:
117
                currentCoefficient /= (var2Bound^degreeInVar2)
118
            print "Current Expression:", currentExpression
119
            currentExpression += currentCoefficient * \
120
                currentMonomialAsMvp
121
        reducedPolynomials.append(currentExpression)
122
    return reducedPolynomials 
123
# End slz_compute_reduced_polynomials
124

  
86 125
def slz_compute_scaled_function(functionSa, \
87 126
                                      lowerBoundSa, \
88 127
                                      upperBoundSa, \

Formats disponibles : Unified diff