Statistiques
| Révision :

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

Historique | Voir | Annoter | Télécharger (21,85 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 103 storres
        norm +=  coefficient.abs()^p
144 87 storres
    return pow(norm, 1/p)
145 81 storres
# end spo_norm
146 81 storres
147 100 storres
def spo_polynomial_to_proto_matrix(p, 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 102 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 100 storres
    pRing = p.parent()
164 77 storres
    knownMonomials = []
165 77 storres
    protoMatrixRows = []
166 92 storres
    polynomialsList = []
167 74 storres
    pVariables = p.variables()
168 74 storres
    iVariable = pVariables[0]
169 76 storres
    tVariable = pVariables[1]
170 87 storres
    polynomialAtPower = pRing(1)
171 87 storres
    currentPolynomial = pRing(1)
172 74 storres
    pIdegree = p.degree(pVariables[0])
173 74 storres
    pTdegree = p.degree(pVariables[1])
174 87 storres
    currentIdegree = currentPolynomial.degree(iVariable)
175 74 storres
    nAtPower = N^alpha
176 91 storres
    nAtAlpha = nAtPower
177 92 storres
    polExpStr = ""
178 74 storres
    # We work from p^0 * N^alpha to p^alpha * N^0
179 74 storres
    for pPower in xrange(0, alpha + 1):
180 76 storres
        # pPower == 0 is a special case. We introduce all the monomials but one
181 78 storres
        # in i and those in t necessary to be able to introduce
182 76 storres
        # p. We arbitrary choose to introduce the highest degree monomial in i
183 76 storres
        # with p. We also introduce all the mixed i^k * t^l monomials with
184 77 storres
        # k < p.degree(i) and l <= p.degree(t).
185 78 storres
        # Mixed terms introduction is necessary here before we start "i shifts"
186 78 storres
        # in the next iteration.
187 74 storres
        if pPower == 0:
188 78 storres
            # Notice that i^pIdegree is excluded as the bound of the xrange is
189 78 storres
            # pIdegree
190 74 storres
            for iPower in xrange(0, pIdegree):
191 74 storres
                for tPower in xrange(0, pTdegree + 1):
192 77 storres
                    if columnsWidth != 0:
193 92 storres
                        polExpStr = spo_expression_as_string(iPower,
194 76 storres
                                                             tPower,
195 76 storres
                                                             pPower,
196 74 storres
                                                             alpha)
197 92 storres
                        print "->", polExpStr
198 74 storres
                    currentExpression = iVariable^iPower * \
199 91 storres
                                        tVariable^tPower * nAtAlpha
200 78 storres
                    # polynomialAtPower == 1 here. Next line should be commented
201 78 storres
                    # out but it does not work! Some conversion problem?
202 91 storres
                    currentPolynomial = pRing(currentExpression)
203 92 storres
                    polynomialsList.append(polExpStr)
204 74 storres
                    pMonomials = currentPolynomial.monomials()
205 74 storres
                    pCoefficients = currentPolynomial.coefficients()
206 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
207 83 storres
                                                            pCoefficients,
208 83 storres
                                                            knownMonomials,
209 83 storres
                                                            protoMatrixRows,
210 83 storres
                                                            columnsWidth)
211 78 storres
                # End tPower.
212 78 storres
            # End for iPower.
213 77 storres
        else: # pPower > 0: (p^1..p^alpha)
214 78 storres
            # This where we introduce the p^pPower * N^(alpha-pPower)
215 77 storres
            # polynomial.
216 77 storres
            # This step could technically be fused as the first iteration
217 77 storres
            # of the next loop (with iPower starting at 0).
218 77 storres
            # We set it apart for clarity.
219 77 storres
            if columnsWidth != 0:
220 92 storres
                polExpStr = spo_expression_as_string(0, 0, pPower, alpha)
221 92 storres
                print "->", polExpStr
222 77 storres
            currentPolynomial = polynomialAtPower * nAtPower
223 92 storres
            polynomialsList.append(polExpStr)
224 77 storres
            pMonomials = currentPolynomial.monomials()
225 77 storres
            pCoefficients = currentPolynomial.coefficients()
226 83 storres
            spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
227 83 storres
                                                    pCoefficients,
228 83 storres
                                                    knownMonomials,
229 83 storres
                                                    protoMatrixRows,
230 83 storres
                                                    columnsWidth)
