Functions
wrap.cpp File Reference
#include <boost/numpy.hpp>
#include <boost/scoped_array.hpp>
#include <iostream>
Include dependency graph for wrap.cpp:

Go to the source code of this file.

Functions

 BOOST_PYTHON_MODULE (example)
void fill1 (double *array, int rows, int cols, int row_stride, int col_stride)
void fill2 (double **array, int rows, int cols)
int main (int argc, char **argv)
void wrap_fill1 (np::ndarray const &array)
void wrap_fill2 (np::ndarray const &array)

Function Documentation

BOOST_PYTHON_MODULE ( example  )

Definition at line 105 of file wrap.cpp.

void fill1 ( double *  array,
int  rows,
int  cols,
int  row_stride,
int  col_stride 
)

A simple example showing how to wrap a couple of C++ functions that operate on 2-d arrays into Python functions that take NumPy arrays as arguments.

If you find have a lot of such functions to wrap, you may want to create a C++ array type (or use one of the many existing C++ array libraries) that maps well to NumPy arrays and create Boost.Python converters. There's more work up front than the approach here, but much less boilerplate per function. See the "Gaussian" example included with Boost.NumPy for an example of custom converters, or take a look at the "ndarray" project on GitHub for a more complete, high-level solution.

Note that we're using embedded Python here only to make a convenient self-contained example; you could just as easily put the wrappers in a regular C++-compiled module and imported them in regular Python. Again, see the Gaussian demo for an example.

Definition at line 36 of file wrap.cpp.

void fill2 ( double **  array,
int  rows,
int  cols 
)

Definition at line 72 of file wrap.cpp.

int main ( int  argc,
char **  argv 
)

Definition at line 111 of file wrap.cpp.

void wrap_fill1 ( np::ndarray const &  array)

Definition at line 51 of file wrap.cpp.

void wrap_fill2 ( np::ndarray const &  array)

Definition at line 82 of file wrap.cpp.



boost_numpy
Author(s): Jim Bosch, Ankit Daftery
autogenerated on Fri Aug 28 2015 10:10:40