matrix.coo-class function

Class "matrix.coo" -- Sparse Matrices in [Coo]rdinate Format

Class "matrix.coo" -- Sparse Matrices in [Coo]rdinate Format

Class for sparse matrices stored in coordinate aka triplet format, storing for each non-zero entry x[i,j]

the triplet (i,j, x[i,j]), in slots (ia, ja, ra).

class

Objects from the Class

Objects can be created by calls of the form new("matrix.coo", ...), but typically rather by as.matrix.coo().

Slots

  • ra:: Object of class numeric, a real array of nnz elements containing the non-zero elements of A.
  • ja:: Object of class integer, an integer array of nnz elements containing the column indices of the elements stored in `ra'.
  • ia:: Object of class integer, an integer array of nnz elements containing the row indices of the elements stored in `ra'.
  • dimension:: Object of class integer, dimension of the matrix

Methods

  • as.matrix.coo: signature(x = "matrix.coo"): ...
  • as.matrix.csr: signature(x = "matrix.coo"): ...
  • as.matrix: signature(x = "matrix.coo"): ...
  • dim: signature(x = "matrix.coo"): ...

See Also

matrix.csr-class

Examples

try( new("matrix.coo") ) # fails currently {FIXME!} # the 1x1 matrix [0] ## correponds to base matrix() mcoo <- new("matrix.coo", ra=NA_real_, ia = 1L, ja = 1L, dimension = c(1L, 1L)) mcoo # currently *does* print but wrongly: as.matrix.csr(<matrix.coo>) fails to keep NA !! co2 <- new("matrix.coo", ra = c(-Inf, -2, 3, Inf), ia = c(1L,1:3), ja = 2L*(1:4), dimension = c(7L, 12L)) co2 # works fine (as has no NA) ## Sparse Diagonal (from "numeric"): as(1:5, "matrix.diag.csr") # a sparse version of diag(1:5)