| mat2triplet | R Documentation |
From an R object coercible to "TsparseMatrix",
typically a (sparse) matrix, produce its triplet representation which may
collapse to a “Duplet” in the case of binary aka pattern, such as
"nMatrix" objects.
mat2triplet(x, uniqT = FALSE)
x |
any R object for which |
uniqT |
|
A list, typically with three components,
i |
vector of row indices for all non-zero entries of |
i |
vector of columns indices for all non-zero entries of |
x |
vector of all non-zero entries of |
Note that the order of the entries is determined by the
coercion to "TsparseMatrix" and hence typically
with increasing j (and increasing i within ties of j).
The mat2triplet() utility was created to be a more efficient and
more predictable substitute for summary(<sparseMatrix>).
UseRs have wrongly expected the latter to return a data frame with
columns i and j which however is wrong for a
"diagonalMatrix".
The summary() method for "sparseMatrix",
summary,sparseMatrix-method.
mat2triplet() is conceptually the inverse function of
spMatrix and (one case of) sparseMatrix.
mat2triplet # simple definition
i <- c(1,3:8); j <- c(2,9,6:10); x <- 7 * (1:7)
(Ax <- sparseMatrix(i, j, x = x)) ## 8 x 10 "dgCMatrix"
str(trA <- mat2triplet(Ax))
stopifnot(i == sort(trA$i), sort(j) == trA$j, x == sort(trA$x))
D <- Diagonal(x=4:2)
summary(D)
str(mat2triplet(D))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.