# SparseM.ontology

0th

Percentile

##### Sparse Matrix Class

This group of functions evaluates and coerces changes in class structure.

Keywords
algebra
##### Usage
# S3 method for matrix.csr
as(x, nrow = 1, ncol = 1, eps = .Machine$double.eps, ...) # S3 method for matrix.csc as(x, nrow = 1, ncol = 1, eps = .Machine$double.eps, ...)
# S3 method for matrix.ssr
as(x, nrow = 1, ncol = 1, eps = .Machine$double.eps, ...) # S3 method for matrix.ssc as(x, nrow = 1, ncol = 1, eps = .Machine$double.eps, ...)
# S3 method for matrix.csr
is(x, ...)
# S3 method for matrix.csc
is(x, ...)
# S3 method for matrix.ssr
is(x, ...)
# S3 method for matrix.ssc
is(x, ...)
##### Arguments
x

is a matrix, or vector object, of either dense or sparse form

nrow

number of rows of matrix

ncol

number of columns of matrix

eps

A tolerance parameter: elements of x such that abs(x) < eps set to zero. This argument is only relevant when coercing matrices from dense to sparse form. Defaults to eps = .Machine\$double.eps

...

other arguments

##### Details

The function matrix.csc acts like matrix to coerce a vector object to a sparse matrix object of class matrix.csr. This aspect of the code is in the process of conversion from S3 to S4 classes. For the most part the S3 syntax prevails. An exception is the code to coerce vectors to diagonal matrix form which uses as(v,"matrix.diag.csr". The generic functions as.matrix.xxx coerce a matrix x into a matrix of storage class matrix.xxx. The argument matrix x may be of conventional dense form, or of any of the four supported classes: matrix.csr, matrix.csc, matrix.ssr, matrix.ssc. The generic functions is.matrix.xxx evaluate whether the argument is of class matrix.xxx. The function as.matrix transforms a matrix of any sparse class into conventional dense form. The primary storage class for sparse matrices is the compressed sparse row matrix.csr class. An n by m matrix A with real elements $a_{ij}$, stored in matrix.csr format consists of three arrays:

• ra: a real array of nnz elements containing the non-zero elements of A, stored in row order. Thus, if i<j, all elements of row i precede elements from row j. The order of elements within the rows is immaterial.

• ja: an integer array of nnz elements containing the column indices of the elements stored in ra.

• ia: an integer array of n+1 elements containing pointers to the beginning of each row in the arrays ra and ja. Thus ia[i] indicates the position in the arrays ra and ja where the ith row begins. The last, (n+1)st, element of ia indicates where the n+1 row would start, if it existed.

The compressed sparse column class matrix.csc is defined in an analogous way, as are the matrix.ssr, symmetric sparse row, and matrix.ssc, symmetric sparse column classes.

##### Note

as.matrix.ssr and as.matrix.ssc should ONLY be used with symmetric matrices.

as.matrix.csr(x), when x is an object of class matrix.csr.chol (that is, an object returned by a call to chol(a) when a is an object of class matrix.csr or matric.csc), by default returns an upper triangular matrix, which is not consistent with the result of chol in the base package. To get an lower triangular matric.csr matrix, use either as.matrix.csr(x, upper.tri = FALSE) or t(as.matrix.csr(x)).

##### References

Koenker, R and Ng, P. (2002). SparseM: A Sparse Matrix Package for R, http://www.econ.uiuc.edu/~roger/research

SparseM.hb for handling Harwell-Boeing sparse matrices.

##### Aliases
• SparseM.ontology
• matrix.csr
• matrix.csc
• initialize,ANY-method
• initialize,matrix.csr-method
• initialize,matrix.coo-method
• coerce,vector,matrix.diag.csr-method
• coerce,matrix,matrix.csr-method
• coerce,matrix.csr,matrix.diag.csr-method
• coerce,vector,matrix.csr-method
• coerce,numeric,matrix.diag.csr-method
• as.matrix,ANY-method
• as.matrix,matrix.csr-method
• as.matrix,csr-method
• is.matrix,csr-methods
• as.matrix,csc-methods
• is.matrix,csc-methods
• as.matrix,ssr-methods
• is.matrix,ssr-methods
• as.matrix,ssc-methods
• is.matrix,ssc-methods
• as.matrix,coo-methods
• is.matrix,coo-methods
• as.matrix.csr,ANY-method
• as.matrix.csr,matrix.csc-method
• as.matrix.csr,matrix.ssr-method
• as.matrix.csr,matrix.ssc-method
• as.matrix.csr,matrix.coo-method
• as.matrix.csr,matrix.csr.chol-method
• as.matrix.csc,ANY-method
• as.matrix.csc,matrix.csr-method
• as.matrix.csc,matrix.csc-method
• as.matrix.csc,matrix.ssr-method
• as.matrix.csc,matrix.ssc-method
• as.matrix.csc,matrix.coo-method
• as.matrix.ssr,ANY-method
• as.matrix.ssr,matrix.csc-method
• as.matrix.ssr,matrix.ssr-method
• as.matrix.ssr,matrix.ssc-method
• as.matrix.ssr,matrix.coo-method
• as.matrix.ssc,ANY-method
• as.matrix.ssc,matrix.csr-method
• as.matrix.ssc,matrix.csc-method
• as.matrix.ssc,matrix.ssr-method
• as.matrix.ssc,matrix.ssc-method
• as.matrix.ssc,matrix.coo-method
• as.matrix.coo,ANY-method
• as.matrix.coo,matrix.csr-method
• as.matrix.coo,matrix.csc-method
• as.matrix.coo,matrix.ssr-method
• as.matrix.coo,matrix.ssc-method
• as.matrix.coo,matrix.coo-method
• as.matrix,matrix.csc-method
• as.matrix,matrix.ssc-method
• as.matrix,matrix.ssr-method
• as.matrix,matrix.coo-method
• matrix.ssc
• as.matrix.ssc,matrix.csc-method
• as.matrix.ssc.matrix.csr-method
• as.matrix.ssc,matrix.ssr-method
• matrix.ssr
• as.matrix.ssr,matrix.csc-method
• as.matrix.ssr,matrix.csr-method
• as.matrix.ssr,matrix.ssc-method
• is.matrix.csr
• is.matrix.csc
• is.matrix.ssr
• is.matrix.ssc
• is.matrix.coo
• is.matrix.csr
• as.matrix.csr
• as.matrix.csc
• as.matrix.ssr
• as.matrix.ssc
• as.matrix.coo
##### Examples
# NOT RUN {
n1 <- 10
p <- 5
a <- rnorm(n1*p)
a[abs(a)<0.5] <- 0
A <- matrix(a,n1,p)
B <- t(A)%*%A
A.csr <- as.matrix.csr(A)
A.csc <- as.matrix.csc(A)
B.ssr <- as.matrix.ssr(B)
B.ssc <- as.matrix.ssc(B)
is.matrix.csr(A.csr) # -> TRUE
is.matrix.csc(A.csc) # -> TRUE
is.matrix.ssr(B.ssr) # -> TRUE
is.matrix.ssc(B.ssc) # -> TRUE
as.matrix(A.csr)
as.matrix(A.csc)
as.matrix(B.ssr)
as.matrix(B.ssc)
as.matrix.csr(rep(0,9),3,3) #sparse matrix of all zeros
as(4,"matrix.diag.csr") #identity matrix of dimension 4
# }

Documentation reproduced from package SparseM, version 1.78, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.