The inverse of a matrix, returned as (success, result).
Matrix3: from the determinant. Fails when the determinant is withinepsilon(default 0.001) of zero, which is an absolute limit, so a valid matrix with small entries can be reported as not invertible; lowerepsilonfor those. On failureresultis the input.Matrix4: by Gaussian elimination with row pivoting (inverse_gaussian_elimination). Fails only when a pivot is exactly zero. On failureresultis the identity.
ok, inv := inverse(Matrix3.{ 2, 0, 0, 0, 4, 0, 0, 0, 5 });
assert(ok && inv._11 == 0.5 && inv._22 == 0.25 && inv._33 == 0.2);
ok4, inv4 := inverse(Matrix4.{});
assert(!ok4 && inv4 == Matrix4_Identity);inverse :: (a: Matrix3, epsilon := 0.001) -> (success: bool, result: Matrix3)
The inverse, or false and the input back when there is none.
Parameters
- a: Matrix3
- the matrix.
- epsilon := 0.001
- a determinant closer to 0 than this counts as having no inverse.
Returns
- success: bool
- result: Matrix3
inverse :: (m: Matrix4) -> (success: bool, result: Matrix4)
The inverse, or false and the identity when there is none.
Parameters
- m: Matrix4
- the matrix.
Returns
- success: bool
- result: Matrix4