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

Neal Becker ndbecker2@gmail....
Thu Apr 26 08:26:23 CDT 2007


Matthieu Brucher wrote:

>>
>> 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

I've got loads of examples.  Good is subjective.  What kind of example 
would you like?




More information about the Scipy-dev mailing list