| isTriangular-methods | R Documentation |
isTriangular and isDiagonal test whether their argument
is a triangular or diagonal matrix, respectively. Unlike the analogous
isSymmetric, these two functions are generically
from Matrix rather than base. Hence Matrix
defines methods for traditional matrices of implicit class
"matrix" in addition to matrices inheriting from
virtual class "Matrix".
By our definition, triangular and diagonal matrices are square, i.e., they have the same number of rows and columns.
isTriangular(object, upper = NA)
isDiagonal(object)
object |
an R object, typically a matrix. |
upper |
a logical, either |
A logical, either TRUE or FALSE
(never NA).
If object is triangular and upper is NA, then
isTriangular returns TRUE with an attribute
kind, either "U" or "L", indicating that
object is upper or lower triangular, respectively.
Users should not rely on how kind is determined for diagonal
matrices, which are both upper and lower triangular.
isSymmetric;
virtual classes "triangularMatrix" and
"diagonalMatrix" and their subclasses.
isTriangular(Diagonal(4))
## is TRUE: a diagonal matrix is also (both upper and lower) triangular
(M <- Matrix(c(1,2,0,1), 2,2))
isTriangular(M) # TRUE (*and* of formal class "dtrMatrix")
isTriangular(as(M, "generalMatrix")) # still triangular, even if not "formally"
isTriangular(crossprod(M)) # FALSE
isDiagonal(matrix(c(2,0,0,1), 2,2)) # TRUE
## Look at implementations:
showMethods("isTriangular", includeDefs = TRUE)
showMethods("isDiagonal", includeDefs = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.