matrix_rank: Rank of a Matrix

Description Usage Arguments Details Value Author(s) References Examples

Description

Determine the rank (number of linearly independent columns) of a matrix.

Usage

1

Arguments

x

a numeric matrix

Details

Implimentation via the Armadillo C++ linear algrebra library. The function returns the rank of the matix x. The computation is based on the singular value decomposition of the matrix; a std::runtime_error excetion will be thrown if the decomposition fails. Any singular values less than the tolerance are treated as zeros. The tolerance is max(m, n) * max_sv * datum::eps, where m is the number of rows of x, n is the number of columns of x, max_sv is the maximal singular value of x, and datum::eps is the difference between 1 and the least value greater than 1 that is representable.

Value

the rank of the matrix as a numeric value.

Author(s)

Peter DeWitt dewittpe@gmail.com

References

Conrad Sanderson and Ryan Curtin. Armadillo: a template-based C++ library for linear algebra. Journal of Open Source Software, Vol. 1, pp. 26, 2016.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Check the rank of a matrix
mat <- matrix(rnorm(25000 * 120), nrow = 25000)
Matrix::rankMatrix(mat)[1]
matrix_rank(mat)

# A full rank B-spline basis
bmat <- bsplines(seq(0, 1, length = 100), df = 15)
matrix_rank(bmat)

# A rank deficient B-spline basis
bmat <- bsplines(seq(0, 1, length = 100), iknots = c(0.001, 0.002))
ncol(bmat)
matrix_rank(bmat)

cpr documentation built on May 1, 2019, 10:46 p.m.