[Matrix-SIG] returning arrays

Paul F. Dubois dubois1@llnl.gov
Mon, 8 Mar 1999 07:53:32 -0800

Forgive me if any of this is misspelled, but it is approximately right:

To create and return a 1-D array of length n:
PyArray_TYPES t;
PyArray* p;
int n;
double* data;

n = ....;
t = PyArray_DOUBLE;
p = PyArray_FromDims(1, &n, t);
data = p->data;
...data[i] = ...;
return (PyObject *) p;
-----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
>Matrix-SIG maillist  -  Matrix-SIG@python.org