[Numpy-discussion] c-api return two arrays

Yoshi Rokuko yoshi at rokuko.net
Fri Jul 29 06:37:45 EDT 2011


+-------------------------------------------- Peter -----------+
> On Fri, Jul 29, 2011 at 9:52 AM, Yoshi Rokuko <yoshi at rokuko.net> wrote:
> >
> > hey, i have an algorithm that computes two matrices like that:
> >
> > A(i,k) = (x(i,k) + y(i,k))/norm
> > B(i,k) = (x(i,k) - y(i,k))/norm
> >
> > it would be convenient to have the method like that:
> >
> >>>> A, B = mod.meth(C, prob=.95)
> >
> > is ith possible to return two arrays?
> >
> > best regards
> 
> Yes, return a tuple of two elements. e.g.
> 
> def make_range(center, spread):
>    return center-spread, center+spread
> 
> low, high = make_range(5,1)
> assert low == 4
> assert high == 6
>

sorry i had important information only in subject: i'm writing
in c - so i'm talking about something like:

static PyObject *
mod_meth(PyObject *self, PyObject* args) {
    PyObject *arg;
    PyArrayObject *A, *B, *C;
[...]
a magic merge: mergedouts = (A, B)
[...]
    return PyArray_Return(mergedouts);
}

is it clear what i mean?

- yoshi




More information about the NumPy-Discussion mailing list