# SparseM.ops

0th

Percentile

##### Basic Linear Algebra for Sparse Matrices

Basic linear algebra operations for sparse matrices of class matrix.csr.

Keywords
algebra
##### Arguments
x

matrix of class matrix.csr.

y

matrix of class matrix.csr or a dense matrix or vector.

value

replacement values.

i,j

vectors of elements to extract or replace.

nrow

optional number of rows for the result.

lag

an integer indicating which lag to use.

differences

an integer indicating the order of the difference.

##### Details

Linear algebra operations for matrices of class matrix.csr are designed to behave exactly as for regular matrices. In particular, matrix multiplication, kronecker product, addition, subtraction and various logical operations should work as with the conventional dense form of matrix storage, as does indexing, rbind, cbind, and diagonal assignment and extraction. The method diag may be used to extract the diagonal of a matrix.csr object, to create a sparse diagonal see SparseM.ontology.

The function determinant computes the (log) determinant, of the argument, returning a "det" object as the base function. This is preferred over using the function det() which is a simple wrapper for determinant(). Using det() in the following way is somewhat deprecated:

det() computes the determinant of the argument matrix. If the matrix is of class matrix.csr then it must be symmetric, or an error will be returned. If the matrix is of class matrix.csr.chol then the determinant of the Cholesky factor is returned, ie the product of the diagonal elements.

The function norm is used to check for symmetry by computing the maximum of the elements of the difference between the matrix and its transpose. Optionally, this sup norm can be replaced by the Hilbert-Schmidt norm, or the l1 norm.

##### References

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

slm for sparse linear model fitting. SparseM.ontology for coercion and other class relations involving the sparse matrix classes.

##### Aliases
• Ops.matrix.csr
• Ops.matrix.diag.csr
• %*%-methods
• %*%,ANY,ANY-method
• %*%,matrix.csr,matrix.csr-method
• %*%,matrix.csr,matrix-method
• %*%,matrix.csr,numeric-method
• %*%,matrix,matrix.csr-method
• %*%,numeric,matrix.csr-method
• kronecker-methods
• kronecker,matrix.csr,matrix.csr-method
• kronecker,matrix.csr,matrix-method
• kronecker,matrix.csr,numeric-method
• kronecker,matrix,matrix.csr-method
• kronecker,numeric,matrix.csr-method
• +,matrix.csr-method
• -,matrix.csr-method
• *,matrix.csr-method
• /,matrix.csr-method
• ^,matrix.csr-method
• %%,matrix.csr-method
• %/%,matrix.csr-method
• >,matrix.csr-method
• >=,matrix.csr-method
• <,matrix.csr-method
• <=,matrix.csr-method
• ==,matrix.csr-method
• !=,matrix.csr-method
• &,matrix.csr-method
• |,matrix.csr-method
• norm
• norm,ANY-method
• norm,matrix.csr-method
• norm,matrix.csr,character-method
• norm,matrix.csr,missing-method
• det,ANY-method
• det,matrix-method
• det,matrix.csr-method
• det,matrix.csr.chol-method
• determinant,matrix.csr.chol,missing-method
• determinant,matrix.csr.chol,logical-method
• determinant,matrix.csr,missing-method
• determinant,matrix.csr,logical-method
• t,ANY-method
• t,matrix.csr-method
• t,matrix.csc-method
• t,matrix.coo-method
• diag,ANY-method
• diag,matrix.csr-method
• diag<-,ANY-method
• diag<-,matrix.csr-method
• diag<-,matrix.diag.csr-method
• diff,matrix.csr-method
• diff<-,ANY-method
• diff<-,matrix.csr-method
• diag.assign,matrix.csr-method
• ncol,matrix.csr-method
• nrow,matrix.csr-method
• dim,ANY-method
• dim,matrix.csr-method
• dim,matrix.csc-method
• dim,matrix.ssr-method
• dim,matrix.ssc-method
• dim,matrix.coo-method
• rbind.matrix.csr
• cbind.matrix.csr
• [.matrix.csr
• [.matrix.diag.csr
• [<-.matrix.csr
• [<-.matrix.diag.csr
• [.matrix.coo
• [<-.matrix.coo
##### Examples
# NOT RUN {
n1 <- 10
n2 <- 10
p <- 6
y <- rnorm(n1)
a <- rnorm(n1*p)
a[abs(a) < 0.5] <- 0
A <- matrix(a,n1,p)
A.csr <- as.matrix.csr(A)
b <- rnorm(n2*p)
b[abs(b)<1.0] <- 0
B <- matrix(b,n2,p)
B.csr <- as.matrix.csr(B)

# matrix transposition and multiplication
A.csr%*%t(B.csr)

# kronecker product - via kronecker() methods:
A.csr %x% matrix(1:4,2,2)
# }

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

### Community examples

Looks like there are no examples yet.