231 77 storres
232 77 storres
            # The i^iPower * p^pPower polynomials: they add i^k monomials to
233 77 storres
            # p^pPower up to k < pIdegree * pPower. This only introduces i^k
234 77 storres
            # monomials since mixed terms (that were introduced at a previous
235 77 storres
            # stage) are only shifted to already existing
236 77 storres
            # ones. p^pPower is "shifted" to higher degrees in i as far as
237 77 storres
            # possible, one step short of the degree in i of p^(pPower+1) .
238 77 storres
            # These "pure" i^k monomials can only show up with i multiplications.
239 77 storres
            for iPower in xrange(1, pIdegree):
240 87 storres
                if columnsWidth != 0:
241 92 storres
                    polExpStr = spo_expression_as_string(iPower, \
242 87 storres
                                                         0,      \
243 87 storres
                                                         pPower, \
244 87 storres
                                                         alpha)
245 92 storres
                    print "->", polExpStr
246 77 storres
                currentExpression = i^iPower * nAtPower
247 87 storres
                currentPolynomial = pRing(currentExpression) * polynomialAtPower
248 92 storres
                polynomialsList.append(polExpStr)
249 77 storres
                pMonomials = currentPolynomial.monomials()
250 77 storres
                pCoefficients = currentPolynomial.coefficients()
251 87 storres
                spo_add_polynomial_coeffs_to_matrix_row(pMonomials,      \
252 87 storres
                                                        pCoefficients,   \
253 87 storres
                                                        knownMonomials,  \
254 87 storres
                                                        protoMatrixRows, \
255 83 storres
                                                        columnsWidth)
256 77 storres
            # End for iPower
257 77 storres
            # We want now to introduce a t * p^pPower polynomial. But before
258 77 storres
            # that we must introduce some mixed monomials.
259 77 storres
            # This loop is no triggered before pPower == 2.
260 78 storres
            # It introduces a first set of high i degree mixed monomials.
261 77 storres
            for iPower in xrange(1, pPower):
262 77 storres
                tPower = pPower - iPower + 1
263 77 storres
                if columnsWidth != 0:
264 92 storres
                    polExpStr = spo_expression_as_string(iPower * pIdegree,
265 77 storres
                                                         tPower,
266 77 storres
                                                         0,
267 77 storres
                                                         alpha)
268 92 storres
                    print "->", polExpStr
269 91 storres
                currentExpression = i^(iPower * pIdegree) * t^tPower * nAtAlpha
270 87 storres
                currentPolynomial = pRing(currentExpression)
271 92 storres
                polynomialsList.append(polExpStr)
272 77 storres
                pMonomials = currentPolynomial.monomials()
273 77 storres
                pCoefficients = currentPolynomial.coefficients()
274 83 storres
                spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
275 83 storres
                                                        pCoefficients,
276 83 storres
                                                        knownMonomials,
277 83 storres
                                                        protoMatrixRows,
278 83 storres
                                                        columnsWidth)
279 77 storres
            # End for iPower
280 78 storres
            #
281 78 storres
            # This is the mixed monomials main loop. It introduces:
282 77 storres
            # - the missing mixed monomials needed before the
283 78 storres
            #   t^l * p^pPower * N^(alpha-pPower) polynomial;
284 78 storres
            # - the t^l * p^pPower * N^(alpha-pPower) itself;
285 78 storres
            # - for each of i^k * t^l * p^pPower * N^(alpha-pPower) polynomials:
286 78 storres
            #   - the the missing mixed monomials needed  polynomials,
287 78 storres
            #   - the i^k * t^l * p^pPower * N^(alpha-pPower) itself.
288 78 storres
            # The t^l * p^pPower * N^(alpha-pPower) is introduced when
289 78 storres
            #
290 77 storres
            for iShift in xrange(0, pIdegree):
291 77 storres
                # When pTdegree == 1, the following loop only introduces
292 77 storres
                # a single new monomial.
293 77 storres
                #print "++++++++++"
294 77 storres
                for outerTpower in xrange(1, pTdegree + 1):
295 77 storres
                    # First one high i degree mixed monomial.
