Created
March 20, 2017 07:27
-
-
Save darden1/029ebdeb3b92145d0b76fffb9aea029b to your computer and use it in GitHub Desktop.
A script for testing cumulative sum with c++. Cython wrapping code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from libcpp.vector cimport vector | |
| cdef extern from "cpp_test_sum_.h" namespace "cpp_test_sum": | |
| cdef cppclass cppTestSum: | |
| cppTestSum(int n_iter) except + | |
| int n_iter | |
| vector[double] sum | |
| void calc_sum() | |
| cdef class TestSum(object): | |
| cdef cppTestSum* thisptr | |
| def __cinit__(self,int n_iter): | |
| self.thisptr = new cppTestSum(n_iter) | |
| def __dealloc(self): | |
| del self.thisptr | |
| def calc_sum(self): | |
| return self.thisptr.calc_sum() | |
| property n_iter: | |
| def __get__(self): return self.thisptr.n_iter | |
| def __set__(self, n_iter): self.thisptr.n_iter = n_iter | |
| property sum: | |
| def __get__(self): return self.thisptr.sum | |
| def __set__(self, sum): self.thisptr.sum = sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment