I'd like to generate some unimodular matrices over ZZ with some restrictions:
- the entries are between -2 and 2
- the main diagonal entries are fixed: $a_{jj} = 2 $
- the matrix is symmetric: $A = A^t$
Item 1 above can be addressed with the option upper_bound
. Simply searching for matrices satisfying (1) and (3),
for j in [1..1000]:
A = random_matrix(ZZ,3,3, algorithm = 'unimodular', upper_bound = 3, max_tries = 1000)
if A == A.transpose():
A
becomes extremely inefficient, especially as the dimension grows. Is there a way to enforce items (1)-(3) within the unimodular algorithm? Or another workaround?