
Hi,
Yes, you can, but it can be tricky. What you may need to do is to check if TNT is capable of accepting an array by pointer without handling the memory (delete when the array is destroyed). If there are tools to do this, then it will be easy. If not, you will have to add a specific handler either in SWIG (copy the array in the in typemap and then copy it back again when the function is finished) or in TNT. If you need to do the latter, you can have some tips on my blog (http://matt.eifelle.com/2007/11/06/wrapping-a-c-container-in-python/).
Matthieu
2008/11/11 Rolf Wester rolf.wester@ilt.fraunhofer.de:
Charles R Harris wrote:
On Tue, Nov 11, 2008 at 1:24 AM, Rolf Wester rolf.wester@ilt.fraunhofer.dewrote:
Hi all,
I would like to wrap some C++ classes that use TNT-Arrays. Is it possible to pass numpy arrays to C++ functions that expect TNT-Arrays as function parameter? Does anybody know how the wrappers could be generated using swig? I would be very appreciative for any help.
With kind regards
IIRC, TNT does vectors and matrices, they have constructors, and they are contiguous. I think you can make wrappers, but it isn't going to be anything straight forward unless you can reuse the memory from a numpy array and I don't recall that that sort of constructor is available.
Is TNT still active? It looked pretty dead last time I looked several years ago.
Chuck
Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
TNT has constructors like:
TNT::Array1D<double>(int n, double * data)
which do not allocate a new C-array but that use "data" as their data-array.
I'm not sure whether TNT is still actively maintained, the TNT home page was last modified in 2004, so you are probably right. But the TNT Arrays are just what I need and I know of no alternative.
Rolf
# Dr. Rolf Wester # Fraunhofer Institut f. Lasertechnik # Steinbachstrasse 15, D-52074 Aachen, Germany. # Tel: + 49 (0) 241 8906 401, Fax: +49 (0) 241 8906 121 # EMail: rolf.wester@ilt.fraunhofer.de # WWW: http://www.ilt.fraunhofer.de _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion