Skip to contents

Compute the rank of a matrix using the singular value decomposition (SVD) method.

Usage

matrix_rank(x, tol)

# Default S3 method
matrix_rank(x, tol)

# S3 method for class 'matrix'
matrix_rank(x, tol)

# S3 method for class 'data.frame'
matrix_rank(x, tol)

Arguments

x

A matrix.

tol

Threshold below which SVD values are considered zero.

Details

The singular value decomposition (SVD) method simply computes the SVD of x and returns the number of singular values of x that are greater than tol. See Matrix::rankMatrix() for alternative methods.

Examples

matrix_rank(1:5)
#> [1] 1
matrix_rank(randn(2, 2))
#> [1] 2
matrix_rank(cbind(c(1, 1, 1), c(2, 2, 2)))
#> [1] 1
matrix_rank(ones(3, 3))
#> [1] 1
matrix_rank(zeros(3, 5))
#> [1] 0