sparseMatrix-class {Matrix}R Documentation

Virtual Class "sparseMatrix" — Mother of Sparse Matrices

Description

Virtual Mother Class of All Sparse Matrices

Slots

Dim:
Object of class "integer" - the dimensions of the matrix - must be an integer vector with exactly two non-negative values.
Dimnames:
a list of length two - inherited from class Matrix, see Matrix.
factors:
Object of class "list" - a list of factorizations of the matrix.

Extends

Class "Matrix", directly.

Methods

show
(object = "sparseMatrix"): The show method for sparse matrices prints “structural” zeroes as "." using the non-exported prSpMatrix function which allows further customization such as replacing "." by " " (blank).

Note that options(max.print) will influence how many entries of large matrices are printed at all.

summary
(object = "sparseMatrix"): Returns an object of S3 class "sparseSummary" which is basically a data.frame with columns (i,j,x) with the non-zero entries. The print method resemble's Matlab's way of printing sparse matrices.
diag
(x = "sparseMatrix"): extracts the diagonal of a sparse matrix.
dim<-
signature(x = "sparseMatrix", value = "ANY"): allows to reshape a sparse matrix to a sparse matrix with the same entries but different dimensions. value must be of length two and fulfill prod(value) == prod(dim(x)).

See also colSums, ... for methods with separate help pages.

Note

In method selection for multiplication operations (i.e. %*% and the two-argument form of crossprod) the sparseMatrix class takes precedence in the sense that if one operand is a sparse matrix and the other is any type of dense matrix then the dense matrix is coerced to a dgeMatrix and the appropriate sparse matrix method is used.

Examples

showClass("sparseMatrix") ## and look at the help() of its subclasses
M <- Matrix(0, 10000, 100)
M[1,1] <- M[2,3] <- 3.14
M


[Package Matrix version 0.99875-2 Index]