Révision 228
pobysoPythonSage/src/pobyso.py (revision 228) | ||
---|---|---|
375 | 375 |
if precSa is None: |
376 | 376 |
precSa = polySa.parent().base_ring().precision() |
377 | 377 |
if (precSa > initialSollyaPrecSa): |
378 |
assert precSa >= 2, "Precision change <2 requested" |
|
378 | 379 |
if precSa <= 2: |
379 | 380 |
print inspect.stack()[0][3], ": precision change <= 2 requested" |
380 | 381 |
precSo = pobyso_constant_from_int(precSa) |
... | ... | |
1548 | 1549 |
debug=False): |
1549 | 1550 |
if debug: |
1550 | 1551 |
print "Input arguments:" |
1551 |
print "Polynomia:l", ; pobyso_autoprint(polySo)
|
|
1552 |
print "Function:", ; pobyso_autoprint(funcSo) |
|
1553 |
print "Internal precision:", ; pobyso_autoprint(precSo) |
|
1554 |
print "Interval:", ; pobyso_autoprint(intervalSo) |
|
1555 |
print "Current approximation error:", ; pobyso_autoprint(currentApproxErrorSo) |
|
1556 |
print "Requested approxiation error:", ; pobyso_autoprint(approxAccurSo) |
|
1552 |
print "Polynomial: ", ; pobyso_autoprint(polySo)
|
|
1553 |
print "Function: ", ; pobyso_autoprint(funcSo)
|
|
1554 |
print "Internal precision: ", ; pobyso_autoprint(precSo)
|
|
1555 |
print "Interval: ", ; pobyso_autoprint(intervalSo)
|
|
1556 |
print "Current approximation error: ", ; pobyso_autoprint(currentApproxErrorSo)
|
|
1557 |
print "Requested approxiation error: ", ; pobyso_autoprint(approxAccurSo)
|
|
1557 | 1558 |
print "________________" |
1558 | 1559 |
approxAccurSa = pobyso_get_constant_as_rn_so_sa(approxAccurSo) |
1559 | 1560 |
currentApproxErrorSa = pobyso_get_constant_as_rn_so_sa(currentApproxErrorSo) |
... | ... | |
1565 | 1566 |
intervalSa = pobyso_range_to_interval_so_sa(intervalSo) |
1566 | 1567 |
|
1567 | 1568 |
if debug: |
1568 |
print "degreeSa :", degreeSa |
|
1569 |
print "intervalSa:", intervalSa.str(style='brackets') |
|
1569 |
print "degreeSa :", degreeSa
|
|
1570 |
print "intervalSa :", intervalSa.str(style='brackets')
|
|
1570 | 1571 |
print "currentApproxErrorSa :", currentApproxErrorSa |
1571 |
print "approxAccurSa :", approxAccurSa |
|
1572 |
print "approxAccurSa :", approxAccurSa
|
|
1572 | 1573 |
### Start with a 0 value expression. |
1573 | 1574 |
radiusSa = intervalSa.absolute_diameter() / 2 |
1574 | 1575 |
if debug: |
... | ... | |
1587 | 1588 |
else: |
1588 | 1589 |
roundingPowerSa = \ |
1589 | 1590 |
floor(((currentRadiusPowerSa/roundedPolyApproxAccurSa)*(degreeSa+1)).log2()) |
1591 |
## Under extreme conditions the above formulas can evaluate under 2, which is the |
|
1592 |
# minimal precision of an MPFR number. |
|
1593 |
if roundingPowerSa < 2: |
|
1594 |
roundingPowerSa = 2 |
|
1590 | 1595 |
if debug: |
1591 | 1596 |
print "roundedPolyApproxAccurSa", roundedPolyApproxAccurSa |
1592 | 1597 |
print "currentRadiusPowerSa", currentRadiusPowerSa |
... | ... | |
1701 | 1706 |
errorTypeIsNone = False |
1702 | 1707 |
# |
1703 | 1708 |
if accuracySo is None: |
1704 |
# Notice the **! |
|
1709 |
# Notice the **: we are in Pythonland!
|
|
1705 | 1710 |
accuracySo = pobyso_constant_sa_so(RR(2**(-40))) |
1706 | 1711 |
accuracyIsNone = True |
1707 | 1712 |
else: |
pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage (revision 228) | ||
---|---|---|
3127 | 3127 |
slz_interval_and_polynomial_to_sage((prceSo[0], prceSo[0], |
3128 | 3128 |
prceSo[1], prceSo[2], |
3129 | 3129 |
prceSo[3])) |
3130 |
print "Sage Taylor polynomial:", floatP, floatP.parent() |
|
3131 |
floatPcoeffs = floatP.coefficients() |
|
3132 |
for coeff in floatPcoeffs: |
|
3133 |
print coeff.n(prec=coeff.parent().prec()).str(base=2) |
|
3134 |
print coeff.n(prec=coeff.parent().prec()) |
|
3130 | 3135 |
intvl = RRIF(intvl) |
3131 | 3136 |
## Clean-up Sollya stuff. |
3132 | 3137 |
for elem in prceSo: |
... | ... | |
3218 | 3223 |
print "Least common multiple:", leastCommonMultiple |
3219 | 3224 |
basisConstructionsFullTime += cputime(basisConstructionTime) |
3220 | 3225 |
basisConstructionsCount += 1 |
3221 |
""" |
|
3226 |
|
|
3222 | 3227 |
#### Compute the matrix to reduce. |
3223 | 3228 |
matrixToReduce = slz_compute_initial_lattice_matrix(intIntP, |
3224 | 3229 |
alpha, |
3225 | 3230 |
N, |
3226 | 3231 |
iBound, |
3227 |
tBound) |
|
3232 |
tBound, |
|
3233 |
True) |
|
3228 | 3234 |
matrixFile = file('/tmp/matrixToReduce.txt', 'w') |
3229 | 3235 |
for row in matrixToReduce.rows(): |
3230 | 3236 |
matrixFile.write(str(row) + "\n") |
3231 | 3237 |
matrixFile.close() |
3232 |
raise Exception("Deliberate stop here.") |
|
3233 |
""" |
|
3238 |
#raise Exception("Deliberate stop here.")
|
|
3239 |
|
|
3234 | 3240 |
reductionTime = cputime() |
3235 | 3241 |
#### Compute the reduced polynomials. |
3236 | 3242 |
ccReducedPolynomialsList = \ |
pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 228) | ||
---|---|---|
359 | 359 |
alpha, |
360 | 360 |
N, |
361 | 361 |
iBound, |
362 |
tBound): |
|
362 |
tBound, |
|
363 |
debug = False): |
|
363 | 364 |
""" |
364 | 365 |
For a given set of arguments (see below), compute the initial lattice |
365 | 366 |
that could be reduced. |
... | ... | |
407 | 408 |
protoMatrix, |
408 | 409 |
0) |
409 | 410 |
matrixToReduce = spo_proto_to_row_matrix(protoMatrix) |
411 |
if debug: |
|
412 |
print "Initial basis polynomials" |
|
413 |
for poly in polynomialsList: |
|
414 |
print poly |
|
410 | 415 |
return matrixToReduce |
411 | 416 |
# End slz_compute_initial_lattice_matrix. |
412 | 417 |
|
... | ... | |
866 | 871 |
- the center of the interval; |
867 | 872 |
- the maximum error in the approximation of the input functionSo by the |
868 | 873 |
output polynomial ; this error <= approxAccurSaS. |
869 |
Changes fom v1: |
|
874 |
Changes fom v 01:
|
|
870 | 875 |
extra verbose. |
871 | 876 |
""" |
872 | 877 |
print"In slz_compute_polynomial_and_interval..." |
... | ... | |
974 | 979 |
print "maxPrecSo: ", ; pobyso_autoprint(maxPrecSo) |
975 | 980 |
print "approxAccurSo: ", ; pobyso_autoprint(approxAccurSo) |
976 | 981 |
(roundedPolySo, roundedPolyMaxErrSo) = \ |
977 |
pobyso_polynomial_coefficients_progressive_round_so_so(polySo,
|
|
978 |
functionSo,
|
|
979 |
intervalCenterSo,
|
|
980 |
currentRangeSo,
|
|
981 |
itpSo,
|
|
982 |
ftpSo,
|
|
983 |
maxPrecSo,
|
|
984 |
approxAccurSo)
|
|
982 |
pobyso_round_coefficients_progressive_so_so(polySo,
|
|
983 |
functionSo, |
|
984 |
maxPrecSo,
|
|
985 |
currentRangeSo, |
|
986 |
intervalCenterSo,
|
|
987 |
maxErrorSo,
|
|
988 |
approxAccurSo,
|
|
989 |
debug = True)
|
|
985 | 990 |
|
986 | 991 |
sollya_lib_clear_obj(polySo) |
987 | 992 |
sollya_lib_clear_obj(maxErrorSo) |
Formats disponibles : Unified diff