/*
Random test.
AKS, Jul 06.
*/


procedure test_lll(N)
    R:=RealField(3);
    RR:=RMatrixSpace(R,2,3);
    B:=RMatrixSpace(IntegerRing(), 2, 3) ! 0;
    B[1,1]:=RandomBits(N);
    B[2,1]:=RandomBits(N);
    B[1,2]:=1;
    B[2,3]:=1;
    printf "N: %o\n", N;
    time L := LLL(B);

    tolerance := Max(100, 2^(N/1000));
    A := RR!L;
    A;
    "tolerance:", R!tolerance;
    for j := 1 to Ncols(A) do
	q := Abs(A[1, j] / A[2, j]);
	if q lt 1 then
	    q := 1/q;
	end if;
	q;
	q le tolerance; 
        // not necessarily true
        // (depends on the continued fraction)
    end for;
end procedure;

test_lll(10000);
test_lll(100000);
test_lll(200000);
