[Numpy-discussion] flatten() without copy - is this possible?
a.h.jaffe at bakerjaffe.plus.com
Mon Jun 4 10:17:00 EDT 2007
> hi all.
> in the numpy for matlab users I read
> y = x.flatten(1)
> turn array into vector (note that this forces a copy)
> Is there any way to do the trick wthout copying?
> What are the problems here? Just other way of array elements indexing...
One important question is whether you actually need the new vector, or
whether you just want a flat index into the array; if the latter, you
can always [I think] use x.flat[one_d_index]. (But note that y=x.flat
gives an iterator, not a new array.)
More information about the NumPy-Discussion