1 #ifndef NUMBERTHEORY_HPP_ 2 #define NUMBERTHEORY_HPP_ 3 4 #include <vector> 5 #include <utility> 6 #include <string> 7 #include <gmp.h> // for gmp_randstate_t 8 #include "mpz_poly.h" 9 #include "mpz_mat.h" 10 struct cxx_mpz; 11 12 13 /* Return a basis for a p-maximal order of the number field defined by 14 * the polynomial f. 15 * 16 * The basis of the order is written in lower triangular positive row hnf 17 * (magma returns lower triangular centered row hnf, with sometimes negative 18 * coefficients). 19 */ 20 21 cxx_mpq_mat p_maximal_order(cxx_mpz_poly const& f, cxx_mpz const& p); 22 23 std::vector<std::pair<cxx_mpz_mat, int> > factorization_of_prime(cxx_mpq_mat & B, cxx_mpz_poly const& g, cxx_mpz const& p, gmp_randstate_t state); 24 25 cxx_mpz_mat multiplication_table_of_order(cxx_mpq_mat const& O, cxx_mpz_poly const& g); 26 27 std::pair<cxx_mpz_mat, cxx_mpz> generate_ideal(cxx_mpq_mat const& O, cxx_mpz_mat const& M, cxx_mpq_mat const& gens); 28 29 cxx_mpz_mat valuation_helper_for_ideal(cxx_mpz_mat const& M, cxx_mpz_mat const& I, cxx_mpz const& p); 30 31 int valuation_of_ideal_at_prime_ideal(cxx_mpz_mat const& M, cxx_mpz_mat const& I, cxx_mpz_mat const& a, cxx_mpz const& p); 32 int valuation_of_ideal_at_prime_ideal(cxx_mpz_mat const& M, std::pair<cxx_mpz_mat,cxx_mpz> const& Id, cxx_mpz_mat const& a, int e, cxx_mpz const& p); 33 34 int prime_ideal_inertia_degree(cxx_mpz_mat const& I); 35 36 std::pair<cxx_mpz, cxx_mpz_mat> prime_ideal_two_element(cxx_mpq_mat const& O, cxx_mpz_poly const& f, cxx_mpz_mat const& M, cxx_mpz_mat const& I); 37 38 std::string write_element_as_polynomial(cxx_mpq_mat const& theta_q, std::string const& var); 39 40 struct ideal_comparator { 41 typedef std::pair<cxx_mpz_mat,int> Im_t; operator ()ideal_comparator42 bool operator()(Im_t const& a, Im_t const& b) const { 43 int r = mpz_mat_cmp(a.first, b.first); 44 if (r) return r < 0; 45 return a.second < b.second; /* should never happen */ 46 } 47 }; 48 49 #endif /* NUMBERTHEORY_HPP_ */ 50