Skip to content

Instantly share code, notes, and snippets.



Created Jun 16, 2014
What would you like to do?
Non-type template arguments C++/Cython
# -*- coding: utf-8 -*-
# distutils: language = c++
from func cimport func as _func
def func(double inp):
cdef double out
_func[double, 3](&inp, &out);
return out;
namespace myfunc {
template<typename T, int n>
void func(const T * const in, T * const out){
*out = n*(*in);
cdef extern from "func.h" namespace "myfunc":
cdef void func[T, int n](const T * const, T * const)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from _func import func
if __name__ == '__main__':
from distutils.core import setup
from Cython.Build import cythonize
ext_mod = cythonize("_func.pyx")
ext_modules = ext_mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment