Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ syntax. FLINTXX is a set of wrapper C++ classes, together termed flintxx,
which provide such an object oriented syntax.
In general, flintxx strives to behave just like the underlying FLINT C, see the documentation for some exceptions.

## Usage
This is a header-only library.
It suffices to add `src/` and `src/flintxx_public/` to the include path.

## Authors
The author of this C++ wrapper is Tom Bachmann.
This was originally part of [FLINT](https://github.com/flintlib/flint)
Expand Down
2 changes: 1 addition & 1 deletion src/flintxx/evaluation_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <iostream>

#include "../flint.h" // FLINT_MAX and FLINT_MIN
#include "flint.h" // FLINT_MAX and FLINT_MIN

#include "expression_traits.h"
#include "mp.h"
Expand Down
1 change: 1 addition & 0 deletions src/flintxx/examples/fmpz_poly_factor_zassenhaus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <cstdio>
#include "fmpz_polyxx.h"
#include "fmpz_poly_factorxx.h"

using namespace flint;
using namespace std;
Expand Down
1 change: 1 addition & 0 deletions src/flintxx/examples/fooxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef FOO_H
#define FOO_H
#include <stdio.h>
#include "flint.h"

extern "C" { // usually only #ifdef __cplusplus etc
typedef slong foo;
Expand Down
7 changes: 4 additions & 3 deletions src/flintxx/examples/radix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ int main(void)

fmpzxx m(17);
m = m.pow(26u);
fmpz_modxx_ctx ctx(m);

fmpz_mod_polyxx A(m), B(m);
fmpz_mod_polyxx A(ctx), B(ctx);

A.set_coeff(3, 5);
A.set_coeff(4, 4);
Expand All @@ -51,9 +52,9 @@ int main(void)

fmpz_mod_polyxx r(A.pow(3u) * fmpzxx(4) + B.pow(2u) * fmpzxx(27));

fmpz_mod_poly_vecxx b(N + 1, m);
fmpz_mod_poly_vecxx b(N + 1, ctx);

fmpz_mod_polyxx t = fmpz_mod_polyxx::randtest(m, state, n + 1);
fmpz_mod_polyxx t = fmpz_mod_polyxx::randtest(ctx, state, n + 1);

flint_printf("Radix conversion\n");
flint_printf("----------------\n");
Expand Down
2 changes: 1 addition & 1 deletion src/flintxx/flint_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Contrary to other parts of this library, they are tailored very
// specifically towards FLINT.

#include "../flint.h"
#include "flint.h"
#include "mp.h"
#include "expression.h"
#include "expression_traits.h"
Expand Down
6 changes: 3 additions & 3 deletions src/flintxx/frandxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef CXX_FRANDXX_H
#define CXX_FRANDXX_H

#include "../flint.h"
#include "flint.h"

// This class contains a first-class wrapper of flint_rand_t.
// Note that frandxx is not copyable.
Expand All @@ -27,8 +27,8 @@ class frandxx
frandxx(const frandxx&);

public:
frandxx() {flint_randinit(inner);}
~frandxx() {flint_randclear(inner);}
frandxx() {flint_rand_init(inner);}
~frandxx() {flint_rand_clear(inner);}

flint_rand_t& _data() {return inner;}
const flint_rand_t& _data() const {return inner;}
Expand Down
2 changes: 1 addition & 1 deletion src/flintxx/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ltuple.h"
#include "traits.h"
#include "tuple.h"
#include "../permxx.h"
#include "permxx.h"

namespace flint {
FLINT_DEFINE_BINOP(solve)
Expand Down
9 changes: 0 additions & 9 deletions src/flintxx/test/t-arithxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ test_stirling()
fmpz_vecxx v1(func##_vec(n, k).evaluate() /* test temporary alloc */); \
for(slong i = 0;i < v1.size();++i) \
tassert(v1[i] == func(n, i)); \
tassert(func##_vec_next(func##_vec(n, k), n+1).size() == k); \
fmpz_vecxx v2(func##_vec_next(v1, n+1)); \
for(slong i = 0;i < v2.size();++i) \
tassert(v2[i] == func(n+1, i)); \
fmpz_vecxx v3(func##_vec(n, n+1)); \
fmpz_vecxx v4(func##_vec_next(v3, n+1)); \
tassert(v4.size() == n+2 && v3.size() == n+1); \
for(slong i = 0;i < v4.size();++i) \
tassert(v4[i] == func(n+1, i)); \
tassert(matfunc(n, k).rows() == n && matfunc(n, k).cols() == k); \
fmpz_matxx M(matfunc(n, k).evaluate() /* test temporaries */); \
for(slong i = 0;i < M.rows();++i) \
Expand Down
1 change: 1 addition & 0 deletions src/flintxx/test/t-fmpz_polyxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string>

#include "fmpz_polyxx.h"
#include "fmpz_poly_factorxx.h"
#include "nmod_polyxx.h"

#include "flintxx/test/helpers.h"
Expand Down
33 changes: 0 additions & 33 deletions src/flintxx_public/arithxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ ARITHXX_DEFINE_BINOP(stirling_number_2, fmpzxx, at::slong, at::slong)
ARITHXX_DEFINE_BINOP(stirling_number_1u_vec, fmpz_vecxx, at::slong, at::slong)
ARITHXX_DEFINE_BINOP(stirling_number_1_vec, fmpz_vecxx, at::slong, at::slong)
ARITHXX_DEFINE_BINOP(stirling_number_2_vec, fmpz_vecxx, at::slong, at::slong)
FLINT_DEFINE_BINOP(stirling_number_1u_vec_next)
FLINT_DEFINE_BINOP(stirling_number_1_vec_next)
FLINT_DEFINE_BINOP(stirling_number_2_vec_next)
FLINT_DEFINE_BINOP(stirling_matrix_1u)
FLINT_DEFINE_BINOP(stirling_matrix_1)
FLINT_DEFINE_BINOP(stirling_matrix_2)
Expand All @@ -99,23 +96,6 @@ template<> struct outsize<operations::stirling_number_1_vec_op>
: outsize<operations::stirling_number_1u_vec_op> { };
template<> struct outsize<operations::stirling_number_2_vec_op>
: outsize<operations::stirling_number_1u_vec_op> { };

template<>
struct outsize<operations::stirling_number_1u_vec_next_op>
{
template<class Expr>
static unsigned get(const Expr& e)
{
slong r = e._data().first().size();
if(r == e._data().second())
return r + 1;
return r;
}
};
template<> struct outsize<operations::stirling_number_1_vec_next_op>
: outsize<operations::stirling_number_1u_vec_next_op> { };
template<> struct outsize<operations::stirling_number_2_vec_next_op>
: outsize<operations::stirling_number_1u_vec_next_op> { };
} // vectors

namespace matrices {
Expand All @@ -134,19 +114,6 @@ template<> struct outsize<operations::stirling_matrix_2_op>
} // matrices

namespace rules {
FLINT_DEFINE_BINARY_EXPR_COND2(stirling_number_1u_vec_next_op, fmpz_vecxx,
FMPZ_VECXX_COND_S, at::slong,
arith_stirling_number_1u_vec_next(to._array(), e1._array(), e2,
e1.size() + (e1.size() == e2)))
FLINT_DEFINE_BINARY_EXPR_COND2(stirling_number_1_vec_next_op, fmpz_vecxx,
FMPZ_VECXX_COND_S, at::slong,
arith_stirling_number_1_vec_next(to._array(), e1._array(), e2,
e1.size() + (e1.size() == e2)))
FLINT_DEFINE_BINARY_EXPR_COND2(stirling_number_2_vec_next_op, fmpz_vecxx,
FMPZ_VECXX_COND_S, at::slong,
arith_stirling_number_2_vec_next(to._array(), e1._array(), e2,
e1.size() + (e1.size() == e2)))

FLINT_DEFINE_BINARY_EXPR_COND2(stirling_matrix_1u_op, fmpz_matxx,
at::slong, at::slong, arith_stirling_matrix_1u(to._mat()))
FLINT_DEFINE_BINARY_EXPR_COND2(stirling_matrix_1_op, fmpz_matxx,
Expand Down
20 changes: 0 additions & 20 deletions src/flintxx_public/fmpz_mod_polyxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,28 +628,12 @@ FLINT_DEFINE_BINARY_EXPR_COND2(divrem_basecase_op, rdetail::fmpz_mod_polyxx_pair
to.template get<0>()._poly(), to.template get<1>()._poly(),
e1._poly(), e2._poly(), e1._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(divrem_divconquer_op, rdetail::fmpz_mod_polyxx_pair,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_divrem_divconquer(
to.template get<0>()._poly(), to.template get<1>()._poly(),
e1._poly(), e2._poly(), e1._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(divrem_op, rdetail::fmpz_mod_polyxx_pair,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_divrem_divconquer(
to.template get<0>()._poly(), to.template get<1>()._poly(),
e1._poly(), e2._poly(), e1._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(divrem_f_op, rdetail::fmpz_mod_poly_divrem_f_rt,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_divrem_f(
to.template get<0>()._fmpz(), to.template get<1>()._poly(),
to.template get<2>()._poly(), e1._poly(), e2._poly(), e1._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(div_basecase_op, fmpz_mod_polyxx,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_div_basecase(to._poly(), e1._poly(), e2._poly(), to._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(rem_basecase_op, fmpz_mod_polyxx,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_rem_basecase(to._poly(), e1._poly(), e2._poly(), to._ctx()))
Expand All @@ -662,10 +646,6 @@ FLINT_DEFINE_BINARY_EXPR_COND2(gcd_op, fmpz_mod_polyxx,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_gcd(to._poly(), e1._poly(), e2._poly(), to._ctx()))

FLINT_DEFINE_BINARY_EXPR_COND2(gcd_euclidean_op, fmpz_mod_polyxx,
FMPZ_MOD_POLYXX_COND_S, FMPZ_MOD_POLYXX_COND_S,
fmpz_mod_poly_gcd_euclidean(to._poly(), e1._poly(), e2._poly(), to._ctx()))

namespace rdetail {
typedef make_ltuple<mp::make_tuple<
fmpz_mod_polyxx, fmpz_mod_polyxx, fmpz_mod_polyxx>::type>::type
Expand Down
1 change: 1 addition & 0 deletions src/flintxx_public/fmpzxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <cstdlib>
#include <vector>
#include "gmp.h"

#include "flintxx/evaluation_tools.h"
#include "flintxx/expression.h"
Expand Down
4 changes: 0 additions & 4 deletions src/flintxx_public/nmod_polyxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,6 @@ NMOD_POLYXX_DEFINE_SERIES_F(sinh)
NMOD_POLYXX_DEFINE_SERIES_F(cosh)
NMOD_POLYXX_DEFINE_SERIES_F(tanh)

FLINT_DEFINE_BINARY_EXPR_COND2(exp_series_basecase_op, nmod_polyxx,
NMOD_POLYXX_COND_S, traits::fits_into_slong,
nmod_poly_exp_series_basecase(to._poly(), e1._poly(), e2))

FLINT_DEFINE_THREEARY_EXPR_COND3(log_series_monomial_op, nmod_polyxx,
NMODXX_COND_S, traits::is_unsigned_integer, traits::fits_into_slong,
nmod_poly_log_series_monomial_ui(to._poly(), e1._limb(), e2, e3))
Expand Down
4 changes: 2 additions & 2 deletions src/flintxx_public/permxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class permxx
static permxx randtest(slong n, frandxx& state)
{permxx res(n);res.set_randtest(state);return res;}

void set_one() {_perm_set_one(_data(), size());}
void set_one() {_perm_one(_data(), size());}
int set_randtest(frandxx& state)
{return _perm_randtest(_data(), size(), state._data());}

Expand Down Expand Up @@ -93,7 +93,7 @@ template<class T> struct is_permxx : mp::equal_types<T, permxx> { };

inline int print(const permxx& p)
{
return _perm_print(p._data(), p.size());
return flint_printf("%{slong*}", p._data(), p.size());
}
} // flint

Expand Down