logo       

Re: Reshaing continued: msg#00038

python.numeric.general

Subject: Re: Reshaing continued

Karthikesh Raju wrote:
A partial support for 3D has been by extending the number of columns in a
2D matrix, so each new dimension is a block matrix in the columns. This
works fine, but again another day when i need 4D it would break. This is
why i thought i could play with reshape to get things correct once and for
all.

I am answering from rusty Numeric knowledge, not knowing whether the numarray implementation is different.

I think you are mixing up how reshape and how transpose work.

"reshape" doesn't actually touch the data; it only changes the size of the different dimensions. Therefore, the order of the data in the array can not be changed by reshape, nor can the number of data points.

The transpose method also doesn't touch the actual data, but it changes the strides in which the data are used. transpose can change the order of N-dimensions, not only 2!

Both operations are basically O(1), which practically means that they are instantaneous, no matter how large the arrays.

After a transpose, the array is normally non-contiguous, which might mean that repeated walk-throughs are significantly slower, and it may pay to make a contiguous copy first.

Rob

--
Rob W.W. Hooft || rob@xxxxxxxxx || http://www.hooft.net/people/rob/


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise