Hi Rolf,

Just curious -- have you considered using the blitz++ library
(http://www.oonumerics.org/blitz/)?  There seems to be a lot of
overlap in terms of functionality.  If you use blitz++, it's largely
included in scipy as part of weave.  Additionally, I already have code
that generates wrappers to functions taking such arrays using weave.
If blitz++ would work, I'll send them to you.

-- Hoyt

On Tue, Nov 11, 2008 at 2:28 AM, Rolf Wester
<[EMAIL PROTECTED]> wrote:
> Charles R Harris wrote:
>> On Tue, Nov 11, 2008 at 2:19 AM, Rolf Wester
>> <[EMAIL PROTECTED]>wrote:
>>
>>> Charles R Harris wrote:
>>>> On Tue, Nov 11, 2008 at 1:24 AM, Rolf Wester
>>>> <[EMAIL PROTECTED]>wrote:
>>>>
>>>>> 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 don't think there is any easy way to do what you want without writing some
>> code somewhere along the line. You can expose the C++ functions and TNT to
>> python, but to use numpy arrays you will need some way to get the data back
>> and forth between TNT arrays and numpy arrays. I suspect you will end up
>> just copying data into TNT arrays, calling your function,  and then copying
>> data back out of the result. Cython might be an alternative to swig for
>> that.
>>
>> It would help to have a better idea of what you want to do. Do you just want
>> to wrap an existing bunch of functions that use TNT?
>>
>> Chuck
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Numpy-discussion mailing list
>> Numpy-discussion@scipy.org
>> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
> It's my own code so I have the choice how to do it. Until now I used the
> typemaps defined in numpy.i, so I had either to use the 1-dimensional
> arrays even in case of multidimensional data or to copy the data. I
> wondered wether there is a more elegant way of using numpy arrays on the
> python side and TNT::Arrays on the C++ side without having to
> explicitely write extra code.
>
>
> 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: [EMAIL PROTECTED]
> # WWW:   http://www.ilt.fraunhofer.de
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
[EMAIL PROTECTED]
+++++++++++++++++++++++++++++++++++
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to