[Numpy-discussion] in-situ resizing array in C
Pearu Peterson
pearu at scipy.org
Mon Nov 29 13:34:11 CST 2004
Hi,
I have a question to Numeric/Numarray experts:
Let A be a contiguous one or two-dimensional array with shape (n,) or
(m,n), respectively. Let k be a positive integer less than n.
Reference count for A is 1. The objective is to execute A=A[:k]
or A=A[:,:k], respctively, in C.
Q: Is it safe to resize the array A by simply resetting its dimensions,
that is,
A->dimensions[0] = k;
or
A->dimensions[1] = k;
if A->nd is 1 or 2, respectively, in C? This appears to work but may be
there are some corner cases that I have overlooked.
Would that work also when using Numarray?
If not, how to resize (preferably in-situ) an array in C under the
conditions given above?
TIA,
Pearu
More information about the Numpy-discussion
mailing list