Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Latest commit

 

History

History
22 lines (15 loc) · 893 Bytes

README.md

File metadata and controls

22 lines (15 loc) · 893 Bytes

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");