[Matrix-SIG] returning arrays part 2

Paul F. Dubois dubois1@llnl.gov
Mon, 8 Mar 1999 08:04:14 -0800


For some reason I only answered half your question. As regards the input:

You do a normal PyTuple_Parse with code "O". That gives you a PyObject
*pobj; Then:
PyArray *pin;
double* din;
pin = PyArray_ContiguousFromObject(pobj, PyArray_DOUBLE, 1, 1);
if(!pin) {error....}
din = pin->din;

The contiguous call makes sure that:
a. the object given can be converted into an array of the desired type and
dimension
b. the data area din is a contiguous field in row-major order.
c. if the input data was all that, pin will just be pobj with an incremented
refcount.

When done with din you should decref pin.

-----Original Message-----
From: Dave Stinchcombe <dars@fook.mechanoid.soton.ac.uk>
To: matrix-sig@python.org <matrix-sig@python.org>
Date: Monday, March 08, 1999 7:07 AM
Subject: [Matrix-SIG] returning arrays


>Hi Folks,
>it's that time in my work when graphs and charts need to be drawn so I'm
>palying with NumPy again. There is one thing I would like to do, but can't
>figure out. I would like to write a function which accepts a Numeric.array
>as it's argument and returns a Numeric.array, in exactly the kind of way
>that Numeric.cos does. Can any one tell me the trick. My function is just a
>shortish bit of numerics that requires only one parameter in order to get a
>solution.
>
>Yours
>Dave
>
>
>_______________________________________________
>Matrix-SIG maillist  -  Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>
>