diff --git a/cython/SnapPy.pxi b/cython/SnapPy.pxi index a4612c11..1a936ec2 100644 --- a/cython/SnapPy.pxi +++ b/cython/SnapPy.pxi @@ -24,51 +24,6 @@ cdef extern from "stdlib.h": cdef extern from "string.h": char* strncpy(char* dst, char* src, size_t len) -IF REAL_TYPE == 'qd_real': - from libcpp cimport bool as cpp_bool - cdef extern from "qd_real_SnapPy.h": - qd_real PI_SQUARED_BY_2 - double default_vertex_epsilon - qd_real det_error_epsilon - cdef cppclass qd_real: - double x[4] - qd_real() except + - qd_real(double) except + - qd_real(char *) except + - qd_real(qd_real) except + - qd_real operator+(qd_real) - qd_real operator-(qd_real) - qd_real operator*(qd_real) - qd_real operator/(qd_real) - cpp_bool operator<(qd_real) - cpp_bool operator<(double) - cpp_bool operator>(qd_real) - cpp_bool operator>(double) - cpp_bool operator<=(qd_real) - cpp_bool operator<=(double) - cpp_bool operator>=(qd_real) - cpp_bool operator>=(double) - cpp_bool operator==(qd_real) - cpp_bool operator==(double) - cpp_bool operator!=(qd_real) - cpp_bool operator!=(double) - void write(char *s, int len, int precision) - - ctypedef qd_real Real - - cdef real_to_string(Real x): - cdef char buffer[128] - x.write(buffer, 128, 64) - return buffer # this should return a python string -ELIF REAL_TYPE == 'double': - ctypedef double Real - cdef extern from "double_SnapPy.h": - double PI_SQUARED_BY_2 - double default_vertex_epsilon - double det_error_epsilon - cdef real_to_string(Real x): - return '%.18f' % x - # SnapPea declarations # Cython can't handle arrays of C++ objects because of a bug which diff --git a/cython/SnapPy.pyx b/cython/SnapPy.pyx index a58d2cb4..575f102c 100644 --- a/cython/SnapPy.pyx +++ b/cython/SnapPy.pyx @@ -1,6 +1,7 @@ # cython: language_level=3str -DEF REAL_TYPE = 'double' +ctypedef double Real + include "SnapPy.pxi" include "numbers/double.pyx" include "core/basic.pyx" diff --git a/cython/SnapPyHP.pyx b/cython/SnapPyHP.pyx index 601c3ca3..62eff721 100644 --- a/cython/SnapPyHP.pyx +++ b/cython/SnapPyHP.pyx @@ -1,7 +1,9 @@ # distutils: language = c++ # distutils: sources = SnapPyHP.cpp # cython: language_level=3str -DEF REAL_TYPE = "qd_real" + +ctypedef qd_real Real + include "SnapPy.pxi" include "numbers/qd.pyx" include "core/basic.pyx" diff --git a/cython/numbers/double.pyx b/cython/numbers/double.pyx index b6fa07dd..9c2f1044 100644 --- a/cython/numbers/double.pyx +++ b/cython/numbers/double.pyx @@ -3,6 +3,14 @@ from .number import Number as RawNumber class Number(RawNumber): _default_precision=53 +cdef extern from "double_SnapPy.h": + double PI_SQUARED_BY_2 + double default_vertex_epsilon + double det_error_epsilon + +cdef real_to_string(Real x): + return '%.18f' % x + cdef Real2gen_direct(Real R): """ Convert a Real to a pari gen of type t_REAL. @@ -26,4 +34,3 @@ cdef Real2Number(Real R): return Number(Real2gen(R)) cdef Complex2Number(Complex C): return Number(Complex2gen(C)) - diff --git a/cython/numbers/qd.pyx b/cython/numbers/qd.pyx index 9f8eb504..bcda37d9 100644 --- a/cython/numbers/qd.pyx +++ b/cython/numbers/qd.pyx @@ -3,6 +3,40 @@ from .number import Number as RawNumber class Number(RawNumber): _default_precision=212 +from libcpp cimport bool as cpp_bool +cdef extern from "qd_real_SnapPy.h": + qd_real PI_SQUARED_BY_2 + double default_vertex_epsilon + qd_real det_error_epsilon + cdef cppclass qd_real: + double x[4] + qd_real() except + + qd_real(double) except + + qd_real(char *) except + + qd_real(qd_real) except + + qd_real operator+(qd_real) + qd_real operator-(qd_real) + qd_real operator*(qd_real) + qd_real operator/(qd_real) + cpp_bool operator<(qd_real) + cpp_bool operator<(double) + cpp_bool operator>(qd_real) + cpp_bool operator>(double) + cpp_bool operator<=(qd_real) + cpp_bool operator<=(double) + cpp_bool operator>=(qd_real) + cpp_bool operator>=(double) + cpp_bool operator==(qd_real) + cpp_bool operator==(double) + cpp_bool operator!=(qd_real) + cpp_bool operator!=(double) + void write(char *s, int len, int precision) + +cdef real_to_string(Real x): + cdef char buffer[128] + x.write(buffer, 128, 64) + return buffer # this should return a python string + cdef Real2gen_direct(Real R): """ Convert a Real to a pari gen of type t_REAL. This constructs the gen