Révision 53
| pobysoPythonSage/src/pobyso.py (revision 53) | ||
|---|---|---|
| 223 | 223 |
|
| 224 | 224 |
def pobyso_get_constant(rnArg, soConst): |
| 225 | 225 |
""" Legacy function. See pobyso_get_constant_so_sa. """ |
| 226 |
pobyso_get_constant_so_sa(rnArg, soConst)
|
|
| 226 |
return(pobyso_get_constant_so_sa(rnArg, soConst))
|
|
| 227 | 227 |
|
| 228 | 228 |
def pobyso_get_constant_so_sa(rnArg, soConst): |
| 229 | 229 |
""" |
| ... | ... | |
| 231 | 231 |
rnArg must already exist and belong to some RealField. |
| 232 | 232 |
We assume that soConst points to a Sollya constant. |
| 233 | 233 |
""" |
| 234 |
sollya_lib_get_constant(get_rn_value(rnArg), soConst)
|
|
| 234 |
return(sollya_lib_get_constant(get_rn_value(rnArg), soConst))
|
|
| 235 | 235 |
|
| 236 | 236 |
def pobyso_get_constant_as_rn(ctExp): |
| 237 | 237 |
""" Legacy function. See pobyso_get_constant_as_rn_so_sa. """ |
| ... | ... | |
| 245 | 245 |
return(rn) |
| 246 | 246 |
|
| 247 | 247 |
def pobyso_get_constant_as_rn_with_rf(ctExp, realField): |
| 248 |
""" Legacy function. See .""" |
|
| 248 |
""" Legacy function. See pobyso_get_constant_as_rn_with_rf_so_sa."""
|
|
| 249 | 249 |
return(pobyso_get_constant_as_rn_with_rf_so_sa(ctExp, realField)) |
| 250 | 250 |
|
| 251 | 251 |
def pobyso_get_constant_as_rn_with_rf_so_sa(ctExp, realField): |
| ... | ... | |
| 278 | 278 |
sollya_lib_get_head_function(byref(functionType), expressionSo, None) |
| 279 | 279 |
return(int(functionType.value)) |
| 280 | 280 |
|
| 281 |
def pobyso_get_interval_from_range_so_sa(soRange): |
|
| 282 |
""" |
|
| 283 |
Return the Sage interval corresponding to the Sollya range argument. |
|
| 284 |
The interval bounds are not rounded: they are elements of RealIntervalField |
|
| 285 |
of the "right" precision. |
|
| 286 |
""" |
|
| 287 |
prec = c_int(0) |
|
| 288 |
retval = sollya_lib_get_prec_of_range(byref(prec), soRange, None) |
|
| 289 |
if retval == 0: |
|
| 290 |
return(None) |
|
| 291 |
RRRI = RealIntervalField(prec.value) |
|
| 292 |
intervalSa = RRRI(0,0) |
|
| 293 |
retval = \ |
|
| 294 |
sollya_lib_get_interval_from_range(get_interval_value(intervalSa),\ |
|
| 295 |
soRange) |
|
| 296 |
if retval == 0: |
|
| 297 |
return(None) |
|
| 298 |
return(intervalSa) |
|
| 299 |
|
|
| 281 | 300 |
def pobyso_get_list_elements(soObj): |
| 282 | 301 |
""" Legacy function. See pobyso_get_list_elements_so_so. """ |
| 283 | 302 |
return(pobyso_get_list_elements_so_so(soObj)) |
| ... | ... | |
| 456 | 475 |
""" Legacy function. See pobyso_get_prec_of_constant_so_sa. """ |
| 457 | 476 |
return(pobyso_get_prec_of_constant_so_sa(ctExpSo)) |
| 458 | 477 |
|
| 459 |
def pobyso_get_prec_of_constant_so_sa(ctExpSo):
|
|
| 478 |
def pobyso_get_prec_of_range_so_sa(rangeSo):
|
|
| 460 | 479 |
prec = c_int(0) |
| 461 |
retc = sollya_lib_get_prec_of_constant(byref(prec), ctExpSo, None)
|
|
| 480 |
retc = sollya_lib_get_prec_of_range(byref(prec), rangeSo, None)
|
|
| 462 | 481 |
return(int(prec.value)) |
| 463 | 482 |
|
| 483 |
def pobyso_infnorm_so_so(func, interval, file = None, intervalList = None): |
|
| 484 |
return(sollya_lib_infnorm(func, interval, file, intervalList, None)) |
|
| 485 |
|
|
| 464 | 486 |
def pobyso_lib_init(): |
| 465 | 487 |
sollya_lib_init(None) |
| 466 | 488 |
|
| pobysoPythonSage/src/sageMpfr.spyx (revision 53) | ||
|---|---|---|
| 1 | 1 |
from sage.rings.real_mpfr cimport * |
| 2 |
from sage.rings.real_mpfi cimport * |
|
| 2 | 3 |
# |
| 3 | 4 |
# Functions to manipulate the real RealNumber values. |
| 4 | 5 |
# |
| ... | ... | |
| 11 | 12 |
cdef extern from "mpfr.h": |
| 12 | 13 |
cdef int MPFR_PREC_MIN "MPFR_PREC_MIN" |
| 13 | 14 |
cdef unsigned int mpfr_min_prec(mpfr_t x) |
| 14 |
|
|
| 15 | 15 |
|
| 16 |
cpdef int get_interval_value(RealIntervalFieldElement x): |
|
| 17 |
""" |
|
| 18 |
Get the address of the value of a RealIntervalField Element. |
|
| 19 |
This address can be used to to set the value as well. |
|
| 20 |
""" |
|
| 21 |
return(<int>&(x.value)) |
|
| 22 |
|
|
| 16 | 23 |
cpdef int get_rn_value(RealNumber x): |
| 17 | 24 |
""" |
| 18 | 25 |
Get the address of the value of a RealNumber. This address can be |
| 19 | 26 |
used to to set the value as well. |
| 20 | 27 |
""" |
| 21 | 28 |
return(<int>&(x.value)) |
| 29 |
|
|
| 30 |
cpdef set_interval_value(RealIntervalFieldElement x, int p): |
|
| 31 |
""" |
|
| 32 |
Set the value of x from MPFI interval p. |
|
| 33 |
""" |
|
| 34 |
# We use the "array trick" to workaround the pointer dereferencing |
|
| 35 |
# issue (in Cython there is no unary operator "*"). |
|
| 36 |
# |
|
| 37 |
mpfi_set(x.value, (<mpfi_t *>p)[0]) |
|
| 22 | 38 |
|
| 23 | 39 |
cpdef set_rn_value(RealNumber x, int p, mp_rnd_t rnd=GMP_RNDN): |
| 24 | 40 |
""" |
| ... | ... | |
| 55 | 71 |
else: |
| 56 | 72 |
return(min_prec) |
| 57 | 73 |
|
| 74 |
cpdef free_mpfi_num(int mpfiNum): |
|
| 75 |
mpfi_clear((<mpfi_t*>mpfiNum)[0]) |
|
| 76 |
|
|
| 77 |
cpdef free_mpfr_num(int mpfrNum): |
|
| 78 |
mpfr_clear((<mpfr_t*>mpfrNum)[0]) |
|
| 79 |
|
|
| 80 |
cpdef new_interval_num(unsigned int prec): |
|
| 81 |
cdef mpfi_t *newValue = NULL |
|
| 82 |
print "Precision : ", prec |
|
| 83 |
newValue = <mpfi_t*>malloc(sizeof(mpfi_t)) |
|
| 84 |
mpfi_init2(newValue[0], prec) |
|
| 85 |
print "Creation done!" |
|
| 86 |
return(<int>newValue) |
|
| 87 |
|
|
| 58 | 88 |
cpdef new_mpfr_num(unsigned int prec): |
| 59 | 89 |
cdef mpfr_t *newValue = NULL |
| 60 | 90 |
print "Precision : ", prec |
| ... | ... | |
| 63 | 93 |
print "Creation done!" |
| 64 | 94 |
return(<int>newValue) |
| 65 | 95 |
|
| 66 |
cpdef free_mpfr_num(int mpfrNum): |
|
| 67 |
mpfr_clear((<mpfr_t*>mpfrNum)[0]) |
|
| 68 |
|
|
| 69 | 96 |
# |
| 70 | 97 |
|
| 71 | 98 |
cpdef cmp_rn_value(RealNumber x, RealNumber y): |
| pobysoPythonSage/src/sollya_lib.sage (revision 53) | ||
|---|---|---|
| 34 | 34 |
sollya.sollya_lib_get_free_variable_name |
| 35 | 35 |
sollya_lib_get_function_arity = sollya.sollya_lib_get_function_arity |
| 36 | 36 |
sollya_lib_get_head_function = sollya.sollya_lib_get_head_function |
| 37 |
sollya_lib_get_interval_from_range = \ |
|
| 38 |
sollya.sollya_lib_get_interval_from_range |
|
| 37 | 39 |
sollya_lib_get_list_elements = sollya.sollya_lib_get_list_elements |
| 38 | 40 |
sollya_lib_get_object_list_head = \ |
| 39 | 41 |
sollya.sollya_lib_get_object_list_head |
| ... | ... | |
| 41 | 43 |
sollya.sollya_lib_get_object_list_tail |
| 42 | 44 |
sollya_lib_get_prec = sollya.sollya_lib_get_prec |
| 43 | 45 |
sollya_lib_get_prec_of_constant = sollya.sollya_lib_get_prec_of_constant |
| 46 |
sollya_lib_get_prec_of_range = sollya.sollya_lib_get_prec_of_range |
|
| 44 | 47 |
sollya_lib_get_subfunctions = sollya.sollya_lib_get_subfunctions |
| 45 | 48 |
sollya_lib_head = sollya.sollya_lib_head |
| 49 |
sollya_lib_infnorm = sollya.sollya_lib_infnorm |
|
| 46 | 50 |
sollya_lib_init= sollya.sollya_lib_init |
| 47 | 51 |
sollya_lib_is_absolute = sollya.sollya_lib_is_absolute |
| 48 | 52 |
sollya_lib_name_free_variable = \ |
| ... | ... | |
| 85 | 89 |
sollya_lib_get_constant_as_int.argtypes = [POINTER(c_int), c_int] |
| 86 | 90 |
sollya_lib_get_function_arity.argtypes = [POINTER(c_int), c_int] |
| 87 | 91 |
sollya_lib_get_head_function.argtypes = [POINTER(c_int), c_int] |
| 88 |
sollya_lib_get_list_elements.argtypes = [POINTER(POINTER(c_longlong)), POINTER(c_int),\ |
|
| 92 |
sollya_lib_get_list_elements.argtypes = [POINTER(POINTER(c_longlong)), \ |
|
| 93 |
POINTER(c_int),\ |
|
| 89 | 94 |
POINTER(c_int), c_int] |
| 90 | 95 |
sollya_lib_get_prec_of_constant.argtypes = [POINTER(c_int), c_int] |
| 96 |
sollya_lib_get_prec_of_range.argtypes = [POINTER(c_int), c_int] |
|
| 91 | 97 |
sollya_lib_get_subfunctions.argtypes = [c_int, POINTER(c_int), \ |
| 92 |
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), \ |
|
| 93 |
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int)] |
|
| 98 |
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), \ |
|
| 99 |
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), \ |
|
| 100 |
POINTER(c_int), POINTER(c_int)] |
|
| 94 | 101 |
sollya_lib_name_free_variable.argtypes = [POINTER(c_char)] |
| 95 | 102 |
except : |
| 96 | 103 |
print "\nOne of the Python-Sollya argument type setting command has \ |
Formats disponibles : Unified diff