subspace_angles(A, B)
This computes the subspace angles according to the formula provided in . For equivalence with MATLAB and Octave behavior, use angles[0]
.
The subspace angles between the column spaces of A
and B
in descending order.
Compute the subspace angles between two matrices.
An Hadamard matrix, which has orthogonal columns, so we expect that the suspace angle to be $\frac{\pi}{2}$ :
>>> from numpy.random import default_rng
... from scipy.linalg import hadamard, subspace_angles
... rng = default_rng()
... H = hadamard(4)
... print(H) [[ 1 1 1 1] [ 1 -1 1 -1] [ 1 1 -1 -1] [ 1 -1 -1 1]]
>>> np.rad2deg(subspace_angles(H[:, :2], H[:, 2:])) array([ 90., 90.])
And the subspace angle of a matrix to itself should be zero:
>>> subspace_angles(H[:, :2], H[:, :2]) <= 2 * np.finfo(float).eps array([ True, True], dtype=bool)
The angles between non-orthogonal subspaces are in between these extremes:
>>> x = rng.standard_normal((4, 3))See :
... np.rad2deg(subspace_angles(x[:, :2], x[:, [2]])) array([ 55.832]) # random
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.linalg._decomp_svd.subspace_angles
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them