inverse ( matrix -- matrix )


Vocabulary
math.matrices.elimination

Inputs and outputs
matrixa sequence


Word description
Computes the multiplicative inverse of a matrix. Assuming the matrix is invertible.

Examples
A matrix multiplied by its inverse is the identity matrix.
USING: kernel math.matrices math.matrices.elimination prettyprint ; { { 3 4 } { 7 9 } } dup inverse m. 2 identity-matrix = .
t


Definition
USING: kernel math.matrices sequences ;

IN: math.matrices.elimination

: inverse ( matrix -- matrix )
dup length [ identity-matrix [ append ] 2map solution ] keep
[ tail ] curry map ;