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
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)
an R object, typically a matrix.
a logical, either
further arguments passed to methods (currently unused by Matrix).
A logical, either
object is triangular and
TRUE with an attribute
"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.
"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.