/** * init pool of samples (used later) */ template <class ZT, class F> void GaussSieve<ZT, F>::init_list_rand() { /* after transformation, the size could be large */ ZZ_mat<mpz_t> NewZ(nr, nc); ZZ_mat<ZT> New(nr, nc); mpz_t tmp; Z_NR<mpz_t> tmpZ; mpz_init(tmp); FP_NR<double> c, t; Z_NR<ZT> x; c = 0.0; t = 32.0; /* init */ for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { (b[i][j]).get_mpz(tmp); NewZ[i][j] = tmp; } } /* randomization */ for (int i = 0; i < nr; i++) { for (int k = 0; k < nr; k++) { if (i != k) { x = sample_z_basic_alt<ZT, FP_NR<double>>(c, t); x.get_mpz(tmp); tmpZ = tmp; (NewZ[i]).addmul(NewZ[k], tmpZ, (NewZ[k]).size()); } } } /* reduce */ lll_reduction(NewZ, LLL_DEF_DELTA, LLL_DEF_ETA, LM_FAST); /* set */ for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { tmpZ = (NewZ[i][j]).get_data(); tmpZ.get_mpz(tmp); New[i][j] = tmp; } } /* add to list */ add_mat_list(New); mpz_clear(tmp); }
template<> Obj GET_INTOBJ(Z_NR<mpz_t> &v) { #ifdef FPLLL_VERSION mpz_t z; mpz_init2 (z, 8*sizeof(long)+1); v.get_mpz(z); Obj o = INT_mpz(z); mpz_clear(z); return o; #else return INT_mpz(v.getData()); #endif }