130 |
130 |
return rangeSo
|
131 |
131 |
# End pobyso_bounds_to_range_sa_so
|
132 |
132 |
|
|
133 |
def pobyso_build_end_elliptic_list_so_so(*args):
|
|
134 |
"""
|
|
135 |
From argumrny Sollya objects, create a Sollya end elliptic list.
|
|
136 |
Elements of the list are "eaten" (should not be cleared individualy,
|
|
137 |
are cleared when the list is cleared).
|
|
138 |
"""
|
|
139 |
if len(args) == 0:
|
|
140 |
## Called with an empty list produced "error".
|
|
141 |
return sollya_lib_build_end_elliptic_list(None)
|
|
142 |
index = 0
|
|
143 |
## One can not append elements to an elliptic list, prepend only is
|
|
144 |
# permitted.
|
|
145 |
for argument in reversed(args):
|
|
146 |
if index == 0:
|
|
147 |
listSo = sollya_lib_build_end_elliptic_list(argument, None)
|
|
148 |
else:
|
|
149 |
listSo = sollya_lib_prepend(argument, listSo)
|
|
150 |
index += 1
|
|
151 |
return listSo
|
|
152 |
|
|
153 |
# End pobyso_build_end_elliptic_list_so_so
|
|
154 |
|
133 |
155 |
def pobyso_build_function_sub_so_so(exp1So, exp2So):
|
134 |
156 |
return(sollya_lib_build_function_sub(exp1So, exp2So))
|
135 |
157 |
|
... | ... | |
222 |
244 |
return(imageIntervalSa)
|
223 |
245 |
# End pobyso_compute_pos_function_abs_val_bounds_sa_sa
|
224 |
246 |
|
|
247 |
def pobyso_compute_precision_decay_ratio_function_sa_so():
|
|
248 |
"""
|
|
249 |
Compute the precision decay ratio function for polynomial
|
|
250 |
coefficient progressive trucation.
|
|
251 |
"""
|
|
252 |
functionText = """
|
|
253 |
proc(deg, a, b, we, wq)
|
|
254 |
{
|
|
255 |
k = we * (exp(x/a)-1) + wq * (b*x)^2 + (1-we-wq) * x;
|
|
256 |
return k/k(d);
|
|
257 |
};
|
|
258 |
"""
|
|
259 |
return pobyso_parse_string_sa_so(functionText)
|
|
260 |
# End pobyso_compute_precision_decay_ratio_function.
|
|
261 |
|
|
262 |
|
225 |
263 |
def pobyso_constant(rnArg):
|
226 |
264 |
""" Legacy function. See pobyso_constant_sa_so. """
|
227 |
265 |
return(pobyso_constant_sa_so(rnArg))
|
... | ... | |
247 |
285 |
"""
|
248 |
286 |
Obvious.
|
249 |
287 |
"""
|
250 |
|
return(pobyso_constant_from_int_sa_so(0))
|
|
288 |
return pobyso_constant_from_int_sa_so(0)
|
251 |
289 |
|
252 |
290 |
def pobyso_constant_1():
|
253 |
291 |
"""
|
254 |
292 |
Obvious.
|
255 |
293 |
Legacy function. See pobyso_constant_so_so.
|
256 |
294 |
"""
|
257 |
|
return(pobyso_constant_1_sa_so())
|
|
295 |
return pobyso_constant_1_sa_so()
|
258 |
296 |
|
259 |
297 |
def pobyso_constant_1_sa_so():
|
260 |
298 |
"""
|
... | ... | |
264 |
302 |
|
265 |
303 |
def pobyso_constant_from_int(anInt):
|
266 |
304 |
""" Legacy function. See pobyso_constant_from_int_sa_so. """
|
267 |
|
return(pobyso_constant_from_int_sa_so(anInt))
|
|
305 |
return pobyso_constant_from_int_sa_so(anInt)
|
268 |
306 |
|
269 |
307 |
def pobyso_constant_from_int_sa_so(anInt):
|
270 |
308 |
"""
|
271 |
309 |
Get a Sollya constant from a Sage int.
|
272 |
310 |
"""
|
273 |
|
return(sollya_lib_constant_from_int64(long(anInt)))
|
|
311 |
return sollya_lib_constant_from_int64(long(anInt))
|
274 |
312 |
|
275 |
313 |
def pobyso_constant_from_int_so_sa(constSo):
|
276 |
314 |
"""
|
... | ... | |
279 |
317 |
"""
|
280 |
318 |
constSa = c_long(0)
|
281 |
319 |
sollya_lib_get_constant_as_int64(byref(constSa), constSo)
|
282 |
|
return(constSa.value)
|
|
320 |
return constSa.value
|
283 |
321 |
# End pobyso_constant_from_int_so_sa
|
284 |
322 |
|
285 |
323 |
def pobyso_constant_from_mpq_sa_so(rationalSa):
|
... | ... | |
304 |
342 |
currentSollyaPrecSa = pobyso_get_prec_so_sa()
|
305 |
343 |
return pobyso_constant_sa_so(rnArgSa, currentSollyaPrecSa)
|
306 |
344 |
# End pobyso_constant_sollya_prec_sa_so
|
307 |
|
|
|
345 |
|
|
346 |
def pobyso_end_elliptic_list_so_sa_so(objectsListSo, intCountSa):
|
|
347 |
"""
|
|
348 |
Create a Sollya end elliptic list made of the objectListSo[0] to
|
|
349 |
objectsListSo[intCountSa-1] objects.
|
|
350 |
"""
|
|
351 |
return sollya_lib_end_elliptic_list(objectSo, int(intCountSa))
|
|
352 |
|
308 |
353 |
def pobyso_error_so():
|
309 |
354 |
return sollya_lib_error(None)
|
310 |
355 |
# End pobyso_error().
|
311 |
356 |
|
|
357 |
def pobyso_evaluate_so_so(funcSo, argumentSo):
|
|
358 |
"""
|
|
359 |
Evaluates funcSo for arguemntSo through sollya_lib_evaluate().
|
|
360 |
"""
|
|
361 |
return sollya_lib_evaluate(funcSo, argumentSo)
|
|
362 |
# End pobyso_evaluate_so_so.
|
|
363 |
|
312 |
364 |
def pobyso_float_poly_sa_so(polySa, precSa = None):
|
313 |
365 |
"""
|
314 |
366 |
Create a Sollya polynomial from a Sage RealField polynomial.
|
... | ... | |
367 |
419 |
"""
|
368 |
420 |
if realFieldSa is None:
|
369 |
421 |
expressionPrecSa = pobyso_get_max_prec_of_exp_so_sa(polySo)
|
|
422 |
print "Maximum precision of Sollya polynomial coefficients:", expressionPrecSa
|
370 |
423 |
realFieldSa = RealField(expressionPrecSa)
|
371 |
424 |
#print "Sollya expression before...",
|
372 |
425 |
#pobyso_autoprint(polySo)
|
... | ... | |
380 |
433 |
#print polyRingSa
|
381 |
434 |
# Do not use the polynomial(expressionSa, ring=polyRingSa) form!
|
382 |
435 |
polynomialSa = polyRingSa(expressionSa)
|
|
436 |
polyCoeffsListSa = polynomialSa.coefficients()
|
|
437 |
#for coeff in polyCoeffsListSa:
|
|
438 |
# print coeff.abs().n()
|
383 |
439 |
return polynomialSa
|
384 |
440 |
# End pobyso_float_poly_so_sa
|
385 |
441 |
|
|
442 |
def pobyso_free_variable():
|
|
443 |
"""
|
|
444 |
Ultra thin wrapper around the sollya_lib_function_build_free_variable function.
|
|
445 |
"""
|
|
446 |
return sollya_lib_build_function_free_variable()
|
386 |
447 |
|
387 |
448 |
def pobyso_function_type_as_string(funcType):
|
388 |
449 |
""" Legacy function. See pobyso_function_type_as_string_so_sa. """
|
... | ... | |
969 |
1030 |
return int(degreeIntervalSa.upper())
|
970 |
1031 |
# End pobyso_guess_degree_so_sa
|
971 |
1032 |
|
|
1033 |
def pobyso_inf_so_so(intervalSo):
|
|
1034 |
"""
|
|
1035 |
Very thin wrapper around sollya_lib_inf().
|
|
1036 |
"""
|
|
1037 |
return sollya_lib_inf(intervalSo)
|
|
1038 |
# End pobyso_inf_so_so.
|
|
1039 |
|
972 |
1040 |
def pobyso_infnorm_so_so(func, interval, file = None, intervalList = None):
|
973 |
1041 |
print "Do not use this function. User pobyso_supnorm_so_so instead."
|
974 |
1042 |
return None
|
... | ... | |
1045 |
1113 |
sollya_lib_clear_obj(precisionSo)
|
1046 |
1114 |
return precisionSa
|
1047 |
1115 |
# End pobyso_precision_so_sa
|
|
1116 |
|
|
1117 |
def pobyso_polynomial_coefficients_progressive_truncate_so_so(polySo,
|
|
1118 |
funcSo,
|
|
1119 |
icSo,
|
|
1120 |
intervalSo,
|
|
1121 |
itpSo,
|
|
1122 |
ftpSo,
|
|
1123 |
maxPrecSo,
|
|
1124 |
maxErrSo):
|
|
1125 |
print "Input arguments:"
|
|
1126 |
pobyso_autoprint(polySo)
|
|
1127 |
pobyso_autoprint(funcSo)
|
|
1128 |
pobyso_autoprint(icSo)
|
|
1129 |
pobyso_autoprint(intervalSo)
|
|
1130 |
pobyso_autoprint(itpSo)
|
|
1131 |
pobyso_autoprint(ftpSo)
|
|
1132 |
pobyso_autoprint(maxPrecSo)
|
|
1133 |
pobyso_autoprint(maxErrSo)
|
|
1134 |
print "________________"
|
1048 |
1135 |
|
|
1136 |
precDecayFuncSo = \
|
|
1137 |
pobyso_parse_string("3/8*(exp(x/2.2)-1) + 2/8*(2*x)^2 + (1-3/8-2/8)*x")
|
|
1138 |
pobyso_autoprint(precDecayFuncSo)
|
|
1139 |
return None
|
|
1140 |
|
1049 |
1141 |
def pobyso_range(rnLowerBound, rnUpperBound):
|
1050 |
1142 |
""" Legacy function. See pobyso_range_sa_so. """
|
1051 |
1143 |
return pobyso_range_sa_so(rnLowerBound, rnUpperBound)
|
... | ... | |
1223 |
1315 |
return(sollya_lib_remez(funcSo, degreeSo, rangeSo, weightSo, qualitySo, None))
|
1224 |
1316 |
# End pobyso_remez_canonical_so_so.
|
1225 |
1317 |
|
|
1318 |
def pobyso_round_coefficients_single_so_so(polySo, precSo):
|
|
1319 |
"""
|
|
1320 |
Create a rounded coefficients polynomial from polynomial argument to
|
|
1321 |
the number of bits in size argument.
|
|
1322 |
All coefficients are set to the same precision.
|
|
1323 |
"""
|
|
1324 |
## TODO: check arguments.
|
|
1325 |
endEllipListSo = pobyso_build_end_elliptic_list_so_so(precSo)
|
|
1326 |
polySo = sollya_lib_roundcoefficients(polySo, endEllipListSo, None)
|
|
1327 |
#sollya_lib_clear_obj(endEllipListSo)
|
|
1328 |
return polySo
|
|
1329 |
|
|
1330 |
# End pobyso_round_coefficients_single_so_so
|
|
1331 |
|
1226 |
1332 |
def pobyso_set_canonical_off():
|
1227 |
1333 |
sollya_lib_set_canonical(sollya_lib_off())
|
1228 |
1334 |
|
... | ... | |
1237 |
1343 |
a = c_int(p)
|
1238 |
1344 |
precSo = c_void_p(sollya_lib_constant_from_int(a))
|
1239 |
1345 |
sollya_lib_set_prec(precSo, None)
|
|
1346 |
# End pobyso_set_prec_sa_so.
|
1240 |
1347 |
|
1241 |
1348 |
def pobyso_set_prec_so_so(newPrecSo):
|
1242 |
1349 |
sollya_lib_set_prec(newPrecSo, None)
|
|
1350 |
# End pobyso_set_prec_so_so.
|
1243 |
1351 |
|
|
1352 |
def pobyso_inf_so_so(intervalSo):
|
|
1353 |
"""
|
|
1354 |
Very thin wrapper around sollya_lib_inf().
|
|
1355 |
"""
|
|
1356 |
return sollya_lib_inf(intervalSo)
|
|
1357 |
# End pobyso_inf_so_so.
|
|
1358 |
|
1244 |
1359 |
def pobyso_supnorm_so_so(polySo, funcSo, intervalSo, errorTypeSo = None,\
|
1245 |
1360 |
accuracySo = None):
|
1246 |
1361 |
"""
|
... | ... | |
1500 |
1615 |
intervalSo, errorTypeSo, None)
|
1501 |
1616 |
if createdErrorType:
|
1502 |
1617 |
sollya_lib_clear_obj(errorTypeSo)
|
1503 |
|
return(resultSo)
|
|
1618 |
return resultSo
|
1504 |
1619 |
|
1505 |
1620 |
|
1506 |
1621 |
def pobyso_univar_polynomial_print_reverse(polySa):
|