Skip to content

closest_orthogonal_subspace

closest_orthogonal_subspace(A, B, M=None)

Projects A to its closest linear space that satisfies the constraints AB = 0 Solves the optimization problem : C = argmin_C ||C - A||_M^2 s.t. CB = 0

Parameters:

Name Type Description Default
A (n, d) float numpy array

Linear space

required
B (c, d) float numpy array

Linear space with which we want to be orthogonal

required
M (n, n) float sparse matrix

Mass metric with which we measure orthogonality (default=identity(n))

None

Returns:

Name Type Description
C (n, d) float numpy array

Projected linear space that is close to A while satisfying CB=0

Source code in src\fast_cody\closest_orthogonal_subspace.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def closest_orthogonal_subspace(A, B, M=None):
    """ Projects A to its closest linear space that satisfies the constraints AB = 0
        Solves the optimization problem :
        ```
        C = argmin_C ||C - A||_M^2 s.t. CB = 0
        ```
    Parameters
    ----------
    A : (n, d) float numpy array
        Linear space
    B : (c, d) float numpy array
        Linear space with which we want to be orthogonal
    M : (n, n) float sparse matrix
        Mass metric with which we measure orthogonality (default=identity(n))

    Returns
    -------
    C : (n, d) float numpy array
        Projected linear space that is close to A while satisfying CB=0

    """
    if M is None:
        M = sp.sparse.identity(A.shape[0])
    c = B.shape[0]

    BMA = B.T @ M @ A


    BMB = B.T @ M @ B
    BMBBMA = sp.sparse.linalg.spsolve(BMB, BMA)
    A2 = A - B @ BMBBMA
    return A2