Macaulay2 Engine
Loading...
Searching...
No Matches

◆ fp_LLL()

bool fp_LLL ( MutableMatrix * M,
MutableMatrix * U,
int strategy )

Definition at line 9 of file fplll-interface.cpp.

10{
11 (void) M;
12 (void) U;
13 (void) strategy;
14#ifndef HAVE_FPLLL
15 ERROR("fplll is not available (configure M2 with fplll!)");
16 return 0;
17#else
18 assert(U == NULL);
19 double delta = 0.99;
20 double eta = 0.51;
21 fplll::LLLMethod method = fplll::LM_WRAPPER;
22 fplll::FloatType floatType = fplll::FT_DEFAULT;
23 int precision = 0;
24 int flags = fplll::LLL_DEFAULT;
25
26 int ncols = static_cast<int>(M->n_rows());
27 int nrows = static_cast<int>(M->n_cols());
28
29 fplll::ZZ_mat<mpz_t> mat(nrows, ncols);
30
31 for (int i = 0; i < nrows; i++)
32 for (int j = 0; j < ncols; j++)
33 {
34 ring_elem a;
35 if (M->get_entry(j, i, a))
36 {
37 mpz_set(mat[i][j].get_data(), a.get_mpz());
38 }
39 }
40
41 int result =
42 lll_reduction(mat, delta, eta, method, floatType, precision, flags);
43
44 switch (result)
45 {
46 case fplll::RED_SUCCESS:
47 break;
48 case fplll::RED_BABAI_FAILURE:
49 ERROR("Error in fpLLL");
50 return 0;
51 case fplll::RED_LLL_FAILURE:
52 ERROR("infinite loop in LLL");
53 return 0;
54 default:
55 ERROR("unknown error in fpLLL");
56 return 0;
57 }
58
59 /* Put this back into M */
60 mpz_t a;
61 mpz_init(a);
62
63 for (int j = 0; j < ncols; j++)
64 for (int i = 0; i < nrows; i++)
65 {
66 mpz_set(a, mat[i][j].get_data());
67 ring_elem b = globalZZ->from_int(a);
68 M->set_entry(j, i, b);
69 }
70 mpz_clear(a);
71 return true;
72#endif
73}
virtual size_t n_rows() const =0
virtual size_t n_cols() const =0
virtual bool get_entry(size_t r, size_t c, ring_elem &result) const =0
virtual bool set_entry(size_t r, size_t c, const ring_elem a)=0
RingZZ * globalZZ
Definition relem.cpp:13
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpz_srcptr get_mpz() const
Definition ringelem.hpp:127

References ERROR, MutableMatrix::get_entry(), ring_elem::get_mpz(), globalZZ, MutableMatrix::n_cols(), MutableMatrix::n_rows(), result(), and MutableMatrix::set_entry().

Referenced by rawLLL().