Révision 94
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 94) | ||
---|---|---|
127 | 127 |
norm = coefficientAbs |
128 | 128 |
return norm |
129 | 129 |
# TODO: check here the value of p |
130 |
# p must be an integer. |
|
131 |
if int(p) != p: |
|
132 |
return None |
|
133 |
# p must be >= 1. |
|
134 |
if p < 1: |
|
135 |
return None |
|
130 | 136 |
# For 1 norm. |
131 | 137 |
if p == 1: |
132 | 138 |
for coefficient in poly.coefficients(): |
pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage (revision 94) | ||
---|---|---|
68 | 68 |
return True |
69 | 69 |
# End smo_is_upper_triangular_matrix |
70 | 70 |
|
71 |
def smo_max_non_null_abs(mat): |
|
72 |
""" |
|
73 |
Compute the maximum absolute value of the matrix elements. |
|
74 |
""" |
|
75 |
maxNonNull = -Infinity |
|
76 |
mlist = mat._list() |
|
77 |
for i in mlist: |
|
78 |
if i != 0 and i.abs() > maxNonNull : |
|
79 |
maxNonNull = i.abs() |
|
80 |
return maxNonNull |
|
81 |
# End smo_min_non_null_abs |
|
82 |
|
|
83 |
# |
|
84 |
|
|
85 |
def smo_min_non_null_abs(mat): |
|
86 |
""" |
|
87 |
Compute the minimum absolute value of the matrix elements. |
|
88 |
""" |
|
89 |
minNonNull = Infinity |
|
90 |
mlist = mat._list() |
|
91 |
for i in mlist: |
|
92 |
if i != 0 and i.abs() < minNonNull : |
|
93 |
minNonNull = i.abs() |
|
94 |
return minNonNull |
|
95 |
# End smo_min_non_null_abs |
|
71 | 96 |
print "\t...sageMatrixOperations loaded" |
pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 94) | ||
---|---|---|
366 | 366 |
# Coefficients are issued in the increasing power order. |
367 | 367 |
ratPolyCoefficients = ratPolyOfInt.coefficients() |
368 | 368 |
# Print the reversed list for debugging. |
369 |
print ratPolyCoefficients[::-1] |
|
370 |
# Build the list of number we compute the lcmm of.
|
|
369 |
print "Rational polynomial coefficients:", ratPolyCoefficients[::-1]
|
|
370 |
# Build the list of number we compute the lcm of. |
|
371 | 371 |
coefficientDenominators = sro_denominators(ratPolyCoefficients) |
372 | 372 |
coefficientDenominators.append(2^precision) |
373 | 373 |
coefficientDenominators.append(2^(targetHardnessToRound + 1)) |
... | ... | |
380 | 380 |
# Iterate over two lists at the same time, stop when the shorter is |
381 | 381 |
# exhausted. |
382 | 382 |
for numerator, denominator in \ |
383 |
zip(coefficientNumerators, coefficientDenominators):
|
|
383 |
zip(coefficientNumerators, coefficientDenominators): |
|
384 | 384 |
multiplicator = leastCommonMultiple / denominator |
385 | 385 |
newCoefficient = numerator * multiplicator |
386 | 386 |
polynomialExpression += newCoefficient * variable1^power |
Formats disponibles : Unified diff