Skip to content
fn

pinv_op

→TensorImplPtr
int pinv_op(const int & a)

Python wrappers

Public Python APIs implemented by this engine symbol.

Compute the Moore-Penrose pseudoinverse A+A^+ of a rectangular matrix.

Shape

  • Input a: (..., m, n).
  • Output: (..., n, m).

Parameters

aTensorImplPtr
Input matrix of shape (..., m, n) with leading batch dims. Need not be square or full rank. Must be at least 2-D and have a floating-point dtype.

Returns

TensorImplPtr

The pseudoinverse A+A^+ of shape (..., n, m) — the last two dimensions are swapped relative to the input.

Raises

:runtime_error
If a is null, has a non-floating-point dtype, or has fewer than two dimensions.

Notes

Internally a full reduced SVD is computed; if the caller already has the SVD on hand, forming A+=VΣ+U⊤A^+ = V \Sigma^+ U^\top manually avoids the redundant factorisation.

Examples

>>> // Solve a tall least-squares system via the pseudoinverse:
>>> auto x_impl = matmul_op(pinv_op(a_impl), b_impl);