dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #21571
Re: std::vector& in Python
On 22/02/11 17:49, Anders Logg wrote:
> On Tue, Feb 22, 2011 at 05:38:24PM +0000, Garth N. Wells wrote:
>>
>>
>> On 22/02/11 17:35, Johan Hake wrote:
>>> What is the signature?
>>>
>>> Have you tried using:
>>>
>>> PY_SEQUENCE_OF_SCALARS_TO_VECTOR_OF_PRIMITIVES(TYPE,
>>> TYPE_UPPER,
>>> ARG_NAME,
>>> TYPE_NAME,
>>> SEQ_LENGTH)
>>>
>>> Look at the end of std_vector_typemaps.i for example of its use.
>>>
>>> Then you can pass any iterable for the values.
>>>
>>> If you want to expose
>>>
>>> add_cell(uint c, const std::vector<uint>& v)
>>>
>>
>> That's the one.
>>
>>> You should be able to use something like:
>>>
>>> IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32,
>>> v, NPY_UINT, uint, I)
>>>
>>>
>>
>> Where should I put it?
>>
>> Winding this back, is it desirable to wrap std::vector, or should we use
>> Array in the C++ interface?
>
> Can we add a constructor to Array that takes a std::vector as
> argument? Then it would be unproblematic to have Array "everywhere" in
> the C++ interface.
>
I think that this would obscure ownership, and eventually lead to trouble.
Garth
> --
> Anders
References