Statistiques
| Révision :

root / pobysoPythonSage / src / sageSLZ / sagePolynomialOperations.sage @ 98

Historique | Voir | Annoter | Télécharger (21,83 ko)

1 74 storres
load "/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage"
2 87 storres
print "sagePolynomialOperations loading..."
3 83 storres
def spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
4 83 storres
                                            pCoefficients,
5 83 storres
                                            knownMonomials,
6 83 storres
                                            protoMatrixRows,
7 83 storres
                                            columnsWidth=0):
8 80 storres
    """
9 80 storres
    For a given polynomial (under the form of monomials and coefficents lists),
10 80 storres
    add the coefficients of the protoMatrix (a list of proto matrix rows).
11 80 storres
    Coefficients are added to the protoMatrix row in the order imposed by the
12 80 storres
    monomials discovery list (the knownMonomials list) built as construction
13 80 storres
    goes on.
14 83 storres
    As a bonus, data can be printed out for a visual check.
15 80 storres
    pMonomials     : the list of the monomials coming form some polynomial;
16 80 storres
    pCoefficients  : the list of the corresponding coefficients to add to
17 80 storres
                     the protoMatrix in the exact same order as the monomials;
18 80 storres
    knownMonomials : the list of the already knonw monomials;
19 80 storres
    protoMatrixRows: a list of lists, each one holding the coefficients of the
20 80 storres
                     monomials
21 80 storres
    columnWith     : the width, in characters, of the displayed column ; if 0,
22 80 storres
                     do not display anything.
23 80 storres
    """
24 80 storres
    # We have started with the smaller degrees in the first variable.
25 80 storres
    pMonomials.reverse()
26 80 storres
    pCoefficients.reverse()
27 80 storres
    # New empty proto matrix row.
28 80 storres
    protoMatrixRowCoefficients = []
29 80 storres
    # We work according to the order of the already known monomials
30 80 storres
    # No known monomials yet: add the pMonomials to knownMonomials
31 80 storres
    # and add the coefficients to the proto matrix row.
32 80 storres
    if len(knownMonomials) == 0:
33 80 storres
        for pmIdx in xrange(0, len(pMonomials)):
34 80 storres
            knownMonomials.append(pMonomials[pmIdx])
35 80 storres
            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
36 80 storres
            if columnsWidth != 0:
37 80 storres
                monomialAsString = str(pCoefficients[pmIdx]) + " " + \
38 80 storres
                                   str(pMonomials[pmIdx])
39 80 storres
                print monomialAsString, " " * \
40 80 storres
                      (columnsWidth - len(monomialAsString)),
41 80 storres
    # There are some known monomials. We search for them in pMonomials and
42 80 storres
    # add their coefficients to the proto matrix row.
43 80 storres
    else:
44 80 storres
        for knownMonomialIndex in xrange(0,len(knownMonomials)):
45 80 storres
            # We lazily use an exception here since pMonomials.index() function
46 80 storres
            # may fail throwing the ValueError exception.
47 80 storres
            try:
48 80 storres
                indexInPmonomials = \
49 80 storres
                    pMonomials.index(knownMonomials[knownMonomialIndex])
50 80 storres
                if columnsWidth != 0:
51 80 storres
                    monomialAsString = str(pCoefficients[indexInPmonomials]) + \
52 80 storres
                        " " + str(knownMonomials[knownMonomialIndex])
53 80 storres
                    print monomialAsString, " " * \
54 80 storres
                        (columnsWidth - len(monomialAsString)),
55 80 storres
                # Add the coefficient to the proto matrix row and delete the \
56 80 storres
                # known monomial from the current pMonomial list
57 80 storres
                #(and the corresponding coefficient as well).
58 80 storres
                protoMatrixRowCoefficients.append(pCoefficients[indexInPmonomials])
59 80 storres
                del pMonomials[indexInPmonomials]
60 80 storres
                del pCoefficients[indexInPmonomials]
61 80 storres
            # The knownMonomials element is not in pMonomials
62 80 storres
            except ValueError:
63 80 storres
                protoMatrixRowCoefficients.append(0)
64 80 storres
                if columnsWidth != 0:
65 80 storres
                    monomialAsString = "0" + " "+ \
66 80 storres
                        str(knownMonomials[knownMonomialIndex])
