Is it possible to construct a matrix of the following form without for loops?
Start with a multidimensional array
M( T1 , n1 , m1 , T2 , n2 , m2 )
where we have the same size in the T1 and T2 dimensions, the n1 and n2 dimensions, and the m1 and m2 dimensions.
Then, for each n and m, set
M( 1 , n , m , 2 , n , m ) = a;
M( 2 , n , m , 1 , n+1 , m ) = b;
M( 2 , n , m , 1 , n , m+1 ) = c;
for some numbers a, b and c. I can do this with e.g.
M( 1 , : , : , 2 , : , : ) = a;
so this is not a problem.
Then condense the multidimensional array to a 2D array
M( u(T1,n1,m1) , u(T2,n2,m2) )
where u is some function that condenses the indices from tuples of 3 to single indices. The function u can be anything that condenses our indices this way, though it'd be especially nice if I could define it myself.
I am familiar with using reshape to condense all indices. Is there also a way to condense only certain indices? Or, is there another way to construct this matrix besides reshaping a multidimensional array?