Commit 53bba633 authored by Andreas Enge's avatar Andreas Enge

Enable the use of fplll-5 for coefficient recognition.

Thanks to Jan Engelhardt <jengelh@inai.de> for figuring out the API
of fplll-5.

* configure.ac: If fplll-4 is not found, check for fplll-5.
* src/lll.cpp (lll_fplll): Add a version working with fplll-5, and simplify
  the code for fplll-4.
parent 7078fedb
# Copyright (C) 2013, 2014, 2015, 2016, 2018, 2019 INRIA
# Copyright (C) 2013, 2014, 2015, 2016, 2018, 2019, 2020 INRIA
#
# This file is part of CMH.
#
......@@ -257,7 +257,7 @@ error
])
# Fplll
AC_MSG_CHECKING(for FPLLL)
AC_MSG_CHECKING(for FPLLL 4)
AC_LANG_PUSH(C++)
OLDLIBS="$LIBS"
LIBS="-lfplll $LIBS"
......@@ -269,12 +269,26 @@ AC_LINK_IFELSE(
)],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_FPLLL],[1],[Define to 1 if FPLLL is present.])
AC_DEFINE([HAVE_FPLLL_4],[1],[Define to 1 if FPLLL 4 is present.])
],
[
AC_MSG_RESULT(no)
LIBS="$OLDLIBS"
AC_MSG_WARN([libfplll not found or uses a different API; using pari instead, which is slower.])
AC_MSG_CHECKING(for FPLLL 5)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include "fplll.h"]],
[[#include "fplll/nr/matrix.h"]],
[[ZZ_mat<mpz_t> M(3,3);]]
)],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_FPLLL_5],[1],[Define to 1 if FPLLL 5 is present.])
],
[
AC_MSG_RESULT(no)
LIBS="$OLDLIBS"
AC_MSG_WARN([libfplll not found or uses a different API; using pari instead, which is slower.])
])
])
AC_LANG_POP(C++)
......
/* lll.cpp -- encapsulate LLL taken from external libraries
Copyright (C) 2019 INRIA
Copyright (C) 2019, 2020 INRIA
This file is part of CMH.
......@@ -20,19 +20,20 @@
#include "config.h"
#include <mpfr.h>
#ifdef HAVE_FPLLL
#if defined HAVE_FPLLL_4 || defined HAVE_FPLLL_5
#define HAVE_FPLLL
#include <fplll.h>
#ifdef HAVE_FPLLL_4
#include <fplll/matrix.h>
#else
#include <fplll/nr/matrix.h>
#endif
#else
#include <pari/pari.h>
#include "parsepari.h"
#endif
#include "lll.h"
#ifdef HAVE_FPLLL
using namespace fplll;
#endif
#ifdef HAVE_FPLLL
static void lll_fplll (mpz_t *v, mpz_t **M, const int m, const int n)
{
......@@ -41,17 +42,27 @@ static void lll_fplll (mpz_t *v, mpz_t **M, const int m, const int n)
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
Mp.Get (i, j).set (M [i][j]);
#ifdef HAVE_FPLLL_4
Mp [i][j].set (M [i][j]);
#else
Mp [i][j] = M [i][j];
#endif
#ifdef HAVE_FPLLL_4
lllReduction (Mp);
#else
lll_reduction (Mp);
#endif
Z_NR <mpz_t> *vp = Mp.GetVec (0);
for (i = 0; i < n; i++)
mpz_set (v [i], vp [i].GetData ());
}
#ifdef HAVE_FPLLL_4
mpz_set (v [i], Mp [0][i].GetData ());
#else
mpz_set (v [i], Mp [0][i].get_data ());
#endif
}
#ifndef HAVE_FPLLL
#else
static void lll_pari (mpz_t *v, mpz_t **M, const int m, const int n)
{
pari_sp av;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment