"Charles R Harris" <[EMAIL PROTECTED]> writes: > > Unfortunately I don't see an easy way to use the same approach the other > > way > > (matlab doesn't seem to offer much on the C level to manipulate arrays), > > so > > I'd presumably need something like: > > > > stuff_into_matlab_array(a.T.reshape(a.shape).copy()) > > > > the question is how to avoid doing two copies. > > > > Any comments appreciated, > > > The easiest way to deal with the ordering is to use the order keyword in > numpy: > > In [4]: a = array([0,1,2,3]).reshape((2,2), order='F') > > In [5]: a > Out[5]: > array([[0, 2], > [1, 3]]) > > You would still need to get access to something to reshape, shared memory or > something, but the key is that you don't have to reorder the elements, you > just need the correct strides and offsets to address the elements in Fortran > order. I have no idea if this works in numeric.
It doesn't work in Numeric, but that isn't much of any issue because I think it ought to be pretty much equivalent by transposing and reshaping. However the problem is that I *do* need to reorder the elements for numpy->matlab and I'm not sure how to best do this (without unnecessary copying and temporary numpy array creation but using numpy functionality if possible). 'as _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion