Skip to contents

Checks that X has n * k columns and that every row, reshaped as an n x k matrix \(U\) (column by column), has orthonormal columns, \(U^T U = I_k\), up to tol (see manifold_grassmann).

Usage

is_in_grassmann(X, n, k, tol = 1e-06)

Arguments

X

A matrix or data frame of (nominally) Grassmann data; rows are samples, with n * k columns.

n

Integer: dimension of the ambient space.

k

Integer: dimension of the subspaces, 1 <= k <= n - 1.

tol

Tolerance on the entries of \(U^T U - I_k\). Defaults to 1e-6.

Value

Logical: TRUE if every row of X represents a point of \(Gr(n, k)\), FALSE otherwise.

Examples

X <- exp_map_grassmann(matrix(rnorm(40, sd = 0.3), nrow = 10), diag(4)[, 1:2])
is_in_grassmann(X, n = 4, k = 2)
#> [1] TRUE

is_in_grassmann(matrix(runif(80), nrow = 10), n = 4, k = 2)
#> [1] FALSE