99 |
99 |
|
100 |
100 |
def pobyso_autoprint_so_so(arg):
|
101 |
101 |
sollya_lib_autoprint(arg,None)
|
|
102 |
|
|
103 |
def pobyso_bounds_to_interval_sa_sa(lowerBound, upperBound):
|
|
104 |
"""
|
|
105 |
Convert a pair of bounds into an interval (an element of
|
|
106 |
a RealIntervalField).
|
|
107 |
"""
|
|
108 |
# Minimal (not bullet-proof) check on bounds.
|
|
109 |
if lowerBound > upperBound:
|
|
110 |
return None
|
|
111 |
# Try to get the maximum precision among the bounds.
|
|
112 |
try:
|
|
113 |
preclb = parent(lowerBound).precision()
|
|
114 |
precub = parent(upperBound).precision()
|
|
115 |
prec = max(preclb, precub)
|
|
116 |
except AttributeError:
|
|
117 |
prec = 53
|
|
118 |
# Create the RealIntervalField and the interval (if possible).
|
|
119 |
theRIF = RealIntervalField(prec)
|
|
120 |
try:
|
|
121 |
interval = theRIF(lowerBound, upperBound)
|
|
122 |
except TypeError:
|
|
123 |
return None
|
|
124 |
else:
|
|
125 |
return interval
|
|
126 |
# End pobyso_bounds_to_interval_sa_sa
|
102 |
127 |
|
103 |
128 |
def pobyso_bounds_to_range_sa_so(rnLowerBoundSa, rnUpperBoundSa, \
|
104 |
129 |
precisionSa=None):
|
... | ... | |
1229 |
1254 |
"""
|
1230 |
1255 |
return sollya_lib_inf(intervalSo)
|
1231 |
1256 |
# End pobyso_inf_so_so.
|
|
1257 |
#
|
|
1258 |
def pobyso_infnorm_sa_sa(funcSa, intervalSa):
|
|
1259 |
"""
|
|
1260 |
An infnorm call with Sage arguments.
|
|
1261 |
We only take into account the 2 first arguments (the function and
|
|
1262 |
the interval (a range). Managing the other arguments (the file for
|
|
1263 |
the proof and the exclusion intervals list) will be performed later
|
|
1264 |
Changes will be needed in sollya_lib.py file too.
|
|
1265 |
"""
|
|
1266 |
# Check that funcSa is a function.
|
|
1267 |
if not \
|
|
1268 |
sage.symbolic.callable.is_CallableSymbolicExpressionRing(parent(funcSa)):
|
|
1269 |
return None
|
|
1270 |
# Check that intervalSa is an interval.
|
|
1271 |
try:
|
|
1272 |
intervalSa.upper()
|
|
1273 |
except AttributeError:
|
|
1274 |
return None
|
|
1275 |
# Convert the Sage function into a Sollya function.
|
|
1276 |
funcAsStringSa = funcSa._assume_str().replace('_SAGE_VAR_', '')
|
|
1277 |
funcSo = pobyso_parse_string_sa_so(funcAsStringSa)
|
|
1278 |
if not pobyso_obj_is_function_so_sa(funcSo):
|
|
1279 |
sollya_lib_clear_obj(funcSo)
|
|
1280 |
return None
|
|
1281 |
# Convert the Sage interval into a Sollya range.
|
|
1282 |
rangeSo = pobyso_interval_to_range_sa_so(intervalSa)
|
|
1283 |
retValSo = sollya_lib_infnorm(funcSo, rangeSo, None)
|
|
1284 |
sollya_lib_clear_obj(funcSo)
|
|
1285 |
sollya_lib_clear_obj(rangeSo)
|
|
1286 |
if pobyso_is_error_so_sa(retValSo):
|
|
1287 |
sollya_lib_clear_obj(retValSo)
|
|
1288 |
return None
|
|
1289 |
retValSa = pobyso_range_to_interval_so_sa(retValSo)
|
|
1290 |
sollya_lib_clear_obj(retValSo)
|
|
1291 |
return retValSa
|
|
1292 |
# End pobyso_infnorm_so_so.
|
|
1293 |
#
|
|
1294 |
def pobyso_infnorm_so_so(funcSo, rangeSo):
|
|
1295 |
"""
|
|
1296 |
Very thin wrapper around sollya_lib_infnorm().
|
|
1297 |
We only take into account the 2 first arguments (the function and
|
|
1298 |
the interval (a range). Managing the other arguments (the file for
|
|
1299 |
the proof and the exclusion intervals list) will be performed later
|
|
1300 |
Changes will be needed in sollya_lib.py file too.
|
1232 |
1301 |
|
1233 |
|
def pobyso_infnorm_so_so(func, interval, file = None, intervalList = None):
|
1234 |
|
print "Do not use this function. User pobyso_supnorm_so_so instead."
|
1235 |
|
return None
|
|
1302 |
As per Sollya manual, this function should not be used anymore and
|
|
1303 |
supnorm should be called instead. Nevertheless, supnorm breaks
|
|
1304 |
sometimes whereas infnorm still returns a satisfactory answer.
|
|
1305 |
"""
|
|
1306 |
return sollya_lib_infnorm(funcSo, rangeSo, None)
|
|
1307 |
# End pobyso_infnorm_so_so.
|
1236 |
1308 |
|
1237 |
1309 |
def pobyso_interval_to_range_sa_so(intervalSa, precisionSa=None):
|
1238 |
1310 |
if precisionSa is None:
|
... | ... | |
2023 |
2095 |
def pobyso_set_prec_so_so(newPrecSo):
|
2024 |
2096 |
sollya_lib_set_prec(newPrecSo)
|
2025 |
2097 |
# End pobyso_set_prec_so_so.
|
2026 |
|
|
2027 |
|
def pobyso_inf_so_so(rangeSo):
|
2028 |
|
"""
|
2029 |
|
Very thin wrapper around sollya_lib_inf().
|
2030 |
|
"""
|
2031 |
|
return sollya_lib_inf(rangeSo)
|
2032 |
|
# End pobyso_inf_so_so.
|
2033 |
2098 |
#
|
2034 |
|
def pobyso_infnorm_sa_sa(funcSa, interevalSa):
|
2035 |
|
"""
|
2036 |
|
Very thin wrapper around sollya_lib_infnorm().
|
2037 |
|
We only take into account the 2 first arguments (the function and
|
2038 |
|
the interval (a range). Managing the other arguments (the file for
|
2039 |
|
the proof and the exclusion intervals list) will be performed later
|
2040 |
|
Changes will be needed in sollya_lib.py file too.
|
2041 |
|
"""
|
2042 |
|
return sollya_lib_infnorm(funcSo, rangeSo, None)
|
2043 |
|
# End pobyso_infnorm_so_so.
|
2044 |
|
#
|
2045 |
|
def pobyso_infnorm_so_so(funcSo, rangeSo):
|
2046 |
|
"""
|
2047 |
|
Very thin wrapper around sollya_lib_infnorm().
|
2048 |
|
We only take into account the 2 first arguments (the function and
|
2049 |
|
the interval (a range). Managing the other arguments (the file for
|
2050 |
|
the proof and the exclusion intervals list) will be performed later
|
2051 |
|
Changes will be needed in sollya_lib.py file too.
|
2052 |
|
"""
|
2053 |
|
return sollya_lib_infnorm(funcSo, rangeSo, None)
|
2054 |
|
# End pobyso_infnorm_so_so.
|
2055 |
|
#
|
2056 |
2099 |
def pobyso_supnorm_sa_sa(poly):
|
2057 |
2100 |
"""
|
2058 |
2101 |
Computes the supremum norm from Sage input arguments and returns a
|