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

sageSLZ.sage (revision 99)
85 85

  
86 86
def slz_compute_reduced_polynomials(reducedMatrix,
87 87
                                    knownMonomials,
88
                                    polynomialRing,
89 88
                                    var1Bound,
90
                                    var2Bound, ):
89
                                    var2Bound):
91 90
    """
92 91
    From a reduced matrix, holding the coefficients, from a monomials list,
93 92
    from the bounds of each variable, compute the corresponding polynomials
94 93
    scaled back by dividing by the "right" powers of the variables bounds.
94
    
95
    The elements in knownMonomials must be of the "right" polynomial type.
95 96
    """
97
    
96 98
    # TODO: check input arguments.
97 99
    if len(knownMonomials) == 0:
98 100
        return []
99
    (var1, var2) = knownMonomials[0].variables()[0:2]
100
    print "Variable 1:", var1;
101
    print "Variable 2:", var2
101
    # Search in knowMonomials until we find a bivariate one, otherwise
102
    # the call to variables does not give the expected result.
103
    monomialIndex = 1
104
    while len(knownMonomials[monomialIndex].variables()) != 2 :
105
        monomialIndex +=1
106
    (var1, var2) = knownMonomials[monomialIndex].variables()[0:2]
107
    #print "Variable 1:", var1
108
    #print "Variable 2:", var2
102 109
    reducedPolynomials = []
110
    currentPolynomial = 0
103 111
    for matrixRow in reducedMatrix.rows():
104
        currentExpression = 0
105 112
        for colIndex in xrange(0, len(knownMonomials)):
106 113
            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
            #print knownMonomials[colIndex]
115
            currentMonomial = knownMonomials[colIndex]
116
            #print "Monomial as multivariate polynomial:", \
117
            currentMonomial, type(currentMonomial)
118
            degreeInVar1 = currentMonomial.degree(var1)
119
            #print "Degree in var", var1, ":", degreeInVar1
120
            degreeInVar2 = currentMonomial.degree(var2)
121
            #print "Degree in var", var2, ":", degreeInVar2
114 122
            if degreeInVar1 != 0:
115 123
                currentCoefficient  /= (var1Bound^degreeInVar1)
116 124
            if degreeInVar2 != 0:
117 125
                currentCoefficient /= (var2Bound^degreeInVar2)
118
            print "Current Expression:", currentExpression
119
            currentExpression += currentCoefficient * \
120
                currentMonomialAsMvp
121
        reducedPolynomials.append(currentExpression)
126
            #print "Current reduced monomial:", (currentCoefficient * \
127
            #                                    currentMonomial)
128
            currentPolynomial += (currentCoefficient * currentMonomial)
129
        #print "Type of the current polynomial:", type(currentPolynomial)
130
        reducedPolynomials.append(currentPolynomial)
122 131
    return reducedPolynomials 
123
# End slz_compute_reduced_polynomials
132
# End slz_compute_reduced_polynomials.
124 133

  
125 134
def slz_compute_scaled_function(functionSa, \
126 135
                                      lowerBoundSa, \

Formats disponibles : Unified diff