Triangular matrix of compressed storage

First, the classification triangular matrix

Triangular matrix generally divided into three categories: a lower triangular matrix, the upper triangular matrix, a symmetric matrix.

Second, the matrix is ​​stored compressed

N * n to the lower triangular matrix (here, when i <j, 0 elements may also be other numbers) as an example:

 

 

 

Lower triangular matrix is ​​stored compressed principle is to store only non-zero elements in the lower triangle, the triangle does not exist on the same element. Press the "line-oriented sequence" is stored, the sequence obtained is

Number of elements in the lower triangular matrix is ​​1 + 2 + 3 + ... + n = n (n + 1) / 2.

 

Therefore, a n * n may be a lower triangular matrix (n + 1) a one-dimensional array / 2 are denoted with the size to n.

Expressed in the form of:

 

Guess you like

Origin www.cnblogs.com/xcxfury001blogs/p/11444668.html