[SciPy-user] C++ extensions

Pearu Peterson pearu at scipy.org
Fri Oct 29 20:01:50 EDT 2004



On Fri, 29 Oct 2004, David Grant wrote:

> Pearu Peterson wrote:
>> 
>> On Fri, 29 Oct 2004, David Grant wrote:
>> 
>>> I also see this: http://docs.python.org/ext/ext.html.  It says how to 
>>> build a module but not how to actually USE it??
>> 
>> 
>> Did you read the first section of this document:
>> 
>>   http://docs.python.org/ext/simpleExample.html
>> 
>> ?
>
> Yeah, but that was for C.  Mine is C++.  I thought it would be a little 
> different.

Not so much different, see http://docs.python.org/ext/cplusplus.html
However, if you need to wrap C++ classes then you can use either SWIG or 
Boost.Python.

>>>> Anyone used SWIG?
>> 
>> Yes, of course;-)
>
> So will it work for me?  From what I've told you so far?

>From what you have told us I see no reason why wouldn't it work.

>> 
>>>> David Grant wrote:
>>>> 
>>>>> Hey guys (and girls, are there any???),
>>>>> 
>>>>> I have some C++ code, it does a decomposition of a large matrix..  It 
>>>>> has a bunch of objects.  It is very black box though, you just declare 
>>>>> an object, give it the matrix and it will give an output.  I think it 
>>>>> uses CLAPACK.  I would like to call this from python.
>>>> 
>> 
>> What kind of a matrix decomposition are you trying to calculate? May be 
>> scipy.linalg has it already.
>> 
> It does some CSD.  But the algorithm is specific to quantum computing, so I 
> doubt it is in scipy.linalg.  Although I'm not sure how much of this code is 
> CSD and how much is other stuff.  It's possible I guess to use scipy.linalg 
> and rewrite the supporting stuff in python directly.

So you would need gsvd in scipy.linalg but that has not been implemented 
yet.

Pearu




More information about the SciPy-User mailing list