RsparseMatrix-class | R Documentation |
The "RsparseMatrix"
class is the virtual class of
all sparse matrices coded in sorted compressed row-oriented form.
Since it is a virtual class, no objects may be created from it. See
showClass("RsparseMatrix")
for its subclasses.
j
:Object of class "integer"
of length nnzero
(number of non-zero elements). These are the row numbers for
each non-zero element in the matrix.
p
:Object of class "integer"
of pointers, one
for each row, to the initial (zero-based) index of elements in
the row.
Dim
, Dimnames
:inherited from
the superclass, see sparseMatrix
.
Class "sparseMatrix"
, directly.
Class "Matrix"
, by class "sparseMatrix"
.
Originally, few methods were defined on purpose, as we
rather use the CsparseMatrix
in Matrix.
Then, more methods were added but beware that these
typically do not return "RsparseMatrix"
results, but
rather Csparse* or Tsparse* ones; e.g., R[i, j] <- v
for an
"RsparseMatrix"
R
works, but after the assignment, R
is a (triplet) "TsparseMatrix"
.
signature(x = "RsparseMatrix")
: ...
signature(from = "RsparseMatrix", to = "CsparseMatrix")
: ...
signature(from = "RsparseMatrix", to = "TsparseMatrix")
: ...
its superclass, sparseMatrix
, and, e.g., class
dgRMatrix
for the links to other classes.
showClass("RsparseMatrix")
(m0 <- new("dsRMatrix"))
m2 <- new("dsRMatrix", Dim = c(2L,2L),
x = c(3,1), j = c(1L,1L), p = 0:2)
m2
stopifnot(colSums(as(m2, "TsparseMatrix")) == 3:4)
str(m2)
(ds2 <- forceSymmetric(diag(2))) # dsy*
dR <- as(ds2, "RsparseMatrix")
dR # dsRMatrix
(m0 <- new("dtRMatrix"))
(m2 <- new("dtRMatrix", Dim = c(2L,2L),
x = c(5, 1:2), p = c(0L,2:3), j= c(0:1,1L)))
str(m2)
(m3 <- as(Diagonal(2), "RsparseMatrix"))# --> dtRMatrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.