Skip to content

cagpjax.linalg.orthogonalize

Orthogonalization methods.

OrthogonalizationMethod

Bases: Enum

Methods for orthogonalizing a matrix.

Source code in src/cagpjax/linalg/orthogonalize.py
class OrthogonalizationMethod(Enum):
    """Methods for orthogonalizing a matrix."""

    QR = "qr"
    """Householder QR decomposition"""
    CGS = "cgs"
    """Classical Gram–Schmidt orthogonalization"""
    MGS = "mgs"
    """Modified Gram–Schmidt orthogonalization"""

CGS = 'cgs' class-attribute instance-attribute

Classical Gram–Schmidt orthogonalization

MGS = 'mgs' class-attribute instance-attribute

Modified Gram–Schmidt orthogonalization

QR = 'qr' class-attribute instance-attribute

Householder QR decomposition

orthogonalize(A, /, method=OrthogonalizationMethod.QR, n_reortho=0)

Orthogonalize the operator using the specified method.

The columns of the resulting matrix should span a (super-)space of the columns of the input matrix and be mutually orthogonal. For column-rank-deficient matrices, some methods (e.g. Gram-Schmidt variants) may include columns of norm 0.

Parameters:

Name Type Description Default
A Float[Array, 'm n'] | LinearOperator

The operator to orthogonalize.

required
method OrthogonalizationMethod

The method to use for orthogonalization.

QR
n_reortho int

The number of times to re-orthogonalize each column. Reorthogonalizing once is generally sufficient to improve orthogonality for Gram-Schmidt variants (see e.g. 10.1007/s00211-005-0615-4).

0

Returns:

Type Description
Float[Array, 'm n'] | LinearOperator

The orthogonalized operator. If the input is a LinearOperator, then so is the output.

Source code in src/cagpjax/linalg/orthogonalize.py
def orthogonalize(
    A: Float[Array, "m n"] | cola.ops.LinearOperator,
    /,
    method: OrthogonalizationMethod = OrthogonalizationMethod.QR,
    n_reortho: int = 0,
) -> Float[Array, "m n"] | cola.ops.LinearOperator:
    """
    Orthogonalize the operator using the specified method.

    The columns of the resulting matrix should span a (super-)space of the columns of
    the input matrix and be mutually orthogonal. For column-rank-deficient matrices,
    some methods (e.g. Gram-Schmidt variants) may include columns of norm 0.

    Args:
        A: The operator to orthogonalize.
        method: The method to use for orthogonalization.
        n_reortho: The number of times to _re_-orthogonalize each column.
            Reorthogonalizing once is generally sufficient to improve orthogonality
            for Gram-Schmidt variants
            (see e.g. [10.1007/s00211-005-0615-4](https://doi.org/10.1007/s00211-005-0615-4)).

    Returns:
        The orthogonalized operator. If the input is a LinearOperator, then so is the output.
    """
    return _orthogonalize(A, method, n_reortho)