On Thu, Mar 12, 2020 at 4:29 PM Przemek Klosowski via Help-octave <
address@hidden> wrote:
On 3/12/20 3:42 PM, Brett Green wrote:
> The documentation simply states that column-major order is used, which
> if I understand correctly preserves the last index (in the case of a
> matrix the column, in this case data), as I wanted.
What do you mean by 'preserving the last index'? Column-major means
that the first index changes first, i.e. for a square matrice reshape()
picks elements down the first column, then second column, etc.:
reshape([1 2 ;3 4],1,4)
ans =
1 3 2 4
For your 4-dimensional array, the elements are taken in this order:
H(1,1,1,1),H(2,1,1,1),H(3,1,1,1), etc. and put in the reshaped array
also in the 'first column, then second column, and so on' order.
reshape([1 2 ;3 4;5 6;7 8],2,4)
ans =
1 5 2 6
3 7 4 8
Nicholas Jankowski:
Yes, that's correct. I'm in practice going to be dealing with m by n by 4 by 10 arrays where m and n are ~100.
Przemek Klosowski:
I see; so they are taken and then populated in the same order -
H(1,1,1,1), H(2,1,1,1), H(3,1,1,1) are reshaped into D(1,1), D(2,1), D(3,1). In both cases the indices are increased from left to right or first to last. I can see why this satisfies both of the properties I need - thank you!