[SciPy-dev] Which matrix library in C++ for scipy

Matthieu Brucher matthieu.brucher@gmail....
Thu Apr 26 08:03:47 CDT 2007


>
> There is numerical interface in boost::python.
>
> I don't use this approach myself.  Here's why.  I write all basic
> algorithms
> in c++.  I try to use modern, generic programming when writing them.



Same for me ;)


There is AFAIK, no reasonable way to interface such code to numerical/numpy.
> The C interface to numpy is too low-level.  IOW, I like writing in c++,
> and
> I don't want to have to write code at such a low-level interface as would
> be needed to interface to numpy.
>
> So my approach is:
>
> 1. Write c++ algorithms with generic interfaces (where feasible).
> 2. When it is not feasible to use generic container types, I use
> boost::ublas::{vector/matrix} explicitly.
> 3. The above c++ code is parametrized (templated) on the container types.
> 4. Explicit instantiations of (3) are then exposed to python, normally
> specifying ublas::{vector/matrix} as the input/output types.
>
> This doesn't, of course, directly interoperate with numpy.  I can,
> however,
> convert between numpy arrays and ublas::matrix (which currently requires
> copying the data, unfortunately).


What I'm doing after the last thread I started on numpy (SWIG,
boost.pythonor ctypes) is using ctypes, so I have my headers, I make a
C/C++ bridge and
I use ctypes.
If you have a (good) boost.python/whatever example for template
instantiation and use in Python then, I'm sure a lot of people will thank
you for the rest of your life - and even after ;) -

Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20070426/f6ac7277/attachment.html 


More information about the Scipy-dev mailing list