warp.inverse#

warp.inverse(
a: Matrix[Float, Literal[2], Literal[2]],
) → Matrix[Float, Any, Any]#
  • Kernel: true
  • Python: true
  • Differentiable: true

Return the inverse of a matrix.

Nearly singular inputs can amplify rounding errors and produce large gradients. Use a well-conditioned matrix for differentiation, and check that the product of the input and returned matrix is close to the identity when numerical accuracy is required.

Parameters:

a – Matrix to invert. Must be nonsingular.

Returns:

The inverse matrix, whose product with the input is the identity in exact arithmetic.

Example

Invert a matrix and inspect the result:

matrix = wp.mat22(2.0, 1.0, 1.0, 2.0)
inverse = wp.inverse(matrix)
print(np.round(np.asarray(inverse).reshape(2, 2), 3))
[[ 0.667 -0.333]
 [-0.333  0.667]]
warp.inverse(
a: Matrix[Float, Literal[3], Literal[3]],
) → Matrix[Float, Any, Any]
  • Kernel: true
  • Python: true
  • Differentiable: true

Return the inverse of a 3x3 matrix.

See the 2x2 overload for numerical and autodiff guidance.

Parameters:

a – Matrix to invert. Must be nonsingular.

Returns:

The inverse matrix, whose product with the input is the identity in exact arithmetic.

warp.inverse(
a: Matrix[Float, Literal[4], Literal[4]],
) → Matrix[Float, Any, Any]
  • Kernel: true
  • Python: true
  • Differentiable: true

Return the inverse of a 4x4 matrix.

See the 2x2 overload for numerical and autodiff guidance.

Parameters:

a – Matrix to invert. Must be nonsingular.

Returns:

The inverse matrix, whose product with the input is the identity in exact arithmetic.