From: Stefan v. d. W. <st...@su...> - 2006-10-17 16:44:31
|
On Tue, Oct 17, 2006 at 10:01:51AM -0600, Travis Oliphant wrote: > Charles R Harris wrote: >=20 > > Travis, > > > > I note that > > > > >>> a =3D arange(6).reshape(2,3,order=3D'F') > > >>> a > > array([[0, 1, 2], > > [3, 4, 5]]) > > > > Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making = a=20 > > copy, but flat, flatten, and tostring all show the elements in 'C'=20 > > order. I ask because I wonder if changing the order can be used to=20 > > prepare arrays for input into the LaPack routines. >=20 >=20 > The order argument to reshape means (how should the big-chunk of data b= e=20 > interpreted when you reshape). So, yes, this should be=20 > [[0,2,4],[1,3,5]]. It is a bug that it does not do the right thing in=20 > this case. A bit counter-ituitive (I somehow expect reshape to return an array that satisfies all the constraints specified as parameters -- i.e. shape and order in memory), but consistent with Numeric. What confuses me is that, if you call the array constructor, you get In [2]: N.array(N.array([[1,2,3],[4,5,6]]),order=3D'F') Out[2]:=20 array([[1, 2, 3], [4, 5, 6]]) so here 'order' means something else. So then you do x =3D N.array([[0,1,2],[3,4,5]],order=3D'F') x.reshape((2,3),order=3D'C') and you get array([[0, 1, 2], [3, 4, 5]]) Hmm. Cheers St=E9fan |