Révision 278
pobysoPythonSage/src/pobyso.py (revision 278) | ||
---|---|---|
1791 | 1791 |
# |
1792 | 1792 |
## Tranform the Sage list of exponents into a Sollya list. |
1793 | 1793 |
exponentsListSo = pobyso_build_list_of_ints_sa_so(*exponentsList) |
1794 |
remezPolySo = sollya_lib_remez(functionSo, \ |
|
1794 |
remezPolySo = sollya_lib_remez(functionSo, \
|
|
1795 | 1795 |
exponentsListSo, \ |
1796 |
rangeSo, \ |
|
1797 |
weightSo, \ |
|
1798 |
qualitySo, \ |
|
1796 |
rangeSo, \
|
|
1797 |
weightSo, \
|
|
1798 |
qualitySo, \
|
|
1799 | 1799 |
None) |
1800 | 1800 |
sollya_lib_clear_obj(functionSo) |
1801 | 1801 |
sollya_lib_clear_obj(exponentsListSo) |
... | ... | |
1843 | 1843 |
# the former as inutile after call. |
1844 | 1844 |
return (sollya_lib_copy_obj(polySo), |
1845 | 1845 |
sollya_lib_copy_obj(currentApproxErrorSo)) |
1846 |
# |
|
1847 |
## Try to round the coefficients. |
|
1846 | 1848 |
degreeSa = pobyso_polynomial_degree_so_sa(polySo) |
1847 | 1849 |
intervalSa = pobyso_range_to_interval_so_sa(intervalSo) |
1848 | 1850 |
|
... | ... | |
1913 | 1915 |
# never happen since the rounding algorithm is proved. But some |
1914 | 1916 |
# circumstances may break it (e.g. internal precision of tools). |
1915 | 1917 |
if cerrSa > approxAccurSa: |
1916 |
if iterIndex > 0: # Round 1 and beyond.
|
|
1918 |
if iterIndex == 0: # Round 0 is agressive rounding, got round 1 (proved rounding)
|
|
1917 | 1919 |
sollya_lib_clear_obj(resPolySo) |
1918 | 1920 |
sollya_lib_clear_obj(infNormSo) |
1921 |
iterIndex += 1 |
|
1922 |
continue |
|
1923 |
else: # Round 1 and beyond : just return the oroginal polynomial. |
|
1924 |
sollya_lib_clear_obj(resPolySo) |
|
1925 |
sollya_lib_clear_obj(infNormSo) |
|
1919 | 1926 |
#### Do not return the arguments but copies: the caller may free |
1920 | 1927 |
# free the former as inutile after call. |
1921 | 1928 |
return (sollya_lib_copy_obj(polySo), |
1922 | 1929 |
sollya_lib_copy_obj(currentApproxErrorSo)) |
1923 |
else: # Round 0 (agressive rounding), got round 1 (proved rounding) |
|
1924 |
sollya_lib_clear_obj(resPolySo) |
|
1925 |
sollya_lib_clear_obj(infNormSo) |
|
1926 |
iterIndex += 1 |
|
1927 |
continue |
|
1928 | 1930 |
### If get here it is because cerrSa <= approxAccurSa |
1929 | 1931 |
### Approximation error of the new polynomial is acceptable. |
1930 | 1932 |
return (resPolySo, infNormSo) |
pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 278) | ||
---|---|---|
1495 | 1495 |
currentRangeSo, |
1496 | 1496 |
absoluteErrorTypeSo) |
1497 | 1497 |
maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo) |
1498 |
while maxErrorSa > approxAccurSa: |
|
1498 |
## Expression "approxAccurSa/2" (instead of just approxAccurSa) is added |
|
1499 |
# since we use polynomial shaving. In order for it to work, we must start |
|
1500 |
# with a better accuracy. |
|
1501 |
while maxErrorSa > approxAccurSa/2: |
|
1499 | 1502 |
print "++Approximation error:", maxErrorSa.n() |
1500 | 1503 |
sollya_lib_clear_obj(polySo) |
1501 | 1504 |
sollya_lib_clear_obj(intervalCenterSo) |
... | ... | |
1627 | 1630 |
- the center of the interval; |
1628 | 1631 |
- the maximum error in the approximation of the input functionSo by the |
1629 | 1632 |
output polynomial ; this error <= approxAccurSaS. |
1633 |
|
|
1630 | 1634 |
Changes fom v 01: |
1631 | 1635 |
extra verbose. |
1632 | 1636 |
""" |
... | ... | |
1664 | 1668 |
absoluteErrorTypeSo) |
1665 | 1669 |
maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo) |
1666 | 1670 |
print "...after Taylor expansion." |
1667 |
while maxErrorSa > approxAccurSa: |
|
1671 |
## Expression "approxAccurSa/2" (instead of just approxAccurSa) is added |
|
1672 |
# since we use polynomial shaving. In order for it to work, we must start |
|
1673 |
# with a better accuracy. |
|
1674 |
while maxErrorSa > approxAccurSa/2: |
|
1668 | 1675 |
print "++Approximation error:", maxErrorSa.n() |
1669 | 1676 |
sollya_lib_clear_obj(polySo) |
1670 | 1677 |
sollya_lib_clear_obj(intervalCenterSo) |
Formats disponibles : Unified diff