1 #ifndef FACUL_HPP_ 2 #define FACUL_HPP_ 3 4 #include <cstdio> // for FILE 5 #include <array> // for array 6 #include <vector> // for vector 7 #include "facul_fwd.hpp" 8 struct cxx_mpz; 9 10 11 #define PM1_METHOD 1 12 #define PP1_27_METHOD 2 13 #define PP1_65_METHOD 3 14 #define EC_METHOD 4 15 #define MPQS_METHOD 5 16 17 /* we should have FACUL_NOT_SMOOTH < 0, FACUL_MAYBE = 0, 18 and FACUL_SMOOTH, FACUL_AUX >= 1 */ 19 #define FACUL_NOT_SMOOTH (-1) 20 #define FACUL_MAYBE (0) 21 #define FACUL_SMOOTH (1) 22 #define FACUL_AUX (2) 23 24 #define STATS_LEN 128 25 26 /* We authorize at most NB_MAX_METHODS different methods in our 27 * strategies. For the descent, we do have an interest in raising this 28 * number somewhat. 29 */ 30 #define NB_MAX_METHODS 400 31 32 /* All prime factors in the input number must be > fb. A factor of the 33 input number is assumed to be prime if it is < fb^2. 34 The input number is taken to be not smooth if it has a 35 prime factor > 2^lpb. */ 36 37 typedef struct facul_strategy_s { 38 unsigned long lpb; /* Large prime bound 2^lpb */ 39 double assume_prime_thresh; /* The factor base bound squared. 40 We assume that primes <= fbb have already been 41 removed, thus any factor <= assume_prime_thresh 42 is assumed prime without further test. */ 43 double BBB; /* The factor base bound cubed. */ 44 facul_method_t *methods; /* List of methods to try */ 45 } facul_strategy_t; 46 47 typedef struct { 48 facul_method_t* method; 49 int side; /* To know on which side this method will be applied */ 50 int is_the_last; /* To know if this method is the last on its side 51 (used when you chain methods). */ 52 }facul_method_side_t; 53 54 typedef struct { 55 unsigned long lpb[2]; /* Large prime bounds 2^lpb */ 56 double assume_prime_thresh[2]; /* The factor base bounds squared. 57 We assume that primes <= fbb have 58 already been removed, thus any 59 factor <= assume_prime_thresh is 60 assumed prime without further 61 test. */ 62 double BBB[2]; /* The factor base bounds cubed. */ 63 unsigned int mfb[2]; /* The cofactor bounds.*/ 64 facul_method_side_t ***methods; /* List of methods to factor each pair 65 of cofactors.*/ 66 facul_method_t* precomputed_methods; /* Optimization for 67 facul_make_strategies ().*/ 68 69 facul_method_side_t * uniform_strategy[2]; /* this is 0 if we have a 70 strategy file, and 1 if we 71 just have a uniform 72 one-size-fits-all strategy. 73 In the latter case, we avoid 74 most of the allocation */ 75 } facul_strategies_t; 76 77 78 79 facul_method_t* facul_make_default_strategy (int, const int); 80 void facul_clear_methods (facul_method_t*); 81 82 int nb_curves (unsigned int, unsigned int); 83 facul_strategy_t * facul_make_strategy (unsigned long, unsigned int, unsigned int, int, int); 84 void facul_clear_strategy (facul_strategy_t *); 85 void facul_print_stats (FILE *); 86 int facul (std::vector<cxx_mpz> &, cxx_mpz const &, const facul_strategy_t *); 87 88 facul_strategies_t* facul_make_strategies (unsigned long, unsigned int, 89 unsigned int, unsigned long, 90 unsigned int, unsigned int, 91 bool, 92 int, int, FILE*, const int); 93 94 void facul_clear_strategies (facul_strategies_t*); 95 96 int 97 facul_fprint_strategies (FILE*, facul_strategies_t* ); 98 99 100 std::array<int,2> 101 facul_both (std::array<std::vector<cxx_mpz>, 2>&, std::array<cxx_mpz, 2> & , 102 const facul_strategies_t *, int*); 103 104 #endif /* FACUL_HPP_ */ 105