Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flint3 #264

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[submodule "renfxx/test/external/cereal"]
path = libeantic/test/external/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "upstream/antic"]
path = libeantic/upstream/antic
url = https://github.com/flatsurf/antic.git
[submodule "upstream/flint"]
path = libeantic/upstream/flint
url = https://github.com/wbhart/flint2.git
url = https://github.com/flintlib/flint.git
[submodule "renfxx/test/external/catch2"]
path = libeantic/test/external/catch2
url = https://github.com/catchorg/Catch2.git
3 changes: 0 additions & 3 deletions libeantic/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ ACLOCAL_AMFLAGS = -I m4

# Distribute files that we might need to fill/replace from our dependencies
EXTRA_DIST = \
upstream/patched/EANTIC_fmpq_poly_add_fmpq.c \
upstream/patched/EANTIC_nf_elem_add_fmpq.c \
upstream/patched/EANTIC_nf_elem_scalar_div_fmpq.c \
upstream/patched/fmpq_poly_add_fmpq.c \
upstream/patched/nf.h \
upstream/patched/nf_elem.h \
Expand Down
26 changes: 7 additions & 19 deletions libeantic/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,18 @@ AC_CHECK_LIB(gmp, __gmpz_add, [], [AC_MSG_ERROR([libgmp not found])])

AC_CHECK_LIB(mpfr, mpfr_init, [], [AC_MSG_WARN([libmpfr not found which FLINT needs])])

AC_CHECK_HEADERS(flint/flint.h flint/fmpz.h flint/fmpq.h, , [AC_MSG_ERROR([FLINT headers not found])])
AC_CHECK_HEADERS(flint/flint.h flint/fmpz.h flint/fmpq.h flint/nf.h flint/nf_elem.h flint/arb.h flint/arb_poly.h flint/arf.h, , [AC_MSG_ERROR([FLINT headers not found])])
AC_CHECK_LIB(flint, fmpz_init, [], [AC_MSG_ERROR([libflint not found])])
AC_CHECK_LIB(flint, nf_init, [], [AC_MSG_ERROR([libflint not found])])
AC_CHECK_LIB(flint, arb_init, [], [AC_MSG_ERROR([libflint not found])])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <flint/flint.h>
#if __FLINT_RELEASE < 20600
#error FLINT must be at least 2.6.0
#if __FLINT_RELEASE < 30000
#error FLINT must be at least 3.0.0
#endif
])], [], [AC_MSG_ERROR([libflint version must be at least 2.6.0])])

AC_CHECK_HEADERS(antic/nf.h antic/nf_elem.h, , [AC_MSG_ERROR([antic headers not found])])
AC_CHECK_LIB(antic, nf_init, [], [AC_MSG_ERROR([libantic not found])])

# Check if we need to provide our own nf_init_randtest which was introduced in https://github.com/wbhart/antic/pull/47
AC_REPLACE_FUNCS(nf_init_randtest)
# Unconditionally patch nf_elem_scalar_div_fmpq which has aliasing issues in ANTIC, https://github.com/wbhart/antic/pull/48
AC_LIBOBJ(EANTIC_nf_elem_scalar_div_fmpq)
# Unconditionally patch fmpq_poly_add_fmpq which was fixed in https://github.com/wbhart/flint2/commit/17d26d4c957828f3c98c15ddec85108f841d3438
AC_LIBOBJ(EANTIC_fmpq_poly_add_fmpq)
# Unconditionally patch nf_elem_add_fmpq so it uses our patched fmpq_poly_add_fmpq
AC_LIBOBJ(EANTIC_nf_elem_add_fmpq)

AC_CHECK_HEADERS(arb.h arb_poly.h arf.h, , [AC_MSG_ERROR([Arb headers not found. If your arb headers are in a non-standard location, you might need to adapt your CPPFLAGS, e.g., by adding -I/usr/include/arb to the CPPFLAGS environment variable.])])
AC_SEARCH_LIBS(arb_init, [arb flint-arb],[], [AC_MSG_ERROR([libarb not found])])
])], [], [AC_MSG_ERROR([libflint version must be at least 3.0.0])])


AC_LANG_PUSH([C++])
AX_CXX_COMPILE_STDCXX(14)
Expand Down
2 changes: 1 addition & 1 deletion libeantic/e-antic/fmpq_poly_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "local.h"

#include <flint/fmpq_poly.h>
#include <arb.h>
#include <flint/arb.h>

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion libeantic/e-antic/fmpz_poly_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "local.h"

#include <flint/fmpz_poly.h>
#include <arb.h>
#include <flint/arb.h>

#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 4 additions & 4 deletions libeantic/e-antic/renf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "local.h"

#include <flint/fmpq_poly.h>
#include <antic/nf.h>
#include <antic/nf_elem.h>
#include <arb.h>
#include <arb_poly.h>
#include <flint/nf.h>
#include <flint/nf_elem.h>
#include <flint/arb.h>
#include <flint/arb_poly.h>