67 80 storres
                    print monomialAsString, " " * \
68 80 storres
                        (columnsWidth - len(monomialAsString)),
69 80 storres
        # End for knownMonomialKey loop.
70 80 storres
        # We now append the remaining monomials of pMonomials to knownMonomials
71 80 storres
        # and the corresponding coefficients to proto matrix row.
72 80 storres
        for pmIdx in xrange(0, len(pMonomials)):
73 80 storres
            knownMonomials.append(pMonomials[pmIdx])
74 80 storres
            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
75 80 storres
            if columnsWidth != 0:
76 80 storres
                monomialAsString = str(pCoefficients[pmIdx]) + " " \
77 80 storres
                    + str(pMonomials[pmIdx])
78 80 storres
                print monomialAsString, " " * \
79 80 storres
                    (columnsWidth - len(monomialAsString)),
80 80 storres
        # End for pmIdx loop.
81 80 storres
    # Add the new list row elements to the proto matrix.
82 80 storres
    protoMatrixRows.append(protoMatrixRowCoefficients)
83 80 storres
    if columnsWidth != 0:
84 80 storres
        print
85 83 storres
# End spo_add_polynomial_coeffs_to_matrix_row
86 80 storres
87 80 storres
def spo_expression_as_string(powI, powT, powP, alpha):
88 80 storres
    """
89 80 storres
    Computes a string version of the i^k + t^l + p^m + N^n expression for
90 80 storres
    output.
91 80 storres
    """
92 80 storres
    expressionAsString =""
93 80 storres
    if powI != 0:
94 80 storres
        expressionAsString += "i^" + str(powI)
95 80 storres
    if powT != 0:
96 80 storres
        if len(expressionAsString) != 0:
97 80 storres
            expressionAsString += " * "
98 80 storres
        expressionAsString += "t^" + str(powT)
99 80 storres
    if powP != 0:
100 80 storres
        if len(expressionAsString) != 0:
101 80 storres
            expressionAsString += " * "
102 80 storres
        expressionAsString += "p^" + str(powP)
103 80 storres
    if (alpha - powP) != 0 :
104 80 storres
        if len(expressionAsString) != 0:
105 80 storres
            expressionAsString += " * "
106 80 storres
        expressionAsString += "N^" + str(alpha - powP)
107 80 storres
    return(expressionAsString)
108 80 storres
# End spo_expression_as_string.
109 80 storres
110 87 storres
def spo_norm(poly, p=2):
111 81 storres
    """
112 81 storres
    Behaves more or less (no infinity defined) as the norm for the
113 81 storres
    univariate polynomials.
114 81 storres
    Quoting the Sage documentation:
115 81 storres
    Definition: For integer p, the p-norm of a polynomial is the pth root of
116 81 storres
    the sum of the pth powers of the absolute values of the coefficients of
117 81 storres
    the polynomial.
118 87 storres
119 81 storres
    """
120 87 storres
    # TODO: check the arguments (for p see below)..
121 81 storres
    norm = 0
122 87 storres
    # For infinity norm.
123 87 storres
    if p == Infinity:
124 87 storres
        for coefficient in poly.coefficients():
125 87 storres
            coefficientAbs = coefficient.abs()
126 87 storres
            if coefficientAbs > norm:
127 87 storres
                norm = coefficientAbs
128 87 storres
        return norm
129 87 storres
    # TODO: check here the value of p
130 94 storres
    # p must be an integer.
131 94 storres
    if int(p) != p:
132 94 storres
        return None
133 94 storres
    # p must be >= 1.
134 94 storres
    if p < 1:
135 94 storres
        return None
136 87 storres
    # For 1 norm.
137 87 storres
    if p == 1:
138 87 storres
        for coefficient in poly.coefficients():
139 87 storres
            norm +=  coefficient.abs()
140 87 storres
        return norm
141 87 storres
    # For other norms
142 81 storres
    for coefficient in poly.coefficients():
143 87 storres
        norm +=  (coefficient^p).abs()
144 87 storres
    return pow(norm, 1/p)
