This function calculates the distance between the two subspaces with equal dimensions \(\mathrm{span}(\mathbf{A})\) and \(\mathrm{span}(\mathbf{B})\), where \(\mathbf{A}\in R^{p\times u}\) and \(\mathbf{B} \in R^{p\times u}\) are the basis matrices of two subspaces. The distance is defined as $$\|\mathbf{P}_{\mathbf{A}} - \mathbf{P}_{\mathbf{B}}\|_F/(2d),$$ where \(\mathbf{P(\cdot)}\) is the projection matrix onto the given subspace with the standard inner product, and \(d\) is the common dimension.
subspace(A, B)
A \(p\)-by-\(u\) matrix.
A \(p\)-by-\(u\) matrix.
Returns a distance metric that is between 0 and 1