fn
inv
→Tensorinv(x: Tensor)Compute the multiplicative inverse of a square matrix.
Returns the unique matrix such that
Inversion is performed via LU decomposition with partial pivoting.
When the goal is to apply to a known right-hand side,
prefer solve — explicit inversion is both slower and less
numerically stable than back-substitution.
Parameters
xTensorSquare matrix of shape
(*, n, n) (batch dims allowed). Must
be non-singular; raises a runtime error on singular input.Returns
TensorInverse matrix of shape (*, n, n) with the same dtype as
x.
Notes
Internally computes and then solves LU X = P for
X via two triangular sweeps. Cost is per matrix.
For ill-conditioned A consider pinv (SVD-based) for a
more robust pseudo-inverse.
Examples
>>> import lucid
>>> from lucid.linalg import inv
>>> A = lucid.tensor([[4.0, 7.0], [2.0, 6.0]])
>>> inv(A)
Tensor([[ 0.6000, -0.7000],
[-0.2000, 0.4000]])