[Numpy-discussion] access ndarray in C++

Ravi lists_ravi@lavabit....
Wed Dec 10 10:28:29 CST 2008


On Wednesday 23 April 2008 15:48:23 Christopher Barker wrote:
> > - Boost Python [1]. Especially if you want usable C++ integration. (ie.
> > more than basic templates, etc.)
>
> What's the status of the Boost array object? maintained? updated for
> recent numpy?

The boost.python array object is still maintained. However, it has a few 
problems:

1. All array operations go through python which makes it too slow for my 
purposes. Phil Austin posted an alternate class on this list which works well 
since it uses the numpy C API:
  http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/num_util_release2/Readme.html

2. Only numeric & numarray are supported out of the box, but it is simple to 
support numpy; just add the following after calling import_array in your 
extension module:
  boost::python::numeric::array::set_module_and_type( "numpy", "ndarray" );

3. If you want the C++-way of dealing with numpy matrices & vectors directly 
as objects look at either of the following:
  http://mail.python.org/pipermail/cplusplus-sig/2008-October/013825.html
  http://mathema.tician.de/software/pyublas
Of course, I am biased towards the first approach.

Regards,
Ravi





More information about the Numpy-discussion mailing list