296 77 storres
                    iPower = iShift + pPower * pIdegree
297 77 storres
                    if columnsWidth != 0:
298 92 storres
                        polExpStr = spo_expression_as_string(iPower,
299 77 storres
                                                             outerTpower,
300 77 storres
                                                             0,
301 77 storres
                                                             alpha)
302 92 storres
                        print "->", polExpStr
303 91 storres
                    currentExpression = i^iPower * t^outerTpower * nAtAlpha
304 87 storres
                    currentPolynomial = pRing(currentExpression)
305 92 storres
                    polynomialsList.append(polExpStr)
306 77 storres
                    pMonomials = currentPolynomial.monomials()
307 77 storres
                    pCoefficients = currentPolynomial.coefficients()
308 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
309 83 storres
                                                            pCoefficients,
310 83 storres
                                                            knownMonomials,
311 83 storres
                                                            protoMatrixRows,
312 83 storres
                                                            columnsWidth)
313 77 storres
                    #print "+++++"
314 78 storres
                    # At iShift == 0, the following innerTpower loop adds
315 78 storres
                    # duplicate monomials, since no extra i^l * t^k is needed
316 78 storres
                    # before introducing the
317 77 storres
                    # i^iShift * t^outerPpower * p^pPower * N^(alpha-pPower)
318 77 storres
                    # polynomial.
319 77 storres
                    # It introduces smaller i degree monomials than the
320 77 storres
                    # one(s) added previously (no pPower multiplication).
321 77 storres
                    # Here the exponent of t decreases as that of i increases.
322 78 storres
                    # This conditional is not entered before pPower == 1.
323 78 storres
                    # The innerTpower loop does not produce anything before
324 78 storres
                    # pPower == 2. We keep it anyway for other configuration of
325 78 storres
                    # p.
326 77 storres
                    if iShift > 0:
327 77 storres
                        iPower = pIdegree + iShift
328 77 storres
                        for innerTpower in xrange(pPower, 1, -1):
329 77 storres
                            if columnsWidth != 0:
330 92 storres
                                polExpStr = spo_expression_as_string(iPower,
331 77 storres
                                                                     innerTpower,
332 77 storres
                                                                     0,
333 77 storres
                                                                     alpha)
334 77 storres
                            currentExpression = \
335 91 storres
                                    i^(iPower) * t^(innerTpower) * nAtAlpha
336 87 storres
                            currentPolynomial = pRing(currentExpression)
337 92 storres
                            polynomialsList.append(polExpStr)
338 77 storres
                            pMonomials = currentPolynomial.monomials()
339 77 storres
                            pCoefficients = currentPolynomial.coefficients()
340 83 storres
                            spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
341 77 storres
                                                                pCoefficients,
342 77 storres
                                                                knownMonomials,
343 77 storres
                                                                protoMatrixRows,
344 77 storres
                                                                columnsWidth)
345 77 storres
                            iPower += pIdegree
346 77 storres
                        # End for innerTpower
347 77 storres
                    # End of if iShift > 0
348 78 storres
                    # When iShift == 0, just after each of the
349 78 storres
                    # p^pPower * N^(alpha-pPower) polynomials has
350 78 storres
                    # been introduced (followed by a string of
351 78 storres
                    # i^k * p^pPower * N^(alpha-pPower) polynomials) a
352 78 storres
                    # t^l *  p^pPower * N^(alpha-pPower) is introduced here.
353 78 storres
                    #
354 77 storres
                    # Eventually, the following section introduces the
355 77 storres
                    # i^iShift * t^outerTpower * p^iPower * N^(alpha-iPower)
356 77 storres
                    # polynomials.
357 77 storres
                    if columnsWidth != 0:
358 92 storres
                        polExpStr = spo_expression_as_string(iShift,
359 77 storres
                                                             outerTpower,
360 77 storres
                                                             pPower,
361 77 storres
                                                             alpha)
362 92 storres
                        print "->", polExpStr
363 77 storres
                    currentExpression = i^iShift * t^outerTpower * nAtPower
364 87 storres
                    currentPolynomial = pRing(currentExpression) * polynomialAtPower
365 92 storres
                    polynomialsList.append(polExpStr)
366 77 storres
                    pMonomials = currentPolynomial.monomials()
