From: Charles R H. <cha...@gm...> - 2006-10-18 21:48:29
|
On 10/18/06, George Nurser <gn...@go...> wrote: > > > > None of the LaPack stuff seems to use the Fortran stuff, they just > > > transpose and copy. > > You've got me worried here. I have assumed that when you start with a > c-contiguous array, a, with say,a.shape = (m,n), if you use the > transpose as an argument to a fortran routine which requires an mxn > size array, then no copying is required. > > This seems to work for me -- the transpose *does* have fortran order. Nope. The result is an (n,m) array in fortran order, not an (m,n) array in fortran order. In [52]:a = array([[1,2,3],[4,5,6]]) In [53]:a.transpose().flags Out[53]: CONTIGUOUS : False FORTRAN : True OWNDATA : False WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False In [54]:a.transpose().shape Out[54]:(3, 2) Looks like what you want is either fastcopyandtranspose or the order flag. In [56]:fastCopyAndTranspose(a).flags Out[56]: CONTIGUOUS : True FORTRAN : False OWNDATA : True WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False which is a (n,m) array in c order, i.e., an (m,n) array in fortran order. Or In [57]:array(a, order='F').flags Out[57]: CONTIGUOUS : False FORTRAN : True OWNDATA : True WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False which is a (m,n) array in fortran order. Also, in f2py, if I use -DF2PY_REPORT_ON_ARRAY_COPY=1 I receive no > alert of any copy. f2py takes care of the ordering, which is one reason why it is so useful. Chuck |