scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
subspace_angles(A, B)

Notes

This computes the subspace angles according to the formula provided in . For equivalence with MATLAB and Octave behavior, use angles[0] .

versionadded

Parameters

A : (M, N) array_like

The first input array.

B : (M, K) array_like

The second input array.

Returns

angles : ndarray, shape (min(N, K),)

The subspace angles between the column spaces of A and B in descending order.

Compute the subspace angles between two matrices.

See Also

orth
svd

Examples

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))
... np.rad2deg(subspace_angles(x[:, :2], x[:, [2]])) array([ 55.832]) # random
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.linalg._decomp_svd.subspace_angles

Local connectivity graph

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


GitHub : /scipy/linalg/_decomp_svd.py#394
type: <class 'function'>
Commit: