Skip to content

Transform

beignet.apply_transform

apply_transform(input, transform)

Return affine transformed position.

Parameters:

Name Type Description Default
input Tensor

Position, must have shape (..., dimension).

required
transform Tensor

Affine transformation matrix, must have shape (dimension, dimension).

required

Returns:

Type Description
Tensor

Affine transformed position of shape (..., dimension).

Source code in src/beignet/_apply_transform.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def apply_transform(input: Tensor, transform: Tensor) -> Tensor:
    """
    Return affine transformed position.

    Parameters
    ----------
    input : Tensor
        Position, must have shape `(..., dimension)`.

    transform : Tensor
        Affine transformation matrix, must have shape
        `(dimension, dimension)`.

    Returns
    -------
    Tensor
        Affine transformed position of shape `(..., dimension)`.
    """
    return _ApplyTransform.apply(transform, input)

beignet.invert_transform

invert_transform(transform)

Calculates the inverse of an affine transformation matrix.

Parameters:

Name Type Description Default
transform Tensor

The affine transformation matrix to be inverted.

required

Returns:

Type Description
Tensor

The inverse of the given affine transformation matrix.

Source code in src/beignet/_invert_transform.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def invert_transform(transform: Tensor) -> Tensor:
    """
    Calculates the inverse of an affine transformation matrix.

    Parameters
    ----------
    transform : Tensor
        The affine transformation matrix to be inverted.

    Returns
    -------
    Tensor
        The inverse of the given affine transformation matrix.
    """
    if transform.ndim in {0, 1}:
        return 1.0 / transform

    if transform.ndim == 2:
        return torch.linalg.inv(transform)

    raise ValueError