I wish to write a program that does the following, and I need some math help figuring out a simple formula to pick up elements in the lower triangular part of a matrix.
Consider the lower bottom-left half of a N x N matrix C, including the diagonal.
Starting from the top-left cell (1,1) and ending with the bottom right cell (N,N) consider all the cells C(i,j) on the oblique patterns "/" (do they have a name, half SW-NE diagonal maybe?):
(1,1) (2,1) (3,1) (2,2) ... (r,1)(r-2,2) ... (r-h,h) h <= r - h (half SW-NE diagonal) ... (N,N)
I wish to write a program to put all these cells - exactly in the order just described - into a unique uni-dimensional array A(u), u=1,... and I want to do that, with only one index u, using a formula like:
i = f(u) j = g(u) [ or, in case, even j = g(u, i) ]
I'd like to understand the simplest way to find some simple explicit formula for f() and g().
So, in brief, the final program should look like:
for u = 1 to CountOfCellsInHalfMatrix i = f(u) j = g(u) A(u) = C(i,j) next
There should be a pretty simple formula for them, but I am confused. Could you outline a simple method to find them ?
I hope I explained clearly enough the goal (feel free to edit at will to make it clearer).