Ask Your Question

Revision history [back]

OK I found the solution. In the code I mentioned the error was that smith_form doesn't return matrices in $SL_2(\mathbb{Z})$. It's quite easy to correct by the following snippet that you have to add just after you use smith_form :

 D, U, V = A.smith_form()
if det(U) == -1 : 
    U = matrix(2,2,[-1,0,0,1])* U
if det(V) == -1 : 
    V = V *matrix(2,2,[-1,0,0,1])
D = U*A*V