[Numpy-discussion] How to call methods from a class with custom matrices parameters with numpy arrays ?
Fri Apr 20 02:38:12 CDT 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
Thanks for the help ;)
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__ ).
> 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 $<
> rm -f *.o
> rm -f *.so
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion