1 #ifndef COFAC_LIST_H
2 #define COFAC_LIST_H
3 
4 #include <cstdint>     // for int64_t, uint64_t
5 #include <cstdio>      // for FILE
6 #include <array>        // for array
7 #include <list>         // for list
8 #include <utility>      // for move
9 #include <gmp.h>        // for mpz_t
10 #include "macros.h"  // for MAYBE_UNUSED
11 #include "cado_poly.h"   // cxx_cado_poly
12 #include "mpz_poly.h"
13 #include "cxx_mpz.hpp"   // for cxx_mpz
14 
15 struct las_todo_entry; // IWYU pragma: keep
16 struct relation; // IWYU pragma: keep
17 
18 /* structure to compute on-line a product tree, avoiding to first compute a
19    list of mpz_t (which might take too much memory) */
20 typedef struct {
21   mpz_t *l;     /* the value stored is l[0] * l[1] * ... * l[size-1],
22                    where l[0] is the product of n[0] elements, l[1] is
23                    the product of n[1] elements, ..., with n[0]=0 or 1,
24                    n[1]=0 or 2, ..., n[k]=0 or 2^k */
25   unsigned long *n;
26   size_t size;
27 } mpz_product_tree_t;
28 typedef mpz_product_tree_t mpz_product_tree[1];
29 
30 struct cofac_candidate {
31   int64_t a;
32   uint64_t b;
33   std::array<cxx_mpz, 2> cofactor;
34   las_todo_entry const * doing_p;
35   cofac_candidate() = default;
cofac_candidatecofac_candidate36   cofac_candidate(int64_t a, uint64_t b, std::array<cxx_mpz,2> & cofactor, las_todo_entry const * doing_p)
37       : a(a), b(b), cofactor(std::move(cofactor)), doing_p(doing_p)
38       {}
39 };
40 
41 typedef std::list<cofac_candidate> cofac_list;
42 
43 /*
44  * These three functions add to to the double& extra_time argument the
45  * cpu time (RUSAGE_THREAD, seconds_thread()) spent in openmp helper
46  * threads, NOT counting the time spent in the main thread.
47  */
48 size_t find_smooth (
49         cofac_list & l,
50         std::array<cxx_mpz, 2> & batchP,
51         int batchlpb[2], int lpb[2], int batchmfb[2],
52         FILE *out,
53         int nthreads MAYBE_UNUSED, double &);
54 
55 std::list<relation> factor (cofac_list const &, cxx_cado_poly const&, int[2], int[2], int, FILE*, int, double&, int);
56 void create_batch_file (const char*, cxx_mpz &, unsigned long, unsigned long,
57                         cxx_mpz_poly const &, FILE*, int, double &);
58 
59 #endif /* COFAC_LIST_H */
60