#include #include NTL_CLIENT int main() { mat_ZZ B, L; vec_ZZ v, w; long s, s1; long r; long i=0; long j=0; long n=0; long m=0; #if 0 cin >> B; m = B.NumRows(); n = B.NumCols(); #else cout << "\n n is the number of rows.\n "; cout << "m is the number of columns.\n "; cout << "bit_in is the maximum number of bits in entry of input.\n "; cout << "t_LLL is the time taken by LLL.\n "; cout << "t_X is the time taken by XLLL.\n "; cout << "t_X/LLL is their ratio.\n "; cout << "bit_LLL is the maximum number of bits in U for LLL.\n "; cout << "bit_X is the maximum number of bits in U for XLLL.\n "; cout << "bit_X/LLL is their ratio.\n "; cout << "bit_det is the number of bits in det\n "; cout << "bit_BLLL is the maximum number of bits in B for LLL.\n "; cout << "bit_BX is the maximum number of bits in B for XLLL version.\n "; cout << "\n"; cerr << "\nn: "; cin >> n; while ( n ){ cerr << "m: "; cin >> m; long k; cerr << "k: "; cin >> k; B.SetDims(n, m); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { RandomLen(B(i,j), k); if (RandomBnd(2)) negate(B(i,j), B(i,j)); } L.SetDims(m, m); for (i = 1; i <= m; i++) for (j = 1; j <= m; j++) { RandomLen(L(i,j), k); if (RandomBnd(2)) negate(L(i,j), L(i,j)); } #endif mat_ZZ U, U1, U2, B0, B1, B2; B0 = B; double t, t1, t2, t3, ra; ZZ d, d1, max1, max2, max3, max4, max5, co; // cerr << "B0 = " << B0 << "\n"; // cerr << "image...\n"; B = B0; for (r = 1; r <= 2 ; r++){ B = B0; t = GetTime(); s = LLL(d, B, U, 0); // s = LLL(d, B); t1 = (GetTime()-t); // cerr << "time = " << t1 << "\n"; mul(B1, U, B0); if (B1 != B) Error("bad LLLTest (1)"); max4=0; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { abs(co,B(i,j)); if (co>max4) max4=co; } max1=0; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) { abs(co,U(i,j)); if (co>max1) max1=co; } B1=B; d1=d; U1=U; B = B0; t = GetTime(); s1 = XLLL(d1, B, U, 0); t2 = GetTime()-t; if (s1 != s) Error("Other answer for rank"); if (d1 != d) Error("Other answer for det"); mul(B1, U, B0); if (B1 != B) Error("bad LLLTest (2)"); max2=0; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { abs(co,U(i,j)); if (co>max2) max2=co; } max3=0; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { abs(co,B0(i,j)); if (co>max3) max3=co; } max5=0; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { abs(co,B(i,j)); if (co>max5) max5=co; } ra=NumBits(max2); ra=ra/NumBits(max1); cout << "m = " << m << ", n = " << n << ", bit_in = " << NumBits(max3); cout <<", t_LLL = "<> n; } cout <<"bye!\n"; }