ldiMatrix-class.Rd
The class "ldiMatrix"
of logical diagonal matrices.
Objects can be created by calls of the form new("ldiMatrix", ...)
but typically rather via Diagonal
.
Class "diagonalMatrix"
and
class "lMatrix"
, directly.
Class "sparseMatrix"
, by class "diagonalMatrix"
.
Classes ddiMatrix
and
diagonalMatrix
; function Diagonal
.
(lM <- Diagonal(x = c(TRUE,FALSE,FALSE)))
#> 3 x 3 diagonal matrix of class "ldiMatrix"
#> [,1] [,2] [,3]
#> [1,] TRUE . .
#> [2,] . FALSE .
#> [3,] . . FALSE
str(lM)#> gory details (slots)
#> Formal class 'ldiMatrix' [package "Matrix"] with 4 slots
#> ..@ diag : chr "N"
#> ..@ Dim : int [1:2] 3 3
#> ..@ Dimnames:List of 2
#> .. ..$ : NULL
#> .. ..$ : NULL
#> ..@ x : logi [1:3] TRUE FALSE FALSE
crossprod(lM) # numeric
#> 3 x 3 diagonal matrix of class "ddiMatrix"
#> [,1] [,2] [,3]
#> [1,] 1 . .
#> [2,] . 0 .
#> [3,] . . 0
(nM <- as(lM, "nMatrix"))
#> 3 x 3 diagonal matrix of class "ndiMatrix"
#> [,1] [,2] [,3]
#> [1,] TRUE . .
#> [2,] . FALSE .
#> [3,] . . FALSE
crossprod(nM) # pattern sparse
#> 3 x 3 diagonal matrix of class "ddiMatrix"
#> [,1] [,2] [,3]
#> [1,] 1 . .
#> [2,] . 0 .
#> [3,] . . 0