I believe there is a bug in the code:
lllhermite(sympy.Matrix([[0,1,0,1],[-1,0,1,0]])
throws an exception. I believe this is because
def lllhermite(G, m1=1, n1=1):
"""
Input: integer mxn matrix A, nonzero, at least two rows+
Output: small unimodular matrix B and HNF(A), such that BA=HNF(A)+
The Havas, Majewski, Matthews LLL method is used+
We usually take alpha=m1/n1, with (m1,n1)=(1,1) to get best results+
"""
m = G.shape[0]
n = G.shape[1]
A, B, L, D = initialise_working_matrices(G)
if first_nonzero_is_negative(A):
B[m, m] = -1
A[m, :] *= -1
should be:
m = G.shape[0]
n = G.shape[1]
A, B, L, D = initialise_working_matrices(G)
if first_nonzero_is_negative(A):
B[m-1, m-1] = -1
A[m-1, :] *= -1
What do you think?