84 |
84 |
|
85 |
85 |
def pobyso_autoprint_so_so(arg):
|
86 |
86 |
sollya_lib_autoprint(arg,None)
|
|
87 |
|
|
88 |
def pobyso_absolute_so_so():
|
|
89 |
return(sollya_lib_absolute(None))
|
87 |
90 |
|
|
91 |
def pobyso_build_function_sub_so_so(exp1So, exp2So):
|
|
92 |
return(sollya_lib_build_function_sub(exp1So, exp2So))
|
|
93 |
|
88 |
94 |
def pobyso_cmp(rnArg, soCte):
|
|
95 |
"""
|
|
96 |
Compare the MPFR value a RealNumber with that of a Sollya constant.
|
|
97 |
|
|
98 |
Get the value of the Sollya constant into a RealNumber and compare
|
|
99 |
using MPFR. Could be optimized by working directly with a mpfr_t
|
|
100 |
for the intermediate number.
|
|
101 |
"""
|
89 |
102 |
precisionOfCte = c_int(0)
|
90 |
103 |
# From the Sollya constant, create a local Sage RealNumber.
|
91 |
104 |
sollya_lib_get_prec_of_constant(precisionOfCte, soCte)
|
... | ... | |
97 |
110 |
# Compare the local Sage RealNumber with rnArg.
|
98 |
111 |
return(cmp_rn_value(rnArg, rnLocal))
|
99 |
112 |
|
|
113 |
def pobyso_compute_pos_function_abs_val_bounds_sa_sa(funcSa, lowerBoundSa, \
|
|
114 |
upperBoundSa):
|
|
115 |
"""
|
|
116 |
TODO: set the variable name in Sollya.
|
|
117 |
"""
|
|
118 |
funcSo = pobyso_parse_string(funcSa._assume_str())
|
|
119 |
rangeSo = pobyso_range_sa_so(lowerBoundSa, upperBoundSa)
|
|
120 |
infnormSo = pobyso_infnorm_so_so(funcSo,rangeSo)
|
|
121 |
fMaxSa = pobyso_get_interval_from_range_so_sa(infnormSo)
|
|
122 |
# Get the top bound and compute the binade top limit.
|
|
123 |
fMaxUpperBoundSa = fMaxSa.upper()
|
|
124 |
binadeTopLimitSa = 2**ceil(fMaxUpperBoundSa.log2())
|
|
125 |
# Put up together the function to use to compute the lower bound.
|
|
126 |
funcAuxSo = pobyso_parse_string(str(binadeTopLimitSa) + \
|
|
127 |
'-(' + f._assume_str() + ')')
|
|
128 |
pobyso_autoprint(funcAuxSo)
|
|
129 |
# Clear the Sollay range before a new call to infnorm and issue the call.
|
|
130 |
sollya_lib_clear_obj(infnormSo)
|
|
131 |
infnormSo = pobyso_infnorm_so_so(funcAuxSo,rangeSo)
|
|
132 |
fMinSa = pobyso_get_interval_from_range_so_sa(infnormSo)
|
|
133 |
sollya_lib_clear_obj(infnormSo)
|
|
134 |
fMinLowerBoundSa = topBinadeLimit - fMinSa.lower()
|
|
135 |
# Compute the maximum of the precisions of the different bounds.
|
|
136 |
maxPrecSa = max([fMinLowerBoundSa.parent().precision(), \
|
|
137 |
fMaxUpperBoundSa.parent().precision()])
|
|
138 |
# Create a RealIntervalField and create an interval with the "good" bounds.
|
|
139 |
RRRI = RealIntervalField(maxPrecSa)
|
|
140 |
imageIntervalSa = RRRI(fMinLowerBoundSa, fMaxUpperBoundSa)
|
|
141 |
# Free the uneeded Sollya objects
|
|
142 |
sollya_lib_clear_obj(funcSo)
|
|
143 |
sollya_lib_clear_obj(funcAuxSo)
|
|
144 |
sollya_lib_clear_obj(rangeSo)
|
|
145 |
return(imageIntervalSa)
|
|
146 |
# End pobyso_compute_function_abs_val_bounds_sa_sa
|
|
147 |
|
100 |
148 |
def pobyso_constant(rnArg):
|
101 |
149 |
""" Legacy function. See pobyso_constant_sa_so. """
|
102 |
150 |
return(pobyso_constant_sa_so(rnArg))
|
... | ... | |
311 |
359 |
isEndElliptic = c_int(0)
|
312 |
360 |
listAsList = []
|
313 |
361 |
result = sollya_lib_get_list_elements(byref(listAddress),\
|
314 |
|
byref(numElements),\
|
315 |
|
byref(isEndElliptic),\
|
316 |
|
soObj)
|
|
362 |
byref(numElements),\
|
|
363 |
byref(isEndElliptic),\
|
|
364 |
soObj)
|
317 |
365 |
if result == 0 :
|
318 |
366 |
return None
|
319 |
367 |
for i in xrange(0, numElements.value, 1):
|
... | ... | |
481 |
529 |
return(int(prec.value))
|
482 |
530 |
|
483 |
531 |
def pobyso_infnorm_so_so(func, interval, file = None, intervalList = None):
|
484 |
|
return(sollya_lib_infnorm(func, interval, file, intervalList, None))
|
|
532 |
print "Do not use this function. User pobyso_supnorm_so_so instead."
|
|
533 |
return(None)
|
485 |
534 |
|
486 |
535 |
def pobyso_lib_init():
|
487 |
536 |
sollya_lib_init(None)
|
... | ... | |
633 |
682 |
precSo = c_void_p(sollya_lib_constant_from_int(a))
|
634 |
683 |
sollya_lib_set_prec(precSo)
|
635 |
684 |
|
|
685 |
def pobyso_supnorm_so_so(polySo, funcSo, intervalSo, errorTypeSo, accuracySo):
|
|
686 |
return(sollya_lib_supnorm(polySo, funcSo, intervalSo, errorTypeSo, \
|
|
687 |
accuracySo))
|
|
688 |
|
636 |
689 |
def pobyso_taylor(function, degree, point):
|
637 |
690 |
""" Legacy function. See pobysoTaylor_so_so. """
|
638 |
691 |
return(pobyso_taylor_so_so(function, degree, point))
|
... | ... | |
647 |
700 |
degree, \
|
648 |
701 |
point, \
|
649 |
702 |
precision, \
|
650 |
|
interval = None, \
|
|
703 |
interval=None, \
|
651 |
704 |
errorType=None):
|
652 |
705 |
"""
|
653 |
706 |
Compute the Taylor form of 'degree' for 'functionSa' at 'point'
|
... | ... | |
670 |
723 |
if not re.search('Real', pointBaseRingString):
|
671 |
724 |
return None
|
672 |
725 |
# Call Sollya but first "sollyafy" the arguments.
|
673 |
|
sollya_lib_init(None)
|
674 |
726 |
pobyso_name_free_variable_sa_so(str(varSa))
|
675 |
727 |
#pobyso_set_prec_sa_so(300)
|
676 |
728 |
# Sollyafy the function.
|
... | ... | |
701 |
753 |
taylorFormSa = [polySa]
|
702 |
754 |
return(taylorFormSa)
|
703 |
755 |
# End pobyso_taylor_form_sa_sa
|
704 |
|
def pobyso_taylorform_so_so(functionSo, degreeSo, pointSo, intervalSo=None, errorTypeSo=None):
|
|
756 |
|
|
757 |
def pobyso_taylorform_so_so(functionSo, degreeSo, pointSo, intervalSo=None, \
|
|
758 |
errorTypeSo=None):
|
|
759 |
createdErrorType = False
|
705 |
760 |
if errorTypeSo is None:
|
706 |
761 |
errorTypeSo = sollya_lib_absolute()
|
|
762 |
createdErrorType = True
|
707 |
763 |
else:
|
708 |
764 |
#TODO: deal with the other case.
|
709 |
765 |
pass
|
710 |
766 |
if intervalSo is None:
|
711 |
|
resultSo = sollya_lib_taylorform(functionSo, degree, pointSo, errorTypeSo, None)
|
|
767 |
resultSo = sollya_lib_taylorform(functionSo, degreeSo, pointSo, \
|
|
768 |
errorTypeSo, None)
|
712 |
769 |
else:
|
713 |
|
resultSo = sollya_lib_taylorform(functionSo, degree, pointSo, intervalSo, errorTypeSo, None)
|
714 |
|
sollya_lib_clear_obj(errorTypeSo)
|
|
770 |
resultSo = sollya_lib_taylorform(functionSo, degreeSo, pointSo, \
|
|
771 |
intervalSo, errorTypeSo, None)
|
|
772 |
if createdErrorType:
|
|
773 |
sollya_lib_clear_obj(errorTypeSo)
|
715 |
774 |
return(resultSo)
|
716 |
775 |
|
717 |
776 |
|