root / pobysoPythonSage / src / sageGMP.spyx @ 243
Historique | Voir | Annoter | Télécharger (835 octet)
1 | 198 | storres | #cimport cython |
---|---|---|---|
2 | 198 | storres | from libc.stdlib cimport malloc,free |
3 | 198 | storres | from sage.rings.rational cimport * |
4 | 198 | storres | # |
5 | 198 | storres | # Sage file in the cimport closes are in <sage_dir>/src/sage directory. |
6 | 198 | storres | # |
7 | 198 | storres | # |
8 | 198 | storres | # Functions to manipulate the real Rational values. |
9 | 198 | storres | # |
10 | 198 | storres | # Import constants and declarations that are not exported |
11 | 198 | storres | # from the Sage real_mpfr.pyx file. |
12 | 198 | storres | # Notes: |
13 | 198 | storres | # - notice how #define constants are imported. |
14 | 198 | storres | # - before mpfr_min_prec() is declared, we need to "ctypedef" mpfr_prec_t |
15 | 198 | storres | # if we want to be consistent with MPFR notations. The actual type comes |
16 | 198 | storres | # from mpfr.h but, according to documentation, any type of same general |
17 | 198 | storres | # kind would have been OK. |
18 | 198 | storres | |
19 | 198 | storres | cpdef inline unsigned long int sgmp_get_rational_value(Rational x): |
20 | 198 | storres | """ |
21 | 198 | storres | Get the address of the value of a Rational. |
22 | 198 | storres | """ |
23 | 198 | storres | return(<unsigned long int>(&(x.value))) |
24 | 198 | storres | # End sgmp_get_rational. |