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

sageSLZ.sage (revision 106)
87 87

  
88 88
def slz_compute_reduced_polynomials(reducedMatrix,
89 89
                                    knownMonomials,
90
                                    var1,
90 91
                                    var1Bound,
92
                                    var2,
91 93
                                    var2Bound):
92 94
    """
93 95
    From a reduced matrix, holding the coefficients, from a monomials list,
......
99 101
    """
100 102
    
101 103
    # TODO: check input arguments.
102
    if len(knownMonomials) == 0:
103
        return []
104
    # Search in knowMonomials until we find a bivariate one, otherwise
105
    # the call to variables does not give the expected result.
106
    monomialIndex = 1
107
    while len(knownMonomials[monomialIndex].variables()) != 2 :
108
        monomialIndex +=1
109
    (var1, var2) = knownMonomials[monomialIndex].variables()[0:2]
110
    #print "Variable 1:", var1
111
    #print "Variable 2:", var2
112 104
    reducedPolynomials = []
113
    currentPolynomial = 0
105
    #print "type var1:", type(var1), " - type var2:", type(var2)
114 106
    for matrixRow in reducedMatrix.rows():
115 107
        currentPolynomial = 0
116 108
        for colIndex in xrange(0, len(knownMonomials)):
117 109
            currentCoefficient = matrixRow[colIndex]
118
            #print knownMonomials[colIndex]
119
            currentMonomial = knownMonomials[colIndex]
120
            #print "Monomial as multivariate polynomial:", \
121
            currentMonomial, type(currentMonomial)
122
            degreeInVar1 = currentMonomial.degree(var1)
123
            #print "Degree in var", var1, ":", degreeInVar1
124
            degreeInVar2 = currentMonomial.degree(var2)
125
            #print "Degree in var", var2, ":", degreeInVar2
126
            if degreeInVar1 != 0:
127
                currentCoefficient  /= (var1Bound^degreeInVar1)
128
            if degreeInVar2 != 0:
129
                currentCoefficient /= (var2Bound^degreeInVar2)
130
            #print "Current reduced monomial:", (currentCoefficient * \
131
            #                                    currentMonomial)
132
            currentPolynomial += (currentCoefficient * currentMonomial)
110
            if currentCoefficient != 0:
111
                #print "Current coefficient:", currentCoefficient
112
                currentMonomial = knownMonomials[colIndex]
113
                parentRing = currentMonomial.parent()
114
                #print "Monomial as multivariate polynomial:", \
115
                #currentMonomial, type(currentMonomial)
116
                degreeInVar1 = currentMonomial.degree(parentRing(var1))
117
                #print "Degree in var", var1, ":", degreeInVar1
118
                degreeInVar2 = currentMonomial.degree(parentRing(var2))
119
                #print "Degree in var", var2, ":", degreeInVar2
120
                if degreeInVar1 > 0:
121
                    currentCoefficient = \
122
                        currentCoefficient / var1Bound^degreeInVar1
123
                    #print "varBound1 in degree:", var1Bound^degreeInVar1
124
                    #print "Current coefficient(1)", currentCoefficient
125
                if degreeInVar2 > 0:
126
                    currentCoefficient = \
127
                        currentCoefficient / var2Bound^degreeInVar2
128
                    #print "Current coefficient(2)", currentCoefficient
129
                #print "Current reduced monomial:", (currentCoefficient * \
130
                #                                    currentMonomial)
131
                currentPolynomial += (currentCoefficient * currentMonomial)
132
                #print "Current polynomial:", currentPolynomial
133
            # End if
134
        # End for colIndex.
133 135
        #print "Type of the current polynomial:", type(currentPolynomial)
134 136
        reducedPolynomials.append(currentPolynomial)
135 137
    return reducedPolynomials 

Formats disponibles : Unified diff