matrix_inverse

compas.geometry.matrix_inverse(M)[source]

Calculates the inverse of a square matrix M.

Parameters

M (list of list of float) – A square matrix of any dimension.

Raises
Returns

list of list of float – The inverted matrix.

Examples

>>> from compas.geometry import Frame
>>> f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
>>> T = matrix_from_frame(f)
>>> I = multiply_matrices(T, matrix_inverse(T))
>>> I2 = identity_matrix(4)
>>> allclose(I[0], I2[0])
True
>>> allclose(I[1], I2[1])
True
>>> allclose(I[2], I2[2])
True
>>> allclose(I[3], I2[3])
True