lierdakil / cpp-ndarray

Thin wrapper around numpy.ndarray for boost.python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cpp-ndarray

This is a thin wrapper around numpy.ndarray for boost.python

Multidimensional array indexing uses operator() with variadic templates for C++11 mode or with va_args for C++03 mode.

C++11 mode is detected via boost/config/compiler framework.

With variadic templates, some runtime checking is preformed on array size and number of dimensions. This can be disabled by defining ndarr_assert(x) before including ndarray.h, which can yield a small performance benefit, but increase chance of memory corruption due to programmer errors.

Code for using boost::python::extract for numpy.ndarray import can be enabled by defining NUMPY_EXTRACT, but one should define

template<typename T>
boost::python::handle<> array_from_python_str<T>::array_type;

in some cpp file and initialize converter by calling

array_from_python_str<T>("numpy","ndarray");

About

Thin wrapper around numpy.ndarray for boost.python

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C++ 77.3%Language:Python 17.9%Language:QMake 4.8%