367 77 storres
                    pCoefficients = currentPolynomial.coefficients()
368 83 storres
                    spo_add_polynomial_coeffs_to_matrix_row(pMonomials,
369 83 storres
                                                            pCoefficients,
370 83 storres
                                                            knownMonomials,
371 83 storres
                                                            protoMatrixRows,
372 83 storres
                                                            columnsWidth)
373 77 storres
                # End for outerTpower
374 77 storres
                #print "++++++++++"
375 77 storres
            # End for iShift
376 77 storres
        polynomialAtPower *= p
377 77 storres
        nAtPower /= N
378 77 storres
    # End for pPower loop
379 92 storres
    return ((protoMatrixRows, knownMonomials, polynomialsList))
380 83 storres
# End spo_polynomial_to_proto_matrix
381 81 storres
382 90 storres
def spo_proto_to_column_matrix(protoMatrixColumns, \
383 90 storres
                               knownMonomialsList, \
384 90 storres
                               boundVar1, \
385 90 storres
                               boundVar2):
386 83 storres
    """
387 87 storres
    Create a column (each row holds the coefficients of one monomial) matrix.
388 83 storres
389 83 storres
    Parameters
390 83 storres
    ----------
391 87 storres
    protoMatrixColumns: a list of coefficient lists.
392 83 storres
    """
393 87 storres
    numColumns = len(protoMatrixColumns)
394 87 storres
    if numColumns == 0:
395 83 storres
        return None
396 87 storres
    # The last column holds has the maximum length.
397 87 storres
    numRows = len(protoMatrixColumns[numColumns-1])
398 83 storres
    if numColumns == 0:
399 83 storres
        return None
400 83 storres
    baseMatrix = matrix(ZZ, numRows, numColumns)
401 87 storres
    for colIndex in xrange(0, numColumns):
402 87 storres
        for rowIndex in xrange(0, len(protoMatrixColumns[colIndex])):
403 90 storres
            if protoMatrixColumns[colIndex][rowIndex] != 0:
404 90 storres
                baseMatrix[rowIndex, colIndex] = \
405 90 storres
                    protoMatrixColumns[colIndex][rowIndex] * \
406 90 storres
                    knownMonomialsList[rowIndex](boundVar1, boundVar2)
407 83 storres
    return baseMatrix
408 83 storres
# End spo_proto_to_column_matrix.
409 83 storres
#
410 88 storres
def spo_proto_to_row_matrix(protoMatrixRows, \
411 88 storres
                            knownMonomialsList, \
412 88 storres
                            boundVar1, \
413 88 storres
                            boundVar2):
414 83 storres
    """
415 90 storres
    Create a row (each column holds the evaluation one monomial at boundVar1 and
416 90 storres
    boundVar2 values) matrix.
417 83 storres
418 83 storres
    Parameters
419 83 storres
    ----------
420 83 storres
    protoMatrixRows: a list of coefficient lists.
421 83 storres
    """
422 83 storres
    numRows = len(protoMatrixRows)
423 83 storres
    if numRows == 0:
424 83 storres
        return None
425 91 storres
    # The last row is the longest one.
426 83 storres
    numColumns = len(protoMatrixRows[numRows-1])
427 83 storres
    if numColumns == 0:
428 83 storres
        return None
429 83 storres
    baseMatrix = matrix(ZZ, numRows, numColumns)
430 83 storres
    for rowIndex in xrange(0, numRows):
431 83 storres
        for colIndex in xrange(0, len(protoMatrixRows[rowIndex])):
432 89 storres
            if protoMatrixRows[rowIndex][colIndex] !=  0:
433 89 storres
                baseMatrix[rowIndex, colIndex] = \
434 89 storres
                    protoMatrixRows[rowIndex][colIndex] * \
435 89 storres
                    knownMonomialsList[colIndex](boundVar1,boundVar2)
436 89 storres
            #print rowIndex, colIndex,
437 89 storres
            #print protoMatrixRows[rowIndex][colIndex],
438 89 storres
            #print knownMonomialsList[colIndex](boundVar1,boundVar2)
439 83 storres
    return baseMatrix
440 83 storres
# End spo_proto_to_row_matrix.
441 83 storres
#
442 87 storres
print "\t...sagePolynomialOperations loaded"