[Numpy-discussion] How to call methods from a class with custom matrices parameters with numpy arrays ?

Matthieu Brucher matthieu.brucher@gmail....
Thu Apr 19 07:29:46 CDT 2007


>
> I forgot you are using C++.



Yes, all my code is in C++, and in fact the code I use in Python should be
object-oriented as well, that's why it is not that easy to define how I'm
going to do this...


Using C++ with ctypes makes the wrapping
> more difficult, I think, specially since you are using templates: you
> would have to write a C wrapper around your classes, and then using
> ctypes on the wrapper (there may be better ways, but I don't see an
> obvious one). Basically, using ctypes is like using code from a
> dynamically loaded library (ala VST :) ).



That works great for C then, not that well for C++...


But writing some C code kills
> one of the strong point of ctypes (doing all the wrapping in python).



Yes, but even with SWIG, I think I'll have to write wrapper in C or in SWIG
to transform one array in my matrix and vice versa. Well, that should be a
great example for my book ;)


I have attached a simplistic example which show how to wrap some functions.


Many thanks, it is simple, I only have to provide the wrappers :| and I have
to do something with the class instance :| I'll think a little bit about how
to do this properly and efficiently


Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070419/3d9b9d6f/attachment.html 


More information about the Numpy-discussion mailing list