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

Matthieu Brucher matthieu.brucher at gmail.com
Fri Apr 20 03:38:12 EDT 2007


Well, that's easy ;)
OK, I have to digg in for the transformations of numpy arrays, knowing that
I have other parameters. But for this, the Cookbook at scipy should help me
a lot.
Thanks for the help ;)

Matthieu

Ok, I have a simple working example. It is actually much easier than I
> thought, because no C compiler is involved at all (I was afraid about
> object layout, vtables and other horrors), only C++.
>
> I attached the example: it shows how to mimic a C++ class in python
> through a C-like interface. The main difficulty is to be sure that your
> object get deleted by the python interpreter, which means having a
> __del__ function. The problem is that you cannot control how python will
> destroy its things: it may "destroy" ctypes module before your object,
> which is problematic since you need it to destroy your object. The idea
> is to "force" python to keep everything in the namespace through a fake
> second argument to the destructor.
>
> http://docs.python.org/ref/customization.html (comments on __del__ ).
>
> David
>
> CC      = colorgcc
> CXX     = colorgcc
>
> LD      = g++
>
> PYTHONINC       = -I/usr/include/python2.5
> NUMPYINC        = -I/usr/lib/python2.5/site-packages/numpy/core/include
>
> WARN    = -W -Wall
>
> CFLAGS  = $(WARN) $(PYTHONINC) $(NUMPYINC)
>
> hellocpp.so: hellocpp.o
>         $(LD) -shared -o $@ $< -Wl,-soname,$@
>
> hellocpp.o: hellocpp.cpp
>         $(CXX) -c $(CFLAGS) -fPIC $<
>
> clean:
>         rm -f *.o
>         rm -f *.so
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070420/50ecb99a/attachment.html>


More information about the NumPy-Discussion mailing list