1Function: matinvmod
2Section: linear_algebra
3C-Name: matinvmod
4Prototype: GG
5Help: matinvmod(x,d): left inverse of the matrix x modulo d.
6Doc: computes a left inverse of the matrix~$x$ modulo~$d$. The matrix $x$ must
7 have \typ{INT} entries, and $d$ can be an arbitrary positive integer.
8
9 \bprog
10 ? A = [3,1,2;1,2,1;3,1,1];
11 ? U = matinvmod(A,6)
12 %2 =
13 [1 1 3]
14
15 [2 3 5]
16
17 [1 0 5]
18
19 ? (U*A)%6
20 %3 =
21 [1 0 0]
22
23 [0 1 0]
24
25 [0 0 1]
26 ? matinvmod(A,5)
27  ***   at top-level: matinvmod(A,5)
28  ***                 ^--------------
29  *** matinvmod: impossible inverse in gen_inv: 0.
30 @eprog
31