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).

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

Examples

 try(  new("matrix.coo") ) # fails currently {FIXME!}     # the 1x1 matrix [0]
#> Error in validObject(.Object) : 
#>   invalid class “matrix.coo” object: invalid dimension attribute

 ## 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 !!
#> Sparse matrix of class "matrix.coo" {use 'str(.)' to see the inner structure}:
#>      [,1]
#> [1,]    .
 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 matrix of class "matrix.coo" {use 'str(.)' to see the inner structure}:
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,]    . -Inf    .   -2    .    .    .    .    .     .     .     .
#> [2,]    .    .    .    .    .    3    .    .    .     .     .     .
#> [3,]    .    .    .    .    .    .    .  Inf    .     .     .     .
#> [4,]    .    .    .    .    .    .    .    .    .     .     .     .
#> [5,]    .    .    .    .    .    .    .    .    .     .     .     .
#> [6,]    .    .    .    .    .    .    .    .    .     .     .     .
#> [7,]    .    .    .    .    .    .    .    .    .     .     .     .

 ## Sparse Diagonal (from "numeric"):
 as(1:5, "matrix.diag.csr") # a sparse version of  diag(1:5)
#> Sparse matrix of class "matrix.diag.csr" {use 'str(.)' to see the inner structure}:
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    .    .    .    .
#> [2,]    .    2    .    .    .
#> [3,]    .    .    3    .    .
#> [4,]    .    .    .    4    .
#> [5,]    .    .    .    .    5