Skip to contents

The class "ldiMatrix" of logical diagonal matrices.

Objects from the Class

Objects can be created by calls of the form new("ldiMatrix", ...) but typically rather via Diagonal.

Slots

x:

"logical" vector.

diag:

"character" string, either "U" or "N", see ddiMatrix.

Dim,Dimnames:

matrix dimension and dimnames, see the Matrix class description.

Extends

Class "diagonalMatrix" and class "lMatrix", directly.

Class "sparseMatrix", by class "diagonalMatrix".

See also

Classes ddiMatrix and diagonalMatrix; function Diagonal.

Examples

(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