I am working a n-dimensional matrix (which being stored as a single dimensional array), I wish to reorder in its dimensions such that the leading dimension is now the last dimension.
eg. if Dimensions(A) = 3 x 4 x 5 x 6 , I would want to change it to 4 x 5 x 6 x 3. This is similar to a transpose function for a 2-D matrix.
It can be implemented using permute function in Matlab for n dimensional matrix A. I want the following tranformation
A=permute(A,[2:n 1])
How could I do it in C?
P.S. I am not looking to reshape the matrix but to actually move the elements in order to get the next dimension as the leading dimension.
Permute can be defined as
B = PERMUTE(A,ORDER) rearranges the dimensions of A so that they
% are in the order specified by the vector ORDER. The array produced
% has the same values as A but the order of the subscripts needed to
% access any particular element are rearranged as specified by ORDER.
% For an N-D array A, numel(ORDER)>=ndims(A). All the elements of
% ORDER must be unique.