Lower and Upper Triangular Part of a Sparse Matrix
lower.tri.Rd
Returns the lower or upper triangular structure or entries of a sparse matrix.
Details
Often not only the structure of the matrix is required but the
entries as well. For compatibility, the default is only a structure
consisting of ones (representing TRUE
s). Setting the flag
getOption( "spam.trivalues")
to TRUE
,
the function returns the actual
values.
See also
spam.options
and diag
Examples
smat <- spam( c( 1,2,0,3,0,0,0,4,5),3)
upper.tri( smat)
#> [,1] [,2] [,3]
#> [1,] 0 1 0
#> [2,] 0 0 1
#> [3,] 0 0 0
#> Class 'spam' (32-bit)
upper.tri( smat, diag=TRUE)
#> [,1] [,2] [,3]
#> [1,] 1 1 0
#> [2,] 0 0 1
#> [3,] 0 0 1
#> Class 'spam' (32-bit)
options(spam.trivalues=TRUE)
upper.tri( smat)
#> [,1] [,2] [,3]
#> [1,] 0 3 0
#> [2,] 0 0 4
#> [3,] 0 0 0
#> Class 'spam' (32-bit)