145 81 storres
# end spo_norm
146 81 storres
147 83 storres
def spo_polynomial_to_proto_matrix(p, pRing, alpha, N, columnsWidth=0):
148 74 storres
    """
149 83 storres
    From a (bivariate) polynomial and some other parameters build a proto
150 87 storres
    matrix (an array of "rows") to be converted into a "true" matrix and
151 83 storres
    eventually by reduced by fpLLL.
152 80 storres
    The matrix is such as those found in Boneh-Durphee and Stehl?.
153 74 storres
154 83 storres
    Parameters
155 83 storres
    ----------
156 87 storres
    p: the (bivariate) polynomial;
157 87 storres
    pRing: the ring over which p is defined;
158 74 storres
    alpha:
159 74 storres
    N:
160 83 storres
    columsWidth: if == 0, no information is displayed, otherwise data is
161 83 storres
                 printed in colums of columnsWitdth width.
162 74 storres
    """
163 77 storres
    knownMonomials = []
164 77 storres
    protoMatrixRows = []
165 92 storres
    polynomialsList = []
166 74 storres
    pVariables = p.variables()
167 74 storres
    iVariable = pVariables[0]
168 76 storres
    tVariable = pVariables[1]
169 87 storres
    polynomialAtPower = pRing(1)
170 87 storres
    currentPolynomial = pRing(1)
171 74 storres
    pIdegree = p.degree(pVariables[0])
172 74 storres
    pTdegree = p.degree(pVariables[1])
173 87 storres
    currentIdegree = currentPolynomial.degree(iVariable)
174 74 storres
    nAtPower = N^alpha
175 91 storres
    nAtAlpha = nAtPower
176 92 storres
    polExpStr = ""
177 74 storres
    # We work from p^0 * N^alpha to p^alpha * N^0
178 74 storres
    for pPower in xrange(0, alpha + 1):
179 76 storres
        # pPower == 0 is a special case. We introduce all the monomials but one
180 78 storres
        # in i and those in t necessary to be able to introduce
181 76 storres
        # p. We arbitrary choose to introduce the highest degree monomial in i
182 76 storres
        # with p. We also introduce all the mixed i^k * t^l monomials with
183 77 storres
        # k < p.degree(i) and l <= p.degree(t).
184 78 storres
        # Mixed terms introduction is necessary here before we start "i shifts"
185 78 storres
        # in the next iteration.
186 74 storres
        if pPower == 0:
187 78 storres
            # Notice that i^pIdegree is excluded as the bound of the xrange is
188 78 storres
            # pIdegree
189 74 storres
            for iPower in xrange(0, pIdegree):
190 74 storres
                for tPower in xrange(0, pTdegree + 1):
191 77 storres
                    if columnsWidth != 0:
192 92 storres
                        polExpStr = spo_expression_as_string(iPower,
193 76 storres
                                                             tPower,
194 76 storres
                                                             pPower,
195 74 storres
                                                             alpha)
196 92 storres
                        print "->", polExpStr
197 74 storres
                    currentExpression = iVariable^iPower * \
198 91 storres
                                        tVariable^tPower * nAtAlpha
199 78 storres
                    # polynomialAtPower == 1 here. Next line should be commented
200 78 storres
                    # out but it does not work! Some conversion problem?
201 91 storres
                    currentPolynomial = pRing(currentExpression)
202 92 storres
                    polynomialsList.append(polExpStr)
203 74 storres
                    pMonomials = currentPolynomial.monomials()
204 74 storres
                    pCoefficients = currentPolynomial.coefficients()
205 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
206 83 storres
                                                            pCoefficients,
207 83 storres
                                                            knownMonomials,
208 83 storres
                                                            protoMatrixRows,
209 83 storres
                                                            columnsWidth)
210 78 storres
                # End tPower.
211 78 storres
            # End for iPower.
212 77 storres
        else: # pPower > 0: (p^1..p^alpha)
213 78 storres
            # This where we introduce the p^pPower * N^(alpha-pPower)
214 77 storres
            # polynomial.
215 77 storres
            # This step could technically be fused as the first iteration
216 77 storres
            # of the next loop (with iPower starting at 0).
217 77 storres
            # We set it apart for clarity.
218 77 storres
            if columnsWidth != 0:
219 92 storres
                polExpStr = spo_expression_as_string(0, 0, pPower, alpha)
220 92 storres
                print "->", polExpStr
221 77 storres
            currentPolynomial = polynomialAtPower * nAtPower
222 92 storres
            polynomialsList.append(polExpStr)
