Given a symmetric square integer matrix M, this function extracts all (r, c) index pairs from the lower triangle (r > c) for each unique value V* present in that region of the matrix. The result is a named list where each name corresponds to a value V*, and each element is a list containing two integer vectors: r and c.

collect_lower_triangle_pairs(M)

Arguments

M

A square numeric matrix. Assumed to be symmetric with integer-like values.

Value

A named list. Each element corresponds to a unique value in the lower triangle of M, and contains a list with components r and c, the row and column indices (with r > c) where that value occurs.

Examples

set.seed(1)
M <- matrix(sample(80:180, size = 100^2, replace = TRUE), nrow = 100)
result <- collect_lower_triangle_pairs(M)
str(result[["100"]])
#> List of 2
#>  $ r: int [1:48] 13 79 85 86 22 14 19 73 67 30 ...
#>  $ c: int [1:48] 1 1 4 4 6 9 9 9 10 11 ...