#ifdef __cplusplus
extern "C" {
Expand Down
14 changes: 4 additions & 10 deletions libeantic/e-antic/renf_elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "local.h"

#include <flint/fmpq_poly.h>
#include <arb.h>
#include <arb_poly.h>
#include <antic/nf.h>
#include <antic/nf_elem.h>
#include <flint/arb.h>
#include <flint/arb_poly.h>
#include <flint/nf.h>
#include <flint/nf_elem.h>

#include "renf.h"

Expand All @@ -33,12 +33,6 @@ extern "C" {
#define EANTIC_STR_D 2
#define EANTIC_STR_ARB 4

// Patch nf_elem_scalar_div & nf_elem_add_fmpq which have issues in the released version of ANTIC, see upstream/patched.
LIBEANTIC_API void EANTIC_nf_elem_scalar_div_fmpq(nf_elem_t a, const nf_elem_t b, const fmpq_t c, const nf_t nf);
#define nf_elem_scalar_div_fmpq(a, b, c, nf) EANTIC_nf_elem_scalar_div_fmpq(a, b, c, nf)
LIBEANTIC_API void EANTIC_nf_elem_add_fmpq(nf_elem_t a, const nf_elem_t b, const fmpq_t c, const nf_t nf);
#define nf_elem_add_fmpq(a, b, c, nf) EANTIC_nf_elem_add_fmpq(a, b, c, nf)

/// === Memory Layout ===
/// A real embedded number field element
typedef struct LIBEANTIC_API renf_elem
Expand Down
4 changes: 1 addition & 3 deletions libeantic/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ name: e-antic-build
channels:
- conda-forge
dependencies:
- arb
- antic
- automake
- benchmark
# byexample 10.5 is not working on macOS: https://github.com/byexamples/byexample/issues/220
Expand All @@ -17,7 +15,7 @@ dependencies:
- coreutils
- c-compiler
- cxx-compiler
- libflint
- libflint>=3.0.0
- gmp
- libtool
- make
Expand Down
1 change: 0 additions & 1 deletion libeantic/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ requirements:
- make
- {{ compiler('cxx') }}
host:
- antic
- boost-cpp {{ boost_cpp }}
- gmp {{ gmp }}
- arb {{ arb }}
Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/fmpq_poly_extra/check_unique_real_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <flint/fmpq.h>
#include <flint/fmpz_vec.h>

#include "../e-antic/fmpz_poly_extra.h"
#include "../e-antic/fmpq_poly_extra.h"
Expand Down
9 changes: 6 additions & 3 deletions libeantic/src/fmpq_poly_extra/set_str_pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include "flint/fmpq_poly.h"
#include "../e-antic/fmpq_poly_extra.h"
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <flint/fmpq.h>
#include <flint/fmpq_poly.h>

#include "../e-antic/fmpq_poly_extra.h"

static int _monomial_set_str(fmpq_t coeff, slong * pow, const char * var, char * w)
{
Expand Down
4 changes: 4 additions & 0 deletions libeantic/src/fmpz_poly_extra/descartes_bound.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>
#include <flint/fmpz_vec.h>

#include "../e-antic/fmpz_poly_extra.h"


slong fmpz_poly_num_real_roots_upper_bound(fmpz_poly_t pol)
{
slong i, i0, k, ret, len;
Expand Down
3 changes: 3 additions & 0 deletions libeantic/src/fmpz_poly_extra/descartes_bound_0_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <flint/fmpz_vec.h>

#include "../e-antic/fmpz_poly_extra.h"


slong _fmpz_poly_descartes_bound_0_1(fmpz * p, slong len, slong bound)
{
slong V = 0;
Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/fmpz_poly_extra/evaluate_at_one.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <flint/fmpz_vec.h>

#include "../e-antic/fmpz_poly_extra.h"

void fmpz_poly_evaluate_at_one(fmpz_t res, fmpz * p, slong len)
Expand Down
4 changes: 4 additions & 0 deletions libeantic/src/fmpz_poly_extra/isolate_real_roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
*/

#include <assert.h>
#include <stdlib.h>
#include <flint/fmpz_vec.h>
#include <flint/fmpq.h>

#include "../e-antic/fmpz_poly_extra.h"


/* isolate the real roots of pol contained in [0,1] */
/* using VCA (Vincent-Collins-Akritas) method */
/* the output are arrays of fmpz c and integers k so that the roots belong to */
Expand Down
1 change: 1 addition & 0 deletions libeantic/src/fmpz_poly_extra/newton_step_arb.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <stdio.h>
#include <stdlib.h>

#include "../e-antic/fmpz_poly_extra.h"

Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/fmpz_poly_extra/num_real_roots_0_1_sturm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>

#include "../e-antic/fmpz_poly_extra.h"

slong fmpz_poly_num_real_roots_0_1_sturm(fmpz_poly_t pol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <assert.h>

#include <arb.h>
#include <flint/arb.h>
#include <flint/fmpz_poly.h>
#include "../e-antic/fmpz_poly_extra.h"

Expand Down
1 change: 1 addition & 0 deletions libeantic/src/fmpz_poly_extra/randtest_irreducible.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <flint/fmpz_mod_poly.h>
#include <flint/fmpz_mod.h>

#include "../e-antic/fmpz_poly_extra.h"

Expand Down
1 change: 1 addition & 0 deletions libeantic/src/renf/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>

#include "../e-antic/renf.h"
#include "../e-antic/fmpq_poly_extra.h"
Expand Down
1 change: 1 addition & 0 deletions libeantic/src/renf/init_nth_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


#include <assert.h>
#include <stdlib.h>

#include "../e-antic/renf.h"

Expand Down
1 change: 1 addition & 0 deletions libeantic/src/renf/randtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <assert.h>
#include <stdlib.h>
#include <flint/fmpz_vec.h>

#include "../e-antic/renf.h"
Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/renf/set_embeddings_fmpz_poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*/

#include <assert.h>
#include <stdlib.h>
#include <flint/fmpz_vec.h>

#include "../e-antic/renf.h"
#include "../e-antic/fmpz_poly_extra.h"
Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/renf_elem/check_embedding.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>

#include "../e-antic/renf_elem.h"
#include "../e-antic/fmpq_poly_extra.h"

Expand Down
2 changes: 1 addition & 1 deletion libeantic/src/renf_elem/fdiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <arb.h>
#include <flint/arb.h>

#include "../e-antic/renf_elem.h"

Expand Down
3 changes: 2 additions & 1 deletion libeantic/src/renf_elem/get_str_pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <arb.h>
#include <math.h>
#include <string.h>
#include <flint/arb.h>

#include "../e-antic/renf_elem.h"

Expand Down
2 changes: 2 additions & 0 deletions libeantic/src/renf_elem/rounding_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#endif

#include <stdlib.h>

static inline int
ARB_UNIQUE_INT(fmpz_t res, arb_t x, arf_t cl, arf_t cr, slong prec)
{
Expand Down
2 changes: 1 addition & 1 deletion libeantic/srcxx/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EXTRA_DIST = $(srcdir)/libeanticxx.map
AM_CPPFLAGS = -DBUILD_LIBEANTIC

# Linked-against libraries
libeanticxx_la_LIBADD = ../src/libeantic.la -lgmpxx -lflint -lantic
libeanticxx_la_LIBADD = ../src/libeantic.la -lgmpxx -lflint

# Installed headers
nobase_pkginclude_HEADERS = \
Expand Down
15 changes: 13 additions & 2 deletions libeantic/srcxx/renf_elem_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,15 @@ renf_elem_class::renf_elem_class(const renf_class& k, const std::vector<mpz_clas
assert(static_cast<slong>(coefficients.size()) <= nf->degree() &&
"can not assign renf_elem_class from vector whose size exceeds number field degree");

fmpz_t coeff;
fmpq_poly_t p;
fmpq_poly_init(p);
for (size_t i = 0; i < coefficients.size(); i++)
fmpq_poly_set_coeff_mpz(p, static_cast<slong>(i), coefficients[i].__get_mp());
{
fmpz_init_set_readonly(coeff, coefficients[i].__get_mp());
fmpq_poly_set_coeff_fmpz(p, static_cast<slong>(i), coeff);
fmpz_clear_readonly(coeff);
}

renf_elem_set_fmpq_poly(a, p, nf->renf_t());
fmpq_poly_clear(p);
Expand All @@ -524,9 +529,15 @@ renf_elem_class::renf_elem_class(const renf_class& k, const std::vector<mpq_clas
assert(static_cast<slong>(coefficients.size()) <= nf->degree() &&
"can not assign renf_elem_class from vector whose size exceeds number field degree");

fmpq_t coeff;
fmpq_poly_t p;
fmpq_poly_init(p);
fmpq_poly_set_array_mpq(p, reinterpret_cast<const mpq_t*>(&coefficients[0]), coefficients.size());
for (size_t i = 0; i < coefficients.size(); i++)
{
fmpq_init_set_readonly(coeff, coefficients[i].__get_mp());
fmpq_poly_set_coeff_fmpq(p, static_cast<slong>(i), coeff);
fmpq_clear_readonly(coeff);
}

renf_elem_set_fmpq_poly(a, p, nf->renf_t());
fmpq_poly_clear(p);
Expand Down
3 changes: 3 additions & 0 deletions libeantic/test/fmpq_poly_extra/t-evaluate.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>
#include <flint/fmpq.h>

#include "../../e-antic/fmpq_poly_extra.h"

int main(void)
Expand Down
1 change: 1 addition & 0 deletions libeantic/test/fmpq_poly_extra/t-set_str_pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "../../e-antic/fmpq_poly_extra.h"

Expand Down
2 changes: 2 additions & 0 deletions libeantic/test/fmpz_poly_extra/t-check_unique_real_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>

#include "../../e-antic/fmpq_poly_extra.h"

int main(void)
Expand Down
Loading