ltrMatrix-class.RdThe "ltrMatrix" class is the class of triangular, dense,
logical matrices in nonpacked storage. The "ltpMatrix" class
is the same except in packed storage.
x:Object of class "logical". The logical
values that constitute the matrix, stored in column-major order.
uplo:Object of class "character". Must be
either "U", for upper triangular, and "L", for lower triangular.
diag:Object of class "character". Must be
either "U", for unit triangular (diagonal is all ones), or
"N"; see triangularMatrix.
Dim,Dimnames:The dimension (a length-2
"integer") and corresponding names (or NULL), see the
Matrix class.
factors:Object of class "list". A named
list of factorizations that have been computed for the matrix.
Both extend classes "ldenseMatrix" and
"triangularMatrix", directly; further, class
"Matrix", "lMatrix" and others,
indirectly. Use showClass("ltrMatrix"), e.g.,
for details.
Currently, mainly t() and coercion methods (for
as(.); use, e.g.,
showMethods(class="ltrMatrix") for details.
showClass("ltrMatrix")
#> Class "ltrMatrix" [package "Matrix"]
#>
#> Slots:
#>
#> Name: Dim Dimnames x uplo diag
#> Class: integer list logical character character
#>
#> Extends:
#> Class "unpackedMatrix", directly
#> Class "ldenseMatrix", directly
#> Class "triangularMatrix", directly
#> Class "lMatrix", by class "ldenseMatrix", distance 2
#> Class "denseMatrix", by class "ldenseMatrix", distance 2
#> Class "Matrix", by class "triangularMatrix", distance 2
str(new("ltpMatrix"))
#> Formal class 'ltpMatrix' [package "Matrix"] with 5 slots
#> ..@ uplo : chr "U"
#> ..@ Dim : int [1:2] 0 0
#> ..@ Dimnames:List of 2
#> .. ..$ : NULL
#> .. ..$ : NULL
#> ..@ x : logi(0)
#> ..@ diag : chr "N"
(lutr <- as(upper.tri(matrix(, 4, 4)), "ldenseMatrix"))
#> 4 x 4 Matrix of class "ltrMatrix"
#> [,1] [,2] [,3] [,4]
#> [1,] FALSE TRUE TRUE TRUE
#> [2,] . FALSE TRUE TRUE
#> [3,] . . FALSE TRUE
#> [4,] . . . FALSE
str(lutp <- pack(lutr)) # packed matrix: only 10 = 4*(4+1)/2 entries
#> Formal class 'ltpMatrix' [package "Matrix"] with 5 slots
#> ..@ uplo : chr "U"
#> ..@ Dim : int [1:2] 4 4
#> ..@ Dimnames:List of 2
#> .. ..$ : NULL
#> .. ..$ : NULL
#> ..@ x : logi [1:10] FALSE TRUE FALSE TRUE TRUE FALSE ...
#> ..@ diag : chr "N"
!lutp # the logical negation (is *not* logical triangular !)
#> 4 x 4 Matrix of class "lgeMatrix"
#> [,1] [,2] [,3] [,4]
#> [1,] TRUE FALSE FALSE FALSE
#> [2,] TRUE TRUE FALSE FALSE
#> [3,] TRUE TRUE TRUE FALSE
#> [4,] TRUE TRUE TRUE TRUE
## but this one is:
stopifnot(all.equal(lutp, pack(!!lutp)))