Learn R Programming

Matrix (version 0.3-19)

Matrix.class: Determine the subclass of a Matrix

Description

Matrix.class determines the class of a Matrix in the "Matrix" class structure. as.Matrix assigns the class determined by Matrix.class to the object x and returns the classed object.

Usage

Matrix.class(x, tol = 0, symmetry = TRUE, unit.diagonal = TRUE, 
             triangularity = c(TRUE, TRUE),
             orthogonality = c(TRUE, TRUE), 
             normality = c(TRUE, TRUE))
as.Matrix(x, tol = .Machine$double.eps)

Arguments

x
a numeric or complex matrix.
tol
tolerance for the various tests. The default is 0.
symmetry
a logical value indicating whether or not to test for symmetry (conjugate symmetry in the complex case). The default is to test for symmetry.
unit.diagonal
a logical value indicating whether or not to test for a unit diagonal. The default is to test for a unit diagonal.
triangularity
a logical vector of length indicating whether or not to test lower and/or upper triangularity, respectively. The default is to test for both lower and upper triangularity.
orthogonality
a logical vector of length indicating whether or not to test row and/or column orthogonality, respectively. The default is to test for both row and column orthogonality.
normality
a logical vector of length indicating whether or not to see if the rows and/or columns have norm one, respectively. The default is to test if both row and columns are normalized.

Value

  • Returns a class for the matrix, relative to the "Matrix" class structure. The matrix will be of class "Matrix", but there may also subclasses depending on the options chosen and their results.

See Also

is.Hermitian, is.LowerTriangular, is.Orthonormal.

Examples

Run this code
x <- hilbert(9)
Matrix.class(x) # should be "Hermitian", "Matrix"
x <- Matrix( rnorm(9), 3, 3)
Matrix.class(x) # should be "Matrix"
x[row(x) < col(x)] <- 0
Matrix.class(x) # should be "LowerTriangular" "Matrix"

Run the code above in your browser using DataLab