matrix.sparse {adelie} | R Documentation |
Creates a sparse matrix object.
Description
Creates a sparse matrix object.
Usage
matrix.sparse(mat, method = c("naive", "cov", "constraint"), n_threads = 1)
Arguments
mat |
A sparse matrix. |
method |
Method type, with default |
n_threads |
Number of threads. |
Value
Sparse matrix object. The object is an S4 class with methods for efficient computation by adelie.
Examples
n <- 100
p <- 20
X_dense <- matrix(rnorm(n * p), n, p)
X_sp <- as(X_dense, "dgCMatrix")
out <- matrix.sparse(X_sp, method="naive")
A_dense <- t(X_dense) %*% X_dense
A_sp <- as(A_dense, "dgCMatrix")
out <- matrix.sparse(A_sp, method="cov")
out <- matrix.sparse(X_sp, method="constraint")
[Package adelie version 1.0.8 Index]