Test if a numeric matrix is orthonormal, that is, each column is orthogonal, at a right angle with the others, and each column has a norm length of 1. This must be true for a projection to be linear.

is_orthonormal(x, tol = 0.001)

Arguments

x

Numeric matrix to test the orthonormality of.

tol

Max tolerance of floating point differences of the element-wise distance of t(x) %*% x from the identity matrix.

Value

Single logical, whether or not the matrix is orthonormal.

Examples

is_orthonormal(tourr::basis_random(n = 6))
#> [1] TRUE
is_orthonormal(matrix(1:12, ncol = 2), tol = 0.01)
#> [1] FALSE