matr_inv - ObjectVision/GeoDMS GitHub Wiki

Matrix functions matr_inv

The matr_inv function computes the inverse of a square matrix using LU decomposition.

syntax

matr_inv(matrix: NxN->Float) -> NxN->Float

definition

Computes the inverse of a square matrix using LU decomposition with partial pivoting. For an invertible matrix A, the result B satisfies A × B = B × A = I (identity matrix).

The implementation uses the Boost uBLAS library with lu_factorize and lu_substitute algorithms based on Numerical Recipes in C.

arguments

argument description type
matrix Square matrix attribute to invert attribute

performance

Uses LU decomposition for matrix inversion. Complexity is O(N³) where N is the matrix dimension.

Memory requirement is O(N²) for the working copy and permutation matrix.

conditions

  • The matrix must be square (Width = Height)
  • The matrix must be invertible (non-singular, determinant ≠ 0)
  • Value types must be Float32 or Float64

result

If the matrix is singular (not invertible), the result values will be undefined (null).

example

// Define a 3x3 matrix domain
unit<SPoint> Matrix3x3 := range(SPoint, point_xy(0s, 0s), point_xy(3s, 3s));

attribute<Float64> A (Matrix3x3) := union_data(Matrix3x3, 
    1.0, 2.0, 3.0,
    0.0, 1.0, 4.0,
    5.0, 6.0, 0.0
);

attribute<Float64> A_inv (Matrix3x3) := matr_inv(A);

// Verify: matr_mul(A, A_inv, Matrix3x3) should approximate identity matrix

see also

since version

7.0

⚠️ **GitHub.com Fallback** ⚠️