// Number theory related procedures #ifndef _qi_number_h_ #define _qi_number_h_ /** QI */ /** $$ Redondance */ #include "QIHompoly.h" #include "QIParam.h" using namespace std; // Enter namespace QI namespace QI { // Optimize coefficients of polynomial using the pp function void optimize(hom_polynomial &pol); // Optimize coefficients of a pair of hom_polynomials by taking the gcd of their coeff void optimize(hom_polynomial &pol1, hom_polynomial &pol2); // Optimize coefficients of a pair of hom_hom_polynomials by taking the gcd of the // contents of the coefficients (we only eliminate constants, not polynomial factors) void optimize(hom_hom_polynomial &pol1, hom_hom_polynomial &pol2); // Output the gcd of the content of the coordinates of a curve_param bigint cont(const curve_param &par); // Compute the content of a hom_hom_polynomial, ie the gcd of the coefficients in (u,v) hom_polynomial cont(const hom_hom_polynomial &a); // Compute the primitive part of a hom_hom_polynomial a, i.e. a divided by its content hom_hom_polynomial pp(const hom_hom_polynomial &a); // Compute the primitive part of a hom_hom_polynomial poly knowing its content hom_hom_polynomial pp(const hom_hom_polynomial &a, const hom_polynomial &content); // Optimize a curve_param void optimize(curve_param &par); // Optimize a pair of curve_params by taking the gcd of their content void optimize(curve_param &par1, curve_param &par2); // Message for factor extraction void extract_message(const int opt_level, ostream &s, const string &f = "extracting square factors"); // Take the integer nearest to the cubic root of an integer bigint cubic_root(const bigint &b); // Compute the square factors of a bigint math_vector extract_square_factors(const bigint &b, const int opt_level, ostream &s); // Content of the coefficients of a vector bigint content(const math_vector &vec); // Optimize a vector by dividing by its content void optimize(math_vector &v1); // Optimize a pair of vectors by dividing by the gcd of the contents void optimize(math_vector &v1, math_vector &v2); // Optimize first two, then last two coordinates void optimize_by_half(math_vector &v1); // Optimize a triple of vectors by dividing by the gcd of the contents void optimize(math_vector &v1, math_vector &v2, math_vector &v3); // Optimize a quadruple of vectors by dividing by the gcd of the contents void optimize(math_vector &v1, math_vector &v2, math_vector &v3, math_vector &v4); // Optimize by dividing each column by its content void optimize_trans1(bigint_matrix &q); // Optimize: each column should be divided by the gcd of the contents of each // matrix column void optimize_trans2(bigint_matrix &q1, bigint_matrix &q2); // Optimize by dividing columns 1, 2, 3 by a, b, c such that a b = c^2 void optimize_trans3(bigint_matrix &q, const int opt_level, ostream &s); // Same, but with additional line values to be updated void optimize_trans3(bigint_matrix &q, math_vector &l, const int opt_level, ostream &s); // Load balancing of columns of a matrix such that a*b = c*d void load_balancing(bigint_matrix &q, const bool &whatcase, ostream &s); // Load balancing of vectors of a matrix such that a*b = c*d bool load_balancing(const math_vector &v1, const math_vector &v2, bigint &mult, ostream &s); // Optimize by dividing columns 1, 2, 3 by a, b, c such that a b = c^2 // But here the two matrices should be divided simultaneously void optimize_trans4(bigint_matrix &q1, bigint_matrix &q2, const int opt_level, ostream &s); // Optimize the parameterization of a smooth quartic c1 + sqrt(xi). c2 + // eps. sqrt(Delta). (c3 + sqrt(xi). c4) // Simplification by the common factor of the parameterization void optimize(curve_param &c1, curve_param &c2, curve_param &c3, curve_param &c4, hom_polynomial &Delta1, hom_polynomial &Delta2, const int opt_level, ostream &s); // Optimize the parameterization of a conic c1 + sqrt(xi). c2 + eps. sqrt(D). (c3 // + sqrt(xi). c4) where D and xi are already optimized // Simplification by the common factor of the parameterization void optimize(curve_param &c1, curve_param &c2, curve_param &c3, curve_param &c4, ostream &s); // Compute the pseudo-discriminant of a quadratic homogeneous polynomial bigint discriminant2(const hom_polynomial &pol); } // end of namespace QI #endif