Hi all,
I think this must be simple but I can't get it right...
I have an MxM triangular matrix, the coefficients of which are stored in a vector, row by row. For example:
M = [ m00 m01 m02 m03 ]
[ m11 m12 m12 ]
[ m22 m23 ]
[ m33 ]
is stored as
coef[ m00 m01 m02 m03 m11 m12 m13 m22 m23 m33 ]
Now I'm looking for a non-recursive algorithm that gives me for matrix size M
and coefficient array index i
unsigned int row_index(i,M)
and
unsigned int column_index(i,M)
of the matrix element that it refers to. So,
row_index(9,4) == 3
, column_index(7,4) == 2
etc. if the index counting is zero-based.
EDIT: Several replies using an iteration have been given. Does anyone know of algebraic expressions?