223 77 storres
            pMonomials = currentPolynomial.monomials()
224 77 storres
            pCoefficients = currentPolynomial.coefficients()
225 83 storres
            spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
226 83 storres
                                                    pCoefficients,
227 83 storres
                                                    knownMonomials,
228 83 storres
                                                    protoMatrixRows,
229 83 storres
                                                    columnsWidth)
230 77 storres
231 77 storres
            # The i^iPower * p^pPower polynomials: they add i^k monomials to
232 77 storres
            # p^pPower up to k < pIdegree * pPower. This only introduces i^k
233 77 storres
            # monomials since mixed terms (that were introduced at a previous
234 77 storres
            # stage) are only shifted to already existing
235 77 storres
            # ones. p^pPower is "shifted" to higher degrees in i as far as
236 77 storres
            # possible, one step short of the degree in i of p^(pPower+1) .
237 77 storres
            # These "pure" i^k monomials can only show up with i multiplications.
238 77 storres
            for iPower in xrange(1, pIdegree):
239 87 storres
                if columnsWidth != 0:
240 92 storres
                    polExpStr = spo_expression_as_string(iPower, \
241 87 storres
                                                         0,      \
242 87 storres
                                                         pPower, \
243 87 storres
                                                         alpha)
244 92 storres
                    print "->", polExpStr
245 77 storres
                currentExpression = i^iPower * nAtPower
246 87 storres
                currentPolynomial = pRing(currentExpression) * polynomialAtPower
247 92 storres
                polynomialsList.append(polExpStr)
248 77 storres
                pMonomials = currentPolynomial.monomials()
249 77 storres
                pCoefficients = currentPolynomial.coefficients()
250 87 storres
                spo_add_polynomial_coeffs_to_matrix_row(pMonomials,      \
251 87 storres
                                                        pCoefficients,   \
252 87 storres
                                                        knownMonomials,  \
253 87 storres
                                                        protoMatrixRows, \
254 83 storres
                                                        columnsWidth)
255 77 storres
            # End for iPower
256 77 storres
            # We want now to introduce a t * p^pPower polynomial. But before
257 77 storres
            # that we must introduce some mixed monomials.
258 77 storres
            # This loop is no triggered before pPower == 2.
259 78 storres
            # It introduces a first set of high i degree mixed monomials.
260 77 storres
            for iPower in xrange(1, pPower):
261 77 storres
                tPower = pPower - iPower + 1
262 77 storres
                if columnsWidth != 0:
263 92 storres
                    polExpStr = spo_expression_as_string(iPower * pIdegree,
264 77 storres
                                                         tPower,
265 77 storres
                                                         0,
266 77 storres
                                                         alpha)
267 92 storres
                    print "->", polExpStr
268 91 storres
                currentExpression = i^(iPower * pIdegree) * t^tPower * nAtAlpha
269 87 storres
                currentPolynomial = pRing(currentExpression)
270 92 storres
                polynomialsList.append(polExpStr)
271 77 storres
                pMonomials = currentPolynomial.monomials()
272 77 storres
                pCoefficients = currentPolynomial.coefficients()
273 83 storres
                spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
274 83 storres
                                                        pCoefficients,
275 83 storres
                                                        knownMonomials,
276 83 storres
                                                        protoMatrixRows,
277 83 storres
                                                        columnsWidth)
278 77 storres
            # End for iPower
279 78 storres
            #
280 78 storres
            # This is the mixed monomials main loop. It introduces:
281 77 storres
            # - the missing mixed monomials needed before the
282 78 storres
            #   t^l * p^pPower * N^(alpha-pPower) polynomial;
283 78 storres
            # - the t^l * p^pPower * N^(alpha-pPower) itself;
284 78 storres
            # - for each of i^k * t^l * p^pPower * N^(alpha-pPower) polynomials:
285 78 storres
            #   - the the missing mixed monomials needed  polynomials,
286 78 storres
            #   - the i^k * t^l * p^pPower * N^(alpha-pPower) itself.
287 78 storres
            # The t^l * p^pPower * N^(alpha-pPower) is introduced when
288 78 storres
            #
289 77 storres
            for iShift in xrange(0, pIdegree):
290 77 storres
                # When pTdegree == 1, the following loop only introduces
291 77 storres
                # a single new monomial.
292 77 storres
                #print "++++++++++"
