pinv

Contents

pinv#

class brainunit.linalg.pinv(a, rtol=None, hermitian=False, *, rcond=None, **kwargs)#

Compute the Moore-Penrose pseudo-inverse of a matrix.

SaiUnit implementation of numpy.linalg.pinv().

The resulting unit is a.unit ** -1.

Parameters:
  • a (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Input matrix of shape (..., M, N) to pseudo-invert.

  • rtol (Array | ndarray | bool | number | bool | int | float | complex | None) – Cutoff for small singular values of shape a.shape[:-2]. Singular values smaller than rtol * largest_singular_value are treated as zero. The default is determined based on the floating point precision of the dtype.

  • hermitian (bool) – If True, the input is assumed to be Hermitian, and a more efficient algorithm is used (default: False).

  • rcond (Array | ndarray | bool | number | bool | int | float | complex | None) – Deprecated alias for rtol. Will result in a DeprecationWarning if used.

Returns:

out – Pseudo-inverse of shape (..., N, M). The resulting unit is a.unit ** -1.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity

See also

saiunit.linalg.inv

Compute the inverse of a square matrix.

saiunit.linalg.lstsq

Least-squares solution to a linear equation.

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> a = jnp.array([[1, 2],
...                [3, 4],
...                [5, 6]]) * u.second
>>> a_pinv = u.linalg.pinv(a)
>>> a_pinv.shape
(2, 3)
>>> u.math.allclose(a_pinv @ a, jnp.eye(2), atol=1e-4)
Array(True, dtype=bool)