| lsparseMatrix-classes {Matrix} | R Documentation |
The lsparseMatrix class is a virtual class of sparse
matrices with TRUE/FALSE entries. Only the positions of the
elements that are TRUE are stored. These can be stored in the
``triplet'' form (classes lgTMatrix, lsTMatrix, and
ltTMatrix which really contain pairs, not triplets) or in
compressed column-oriented form (classes lgCMatrix,
lsCMatrix, and ltCMatrix) or in compressed row-oriented
form (classes lgRMatrix, lsRMatrix, and
ltRMatrix). The second letter in the name of these non-virtual
classes indicates general, symmetric, or triangular.
Objects can be created by calls of the form new("lgCMatrix",
...) and so on. More frequently objects are created by coercion of
a numeric sparse matrix to the logical form for use in
the symbolic analysis phase
of an algorithm involving sparse matrices. Such algorithms often
involve two phases: a symbolic phase wherein the positions of the
non-zeros in the result are determined and a numeric phase wherein the
actual results are calculated. During the symbolic phase only the
positions of the non-zero elements in any operands are of interest,
hence any numeric sparse matrices can be treated as logical sparse
matrices.
uplo:"character". Must be
either "U", for upper triangular, and "L", for lower
triangular. Present in the triangular and symmetric classes but not
in the general class.diag:"character". Must be
either "U", for unit triangular (diagonal is all ones), or
"N" for non-unit. The implicit diagonal elements are not
explicitly stored when diag is "U". Present in the
triangular classes only.p:"integer" of pointers, one
for each column (row), to the initial (zero-based) index of elements in
the column. Present in compressed column-oriented and compressed
row-oriented forms only.i:"integer" of length nnzero
(number of non-zero elements). These are the row numbers for
each TRUE element in the matrix. All other elements are FALSE.
Present in triplet and compressed column-oriented forms only.j:"integer" of length nnzero
(number of non-zero elements). These are the column numbers for
each TRUE element in the matrix. All other elements are FALSE.
Present in triplet and compressed column-oriented forms only.Dim:"integer" - the dimensions
of the matrix.signature(from = "dgCMatrix", to = "lgCMatrix")signature(x = "lgCMatrix"): returns the transpose
of x
m <- Matrix(c(0,0,2:0), 3,5, dimnames=list(LETTERS[1:3],NULL))
(dm <- as(m, "dgCMatrix"))# no dimnames for sparse here
(lm <- as(dm, "lgCMatrix"))
str(lm)
data(KNex)
lmm <- as(KNex $ mm, "lgCMatrix")
xlx <- crossprod(lmm)
image(xlx, main=paste("crossprod(lmm) : Sparse", class(xlx)))