Révision 57
pobysoPythonSage/src/pobyso.py (revision 57) | ||
---|---|---|
6 | 6 |
use from Sage (via the "load" or the "attach" commands) |
7 | 7 |
|
8 | 8 |
pobyso functions come in five flavors: |
9 |
- the _so_so (arguments and returned objects are pointers to Sollya objects, includes
|
|
10 |
the void function and the no arguments function that return a pointer to a Sollya
|
|
11 |
object); |
|
9 |
- the _so_so (arguments and returned objects are pointers to Sollya objects, |
|
10 |
includes the void function and the no arguments function that return a
|
|
11 |
pointer to a Sollya object);
|
|
12 | 12 |
- the _so_sa (argument are pointers to Sollya objects, returned objects are |
13 |
Sage/Python objects or, more generally, information is transfered from the Sollya |
|
14 |
world to Sage/Python world); |
|
13 |
Sage/Python objects or, more generally, information is transfered from the |
|
14 |
Sollya world to Sage/Python world; e.g. functions without arguments that |
|
15 |
return a Sage/Python object); |
|
15 | 16 |
- the _sa_so (arguments are Sage/Python objects, returned objects are |
16 | 17 |
pointers to Sollya objects); |
17 | 18 |
- the sa_sa (arguments and returned objects are all Sage/Python objects); |
18 | 19 |
- a catch all flavor, without any suffix, (e. g. functions that have no argument |
19 | 20 |
nor return value). |
21 |
This classification is not always very strict. Conversion functions from Sollya |
|
22 |
to Sage/Python are sometimes decorated with Sage/Python arguments to set |
|
23 |
the precision. These functions remain in the so_sa category. |
|
20 | 24 |
NOTES: |
21 | 25 |
Reported errors in Eclipse come from the calls to |
22 | 26 |
the Sollya library |
... | ... | |
295 | 299 |
""" |
296 | 300 |
return(sollya_lib_get_constant(get_rn_value(rnArg), soConst)) |
297 | 301 |
|
298 |
def pobyso_get_constant_as_rn(ctExp): |
|
302 |
def pobyso_get_constant_as_rn(ctExpSo):
|
|
299 | 303 |
""" Legacy function. See pobyso_get_constant_as_rn_so_sa. """ |
300 |
return(pobyso_get_constant_as_rn_so_sa(ctExp)) |
|
304 |
return(pobyso_get_constant_as_rn_so_sa(ctExpSo))
|
|
301 | 305 |
|
302 | 306 |
def pobyso_get_constant_as_rn_so_sa(constExpSo): |
303 |
precisionSa = pobyso_get_prec_of_constant(constExpSo) |
|
307 |
precisionSa = pobyso_get_prec_of_constant_so_sa(constExpSo)
|
|
304 | 308 |
RRRR = RealField(precisionSa) |
305 | 309 |
rnSa = RRRR(0) |
306 | 310 |
sollya_lib_get_constant(get_rn_value(rnSa), constExpSo) |
... | ... | |
484 | 488 |
print "Unexpected" |
485 | 489 |
return eval('None') |
486 | 490 |
# End pobyso_get_sage_poly_from_sollya_poly |
491 |
def pobyso_get_sage_poly_from_sollya_poly(polySo, realFieldSa=None): |
|
492 |
""" |
|
493 |
Convert a Sollya polynomial into a Sage polynomial. |
|
494 |
If no realField is given, a RealField corresponding to the maximum precision |
|
495 |
of the coefficients is internally computed. |
|
496 |
It is not returned but can be easily retrieved from the polynomial itself. |
|
497 |
Main steps: |
|
498 |
- (optional) compute the RealField of the coefficients; |
|
499 |
- convert the Sollya expression into a Sage expression; |
|
500 |
- convert the Sage expression into a Sage polynomial |
|
501 |
""" |
|
502 |
if realFieldSa is None: |
|
503 |
expressionPrecSa = pobyso_get_max_prec_of_exp_so_sa(polySo) |
|
504 |
realFieldSa = RealField(expressionPrecSa) |
|
487 | 505 |
|
506 |
expressionSa = pobyso_get_sage_exp_from_sollya_exp_so_sa(polySo, \ |
|
507 |
realFieldSa) |
|
508 |
polyVariableSa = expressionSa.variables()[0] |
|
509 |
polyRingSa = realFieldSa[polyVariableSa] |
|
510 |
polynomialSa = polynomial(expressionSa, polyRingSa) |
|
511 |
return(polynomialSa) |
|
512 |
# End pobyso_get_sage_poly_from_sollya_poly |
|
513 |
|
|
488 | 514 |
def pobyso_get_subfunctions(expressionSo): |
489 | 515 |
""" Legacy function. See pobyso_get_subfunctions_so_sa. """ |
490 | 516 |
return(pobyso_get_subfunctions_so_sa(expressionSo)) |
Formats disponibles : Unified diff