diff options
Diffstat (limited to 'src/cython')
-rw-r--r-- | src/cython/Makefile | 8 | ||||
-rw-r--r-- | src/cython/cgudhi.pxd | 9 | ||||
-rw-r--r-- | src/cython/gudhi.pyx | 18 | ||||
-rwxr-xr-x | src/cython/main.py | 5 | ||||
-rw-r--r-- | src/cython/setup.py | 15 |
5 files changed, 55 insertions, 0 deletions
diff --git a/src/cython/Makefile b/src/cython/Makefile new file mode 100644 index 00000000..b694ab47 --- /dev/null +++ b/src/cython/Makefile @@ -0,0 +1,8 @@ +ext: + python setup.py build_ext --inplace + +test: + python main.py + +clean: + rm -rf build/ *.o *.so *.cpp diff --git a/src/cython/cgudhi.pxd b/src/cython/cgudhi.pxd new file mode 100644 index 00000000..9ba40999 --- /dev/null +++ b/src/cython/cgudhi.pxd @@ -0,0 +1,9 @@ + +cdef extern from "include/gudhi/Simplex_tree.h" namespace "Gudhi": + cdef cppclass Simplex_tree_options_full_featured: + pass + cdef Simplex_tree_options_fast_persistence: + pass + cdef cppclass Simplex_tree[T]: + Simplex_tree() + diff --git a/src/cython/gudhi.pyx b/src/cython/gudhi.pyx new file mode 100644 index 00000000..6fab0726 --- /dev/null +++ b/src/cython/gudhi.pyx @@ -0,0 +1,18 @@ +from cython cimport numeric +cimport cgudhi + +cdef class SimplexTree: + cdef cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_full_featured] *thisptr + def __cinit__(self): + self.thisptr = new cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_full_featured]() + def __dealloc__(self): + if self.thisptr != NULL: + del self.thisptr + +cdef class MiniSimplexTree: + cdef cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_fast_persistence] *thisptr + def __cinit__(self): + self.thisptr = new cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_fast_persistence]() + def __dealloc__(self): + if self.thisptr != NULL: + del self.thisptr diff --git a/src/cython/main.py b/src/cython/main.py new file mode 100755 index 00000000..cb7a4754 --- /dev/null +++ b/src/cython/main.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +import gudhi + +st = gudhi.SimplexTree() diff --git a/src/cython/setup.py b/src/cython/setup.py new file mode 100644 index 00000000..26a46590 --- /dev/null +++ b/src/cython/setup.py @@ -0,0 +1,15 @@ +from distutils.core import setup, Extension +from Cython.Build import cythonize + +gudhi = Extension( + "gudhi", + sources = ['gudhi.pyx',], + language = 'c++', + extra_compile_args=['-std=c++11'], + include_dirs = ['..'], +) + +setup( + name = 'gudhi', + ext_modules = cythonize(gudhi), +) |