up previous next
random unimodular matrix
RandomUnimodularMat(R: RING, N: INT): MAT
RandomUnimodularMat(R: RING, N: INT, Niters: INT): MAT 
The function returns a random
N
by
N
matrix with integer
entries, and determinant +1. The matrix is over the ring
R
. To
obtain a unimodular matrix with determinant +1 or 1, just multiply the
first row by 1 with probability 1/2.
The optional 3rd argument says how many internal iterations to
perform: the algorithm starts with an identity matrix, then on each
iteration simply adds or substracts one random row to another random
row. The default number of iterations is currently
25*N
.
/**/ RandomUnimodularMat(ZZ, 3);
matrix(ZZ,
[[684, 2919, 769],
[1054, 4498, 1185],
[519, 2215, 584]])
