Zero-based Wrapper for Sparse Matrices
Zero-based Wrapper for Sparse Matrices
Details
matrixZeroBasedView
is a wrapper shim for a matrix or
Matrix::sparseMatrix
that allows
elemental matrix access using zero-based indices.
Methods
Method sum()
Perform arithmetic sum between this
matrixZeroBasedView
and another matrixZeroBasedView
.
Examples
(mat <- Matrix::rsparsematrix(3L, 3L, 0.3))
#> 3 x 3 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 0.84 .
#> [2,] -0.27 . .
#> [3,] . 0.24 .
(mat0 <- matrixZeroBasedView$new(mat))
#> Non-mutable 0-based 'view' class for matrices.
#> To get 1-based matrix use `x$get_one_based_matrix()
#> Dimensions: 3x3
mat0$take(0, 0)
#> Non-mutable 0-based 'view' class for matrices.
#> To get 1-based matrix use `x$get_one_based_matrix()
#> Dimensions: 1x1
mat0$take(0, 0:2)$get_one_based_matrix()
#> 1 x 3 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 0.84 .