293 77 storres
                for outerTpower in xrange(1, pTdegree + 1):
294 77 storres
                    # First one high i degree mixed monomial.
295 77 storres
                    iPower = iShift + pPower * pIdegree
296 77 storres
                    if columnsWidth != 0:
297 92 storres
                        polExpStr = spo_expression_as_string(iPower,
298 77 storres
                                                             outerTpower,
299 77 storres
                                                             0,
300 77 storres
                                                             alpha)
301 92 storres
                        print "->", polExpStr
302 91 storres
                    currentExpression = i^iPower * t^outerTpower * nAtAlpha
303 87 storres
                    currentPolynomial = pRing(currentExpression)
304 92 storres
                    polynomialsList.append(polExpStr)
305 77 storres
                    pMonomials = currentPolynomial.monomials()
306 77 storres
                    pCoefficients = currentPolynomial.coefficients()
307 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
308 83 storres
                                                            pCoefficients,
309 83 storres
                                                            knownMonomials,
310 83 storres
                                                            protoMatrixRows,
311 83 storres
                                                            columnsWidth)
312 77 storres
                    #print "+++++"
313 78 storres
                    # At iShift == 0, the following innerTpower loop adds
314 78 storres
                    # duplicate monomials, since no extra i^l * t^k is needed
315 78 storres
                    # before introducing the
316 77 storres
                    # i^iShift * t^outerPpower * p^pPower * N^(alpha-pPower)
317 77 storres
                    # polynomial.
318 77 storres
                    # It introduces smaller i degree monomials than the
319 77 storres
                    # one(s) added previously (no pPower multiplication).
320 77 storres
                    # Here the exponent of t decreases as that of i increases.
321 78 storres
                    # This conditional is not entered before pPower == 1.
322 78 storres
                    # The innerTpower loop does not produce anything before
323 78 storres
                    # pPower == 2. We keep it anyway for other configuration of
324 78 storres
                    # p.
325 77 storres
                    if iShift > 0:
326 77 storres
                        iPower = pIdegree + iShift
327 77 storres
                        for innerTpower in xrange(pPower, 1, -1):
328 77 storres
                            if columnsWidth != 0:
329 92 storres
                                polExpStr = spo_expression_as_string(iPower,
330 77 storres
                                                                     innerTpower,
331 77 storres
                                                                     0,
332 77 storres
                                                                     alpha)
333 77 storres
                            currentExpression = \
334 91 storres
                                    i^(iPower) * t^(innerTpower) * nAtAlpha
335 87 storres
                            currentPolynomial = pRing(currentExpression)
336 92 storres
                            polynomialsList.append(polExpStr)
337 77 storres
                            pMonomials = currentPolynomial.monomials()
338 77 storres
                            pCoefficients = currentPolynomial.coefficients()
339 83 storres
                            spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
340 77 storres
                                                                pCoefficients,
341 77 storres
                                                                knownMonomials,
342 77 storres
                                                                protoMatrixRows,
343 77 storres
                                                                columnsWidth)
344 77 storres
                            iPower += pIdegree
345 77 storres
                        # End for innerTpower
346 77 storres
                    # End of if iShift > 0
347 78 storres
                    # When iShift == 0, just after each of the
348 78 storres
                    # p^pPower * N^(alpha-pPower) polynomials has
349 78 storres
                    # been introduced (followed by a string of
350 78 storres
                    # i^k * p^pPower * N^(alpha-pPower) polynomials) a
351 78 storres
                    # t^l *  p^pPower * N^(alpha-pPower) is introduced here.
352 78 storres
                    #
353 77 storres
                    # Eventually, the following section introduces the
354 77 storres
                    # i^iShift * t^outerTpower * p^iPower * N^(alpha-iPower)
355 77 storres
                    # polynomials.
356 77 storres
                    if columnsWidth != 0:
357 92 storres
                        polExpStr = spo_expression_as_string(iShift,
358 77 storres
                                                             outerTpower,
359 77 storres
                                                             pPower,
360 77 storres
                                                             alpha)
361 92 storres
                        print "->", polExpStr
362 77 storres
                    currentExpression = i^iShift * t^outerTpower * nAtPower
363 87 storres
                    currentPolynomial = pRing(currentExpression) * polynomialAtPower
