bundles / scipy 1.17.1 / scipy / linalg / _decomp_svd / subspace_angles
function
scipy.linalg._decomp_svd:subspace_angles
Signature
def subspace_angles ( A , B ) Summary
Compute the subspace angles between two matrices.
Extended Summary
The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.
Parameters
A: (M, N) array_likeThe first input array.
B: (M, K) array_likeThe second input array.
Returns
angles: ndarray, shape (min(N, K),)The subspace angles between the column spaces of
AandBin descending order.
Notes
This computes the subspace angles according to the formula provided in [1]. For equivalence with MATLAB and Octave behavior, use angles[0].
Examples
An Hadamard matrix, which has orthogonal columns, so we expect that the suspace angle to be :math:`\frac{\pi}{2}`:import numpy as np from scipy.linalg import hadamard, subspace_angles rng = np.random.default_rng() H = hadamard(4) print(H)✓
np.rad2deg(subspace_angles(H[:, :2], H[:, 2:]))
✗subspace_angles(H[:, :2], H[:, :2]) <= 2 * np.finfo(float).eps
✗x = rng.standard_normal((4, 3))
✓np.rad2deg(subspace_angles(x[:, :2], x[:, [2]]))
✗See also
- orth
- svd
Aliases
-
scipy.linalg.subspace_angles