dsCMatrix-class | R Documentation |
The dsCMatrix
class is a class of symmetric, sparse
numeric matrices in the compressed, column-oriented format. In
this implementation the non-zero elements in the columns are sorted
into increasing row order.
The dsTMatrix
class is the class of symmetric, sparse numeric
matrices in triplet format.
Objects can be created by calls of the form new("dsCMatrix",
...)
or new("dsTMatrix", ...)
, or automatically via e.g.,
as(*, "symmetricMatrix")
, or (for dsCMatrix
) also
from Matrix(.)
.
Creation “from scratch” most efficiently happens via
sparseMatrix(*, symmetric=TRUE)
.
uplo
:A character object indicating if the upper
triangle ("U"
) or the lower triangle ("L"
) is stored.
i
:Object of class "integer"
of length nnZ
(half number of non-zero elements). These are the row
numbers for each non-zero element in the lower triangle of the matrix.
p
:(only in class "dsCMatrix"
:) an
integer
vector for providing pointers, one for each
column, see the detailed description in CsparseMatrix
.
j
:(only in class "dsTMatrix"
:) Object of
class "integer"
of length nnZ (as i
). These are the
column numbers for each non-zero element in the lower triangle of
the matrix.
x
:Object of class "numeric"
of length nnZ –
the non-zero elements of the matrix (to be duplicated for full matrix).
factors
:Object of class "list"
- a list
of factorizations of the matrix.
Dim
:Object of class "integer"
- the dimensions
of the matrix - must be an integer vector with exactly two
non-negative values.
Both classes extend classes and symmetricMatrix
dsparseMatrix
directly;
dsCMatrix
further directly extends
CsparseMatrix
, where
dsTMatrix
does TsparseMatrix
.
signature(a = "dsCMatrix", b = "....")
: x
<- solve(a,b)
solves A x = b
for x
; see
solve-methods
.
signature(x = "dsCMatrix", pivot = "logical")
:
Returns (and stores) the Cholesky decomposition of x
, see
chol
.
signature(A = "dsCMatrix",...)
:
Computes more flexibly Cholesky decompositions,
see Cholesky
.
signature(x = "dsCMatrix", logarithm =
"missing")
: Evaluate the determinant of x
on the
logarithm scale. This creates and stores the Cholesky factorization.
signature(x = "dsCMatrix", logarithm =
"logical")
: Evaluate the determinant of x
on the
logarithm scale or not, according to the logarithm
argument. This creates and stores the Cholesky factorization.
signature(x = "dsCMatrix")
: Transpose. As for all
symmetric matrices, a matrix for which the upper triangle is
stored produces a matrix for which the lower triangle is stored
and vice versa, i.e., the uplo
slot is swapped, and the row
and column indices are interchanged.
signature(x = "dsTMatrix")
: Transpose. The
uplo
slot is swapped from "U"
to "L"
or vice
versa, as for a "dsCMatrix"
, see above.
Classes dgCMatrix
, dgTMatrix
,
dgeMatrix
and those mentioned above.
mm <- Matrix(toeplitz(c(10, 0, 1, 0, 3)), sparse = TRUE)
mm # automatically dsCMatrix
str(mm)
mT <- as(as(mm, "generalMatrix"), "TsparseMatrix")
## Either
(symM <- as(mT, "symmetricMatrix")) # dsT
(symC <- as(symM, "CsparseMatrix")) # dsC
## or
sT <- Matrix(mT, sparse=TRUE, forceCheck=TRUE) # dsT
sym2 <- as(symC, "TsparseMatrix")
## --> the same as 'symM', a "dsTMatrix"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.