Révision 3296902f src/functions_for_cvp.sage
b/src/functions_for_cvp.sage | ||
---|---|---|
692 | 692 |
#print "Real field:", realField |
693 | 693 |
## Compute the Sollya version of the function. |
694 | 694 |
funcAsStringSa = funcSa._assume_str().replace("_SAGE_VAR_","",100) |
695 |
#print "cpefa:", funcAsStringSa |
|
695 | 696 |
funcSo = pobyso_parse_string(funcAsStringSa) |
696 | 697 |
if pobyso_is_error_so_sa(funcSo): |
697 | 698 |
pobyso_clear_obj(funcSo) |
698 | 699 |
return None |
700 |
#print "cpefa: function conversion OK." |
|
699 | 701 |
## Compute the Sollya version of the polynomial. |
700 | 702 |
## The conversion is made from a floating-point coefficients polynomial. |
701 | 703 |
try: |
... | ... | |
708 | 710 |
pobyso_clear_obj(funcSo) |
709 | 711 |
pobyso_clear_obj(polySo) |
710 | 712 |
return None |
713 |
#print "cpefa: polynomial conversion to Sollya OK." |
|
711 | 714 |
## Copy both funcSo and polySo as they are needed later for the infnorm.. |
712 |
errorFuncSo = sollya_lib_build_function_sub(sollya_lib_copy_obj(funcSo), |
|
713 |
sollya_lib_copy_obj(polySo)) |
|
715 |
errorFuncSo = \ |
|
716 |
sollya_lib_build_function_sub(sollya_lib_copy_obj(funcSo), |
|
717 |
sollya_lib_copy_obj(polySo)) |
|
714 | 718 |
if pobyso_is_error_so_sa(errorFuncSo): |
715 | 719 |
pobyso_clear_obj(errorFuncSo) |
716 | 720 |
return None |
721 |
#print "cpefa: error function in Sollya OK." |
|
717 | 722 |
## Compute the derivative. |
718 | 723 |
diffErrorFuncSo = pobyso_diff_so_so(errorFuncSo) |
719 | 724 |
pobyso_clear_obj(errorFuncSo) |
720 | 725 |
if pobyso_is_error_so_sa(diffErrorFuncSo): |
721 | 726 |
pobyso_clear_obj(diffErrorFuncSo) |
722 | 727 |
return None |
728 |
#print "cpefa: polynomial conversion to Sollya OK." |
|
729 |
#print "cpefa: error function derivative in Sollya OK." |
|
723 | 730 |
## Compute the interval. |
724 | 731 |
intervalSo = pobyso_range_from_bounds_sa_so(lowerBound, upperBound) |
725 | 732 |
if pobyso_is_error_so_sa(intervalSo): |
... | ... | |
734 | 741 |
pobyso_clear_obj(polySo) |
735 | 742 |
pobyso_clear_obj(funcSo) |
736 | 743 |
## Compute the zeros of the derivative. |
737 |
errorFuncMaxisSo = pobyso_dirty_find_zeros_so_so(diffErrorFuncSo, intervalSo) |
|
738 |
pobyso_clear_obj(diffErrorFuncSo) |
|
739 |
pobyso_clear_obj(intervalSo) |
|
744 |
### Give it a first try with dirtyfindzeros but it may |
|
745 |
# fail. |
|
746 |
errorFuncMaxisSo = pobyso_dirty_find_zeros_so_so(diffErrorFuncSo, |
|
747 |
intervalSo) |
|
740 | 748 |
if pobyso_is_error_so_sa(errorFuncMaxisSo): |
749 |
pobyso_clear_obj(diffErrorFuncSo) |
|
750 |
pobyso_clear_obj(intervalSo) |
|
741 | 751 |
pobyso_clear_obj(errorFuncMaxisSo) |
742 | 752 |
return None |
753 |
#print "cpefa: error function maxis in Sollya OK." |
|
743 | 754 |
errorFuncMaxisSa = pobyso_float_list_so_sa(errorFuncMaxisSo) |
744 | 755 |
pobyso_clear_obj(errorFuncMaxisSo) |
756 |
#### If the list is empty try the more sophisticated |
|
757 |
# findzeros. |
|
758 |
if len(errorFuncMaxisSa) == 0: |
|
759 |
errorFuncMaxisSo = \ |
|
760 |
pobyso_find_zeros_so_so(diffErrorFuncSo, |
|
761 |
intervalSo) |
|
762 |
if pobyso_is_error_so_sa(errorFuncMaxisSo): |
|
763 |
pobyso_clear_obj(diffErrorFuncSo) |
|
764 |
pobyso_clear_obj(intervalSo) |
|
765 |
pobyso_clear_obj(errorFuncMaxisSo) |
|
766 |
return None |
|
767 |
#print "cpefa: error function maxis in Sollya OK." |
|
768 |
#print "cpefa:", ; pobyso_autoprint(errorFuncMaxisSo) |
|
769 |
##### The findzeros functions returns intervals (ranges). |
|
770 |
errorFuncRangeMaxisSa = pobyso_range_list_so_sa(errorFuncMaxisSo) |
|
771 |
pobyso_clear_obj(errorFuncMaxisSo) |
|
772 |
errorFuncMaxisSa = [] |
|
773 |
for interval in errorFuncRangeMaxisSa: |
|
774 |
errorFuncMaxisSa.append(interval.center()) |
|
775 |
pobyso_clear_obj(diffErrorFuncSo) |
|
776 |
pobyso_clear_obj(intervalSo) |
|
745 | 777 |
## If required, convert the numbers to rational numbers. |
778 |
#print "cpefa - errorFuncMaxisSa:", errorFuncMaxisSa |
|
746 | 779 |
if not contFracMaxErr is None: |
747 | 780 |
for index in xrange(0, len(errorFuncMaxisSa)): |
748 | 781 |
errorFuncMaxisSa[index] = \ |
Formats disponibles : Unified diff