triMatInd {fuzzySim} | R Documentation |
This function outputs the indices of one triangle (the lower one by default) of an input square matrix. It is used by simMat
and, for large matrices, makes it faster than e.g. with lower.tri
or upper.tri
.
triMatInd(mat, lower = TRUE, list = FALSE)
mat |
a square matrix. |
lower |
logical indicating whether the indices should correspond to the lower triangle. The default is TRUE; FALSE produces the upper triangle indices. |
list |
logical indicating whether the results should be output as a list instead of a matrix. The default is FALSE. |
The indices (row, column) of the elements of the matrix that belong to the requested triangle.
A. Marcia Barbosa
http://stackoverflow.com/questions/20898684/how-to-efficiently-generate-lower-triangle-indices-of-a-symmetric-matrix
mat <- matrix(nrow = 4, ncol = 4) mat triMatInd(mat) triMatInd(mat, list = TRUE)