On Friday August 23 2013 10:28:09 Anders Logg wrote:
> On Fri, Aug 23, 2013 at 08:45:08AM +0200, Johan Hake wrote:
> > On Thursday August 22 2013 21:41:18 Anders Logg wrote:
> > > How do I add a typemap for
> > >
> > > std::pair<std::vector<unsigned int>, std::vector<unsigned int> >?
> >
> > What do you want to map it to? A tuple of 2 numpy arrays?
>
> Exactly.
>
> > > I know simple types can be added at the bottom om std_pair.i by
> > >
> > > %typemap(out) std::pair<unsigned int, double>
> > > {
> > >
> > > $result = Py_BuildValue("id", $1.first, $1.second);
> > >
> > > }
> > >
> > > and similiar, but will this work for std::vector?
> >
> > No, these are just for primitive types. A new macro needs to be
> > constructed
> > for this one, which should be straight forward.
> >
> > Just construct two numpy arrays and populate them with values from the two
> > std::vectors, for which there are numerous examples in std_vector.i or
> > std_map.i. Then call Py_BuildValue using "oo" as the types and pass the
> > two
> > numpy arrays.
>
> Thanks. I'll try this. Where should it be placed? In std_pair.i or
> std_vector.i?
In std_pair.i
Johan
>
> --
> Anders
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics