Triangular Dense Logical Matrices
ntrMatrix-class.RdThe "ntrMatrix" class is the class of triangular, dense,
logical matrices in nonpacked storage. The "ntpMatrix" class
is the same except in packed storage.
Slots
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"; seetriangularMatrix.Dim,Dimnames:The dimension (a length-2
"integer") and corresponding names (orNULL), see theMatrixclass.factors:Object of class
"list". A named list of factorizations that have been computed for the matrix.
Extends
"ntrMatrix" extends class "ngeMatrix", directly, whereas"ntpMatrix" extends class "ndenseMatrix", directly.
Both extend Class "triangularMatrix", directly,
and class "denseMatrix", "lMatrix" and others,
indirectly, use showClass("nsyMatrix"), e.g., for
details.
Methods
Currently, mainly t() and coercion methods (for
as(.); use, e.g.,
showMethods(class="ntrMatrix") for details.
Examples
showClass("ntrMatrix")
#> Class "ntrMatrix" [package "Matrix"]
#>
#> Slots:
#>
#> Name: Dim Dimnames x uplo diag
#> Class: integer list logical character character
#>
#> Extends:
#> Class "unpackedMatrix", directly
#> Class "ndenseMatrix", directly
#> Class "triangularMatrix", directly
#> Class "nMatrix", by class "ndenseMatrix", distance 2
#> Class "denseMatrix", by class "ndenseMatrix", distance 2
#> Class "Matrix", by class "triangularMatrix", distance 2
str(new("ntpMatrix"))
#> Formal class 'ntpMatrix' [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"
(nutr <- as(upper.tri(matrix(, 4, 4)), "ndenseMatrix"))
#> 4 x 4 Matrix of class "ntrMatrix"
#> [,1] [,2] [,3] [,4]
#> [1,] FALSE TRUE TRUE TRUE
#> [2,] . FALSE TRUE TRUE
#> [3,] . . FALSE TRUE
#> [4,] . . . FALSE
str(nutp <- pack(nutr)) # packed matrix: only 10 = 4*(4+1)/2 entries
#> Formal class 'ntpMatrix' [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"
!nutp # the logical negation (is *not* logical triangular !)
#> 4 x 4 Matrix of class "ngeMatrix"
#> [,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(nutp, pack(!!nutp)))