364 92 storres
                    polynomialsList.append(polExpStr)
365 77 storres
                    pMonomials = currentPolynomial.monomials()
366 77 storres
                    pCoefficients = currentPolynomial.coefficients()
367 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
368 83 storres
                                                            pCoefficients,
369 83 storres
                                                            knownMonomials,
370 83 storres
                                                            protoMatrixRows,
371 83 storres
                                                            columnsWidth)
372 77 storres
                # End for outerTpower
373 77 storres
                #print "++++++++++"
374 77 storres
            # End for iShift
375 77 storres
        polynomialAtPower *= p
376 77 storres
        nAtPower /= N
377 77 storres
    # End for pPower loop
378 92 storres
    return ((protoMatrixRows, knownMonomials, polynomialsList))
379 83 storres
# End spo_polynomial_to_proto_matrix
380 81 storres
381 90 storres
def spo_proto_to_column_matrix(protoMatrixColumns, \
382 90 storres
                               knownMonomialsList, \
383 90 storres
                               boundVar1, \
384 90 storres
                               boundVar2):
385 83 storres
    """
386 87 storres
    Create a column (each row holds the coefficients of one monomial) matrix.
387 83 storres
388 83 storres
    Parameters
389 83 storres
    ----------
390 87 storres
    protoMatrixColumns: a list of coefficient lists.
391 83 storres
    """
392 87 storres
    numColumns = len(protoMatrixColumns)
393 87 storres
    if numColumns == 0:
394 83 storres
        return None
395 87 storres
    # The last column holds has the maximum length.
396 87 storres
    numRows = len(protoMatrixColumns[numColumns-1])
397 83 storres
    if numColumns == 0:
398 83 storres
        return None
399 83 storres
    baseMatrix = matrix(ZZ, numRows, numColumns)
400 87 storres
    for colIndex in xrange(0, numColumns):
401 87 storres
        for rowIndex in xrange(0, len(protoMatrixColumns[colIndex])):
402 90 storres
            if protoMatrixColumns[colIndex][rowIndex] != 0:
403 90 storres
                baseMatrix[rowIndex, colIndex] = \
404 90 storres
                    protoMatrixColumns[colIndex][rowIndex] * \
405 90 storres
                    knownMonomialsList[rowIndex](boundVar1, boundVar2)
406 83 storres
    return baseMatrix
407 83 storres
# End spo_proto_to_column_matrix.
408 83 storres
#
409 88 storres
def spo_proto_to_row_matrix(protoMatrixRows, \
410 88 storres
                            knownMonomialsList, \
411 88 storres
                            boundVar1, \
412 88 storres
                            boundVar2):
413 83 storres
    """
414 90 storres
    Create a row (each column holds the evaluation one monomial at boundVar1 and
415 90 storres
    boundVar2 values) matrix.
416 83 storres
417 83 storres
    Parameters
418 83 storres
    ----------
419 83 storres
    protoMatrixRows: a list of coefficient lists.
420 83 storres
    """
421 83 storres
    numRows = len(protoMatrixRows)
422 83 storres
    if numRows == 0:
423 83 storres
        return None
424 91 storres
    # The last row is the longest one.
425 83 storres
    numColumns = len(protoMatrixRows[numRows-1])
426 83 storres
    if numColumns == 0:
427 83 storres
        return None
428 83 storres
    baseMatrix = matrix(ZZ, numRows, numColumns)
429 83 storres
    for rowIndex in xrange(0, numRows):
430 83 storres
        for colIndex in xrange(0, len(protoMatrixRows[rowIndex])):
431 89 storres
            if protoMatrixRows[rowIndex][colIndex] !=  0:
432 89 storres
                baseMatrix[rowIndex, colIndex] = \
433 89 storres
                    protoMatrixRows[rowIndex][colIndex] * \
434 89 storres
                    knownMonomialsList[colIndex](boundVar1,boundVar2)
435 89 storres
            #print rowIndex, colIndex,
436 89 storres
            #print protoMatrixRows[rowIndex][colIndex],
437 89 storres
            #print knownMonomialsList[colIndex](boundVar1,boundVar2)
438 83 storres
    return baseMatrix
439 83 storres
# End spo_proto_to_row_matrix.
440 83 storres
#
441 87 storres
print "\t...sagePolynomialOperations loaded"