1 #ifndef GINAC_PGCD_EVAL_POINT_FINDER_H
2 #define GINAC_PGCD_EVAL_POINT_FINDER_H
9 /// Find a `good' evaluation point b \in Z_p for a pair of multivariate
10 /// polynomials A, B \in Z_p[x_n][x_0, \ldots, x_n]. Here `good' means
11 /// that b is not a root of GCD of contents of A and B. N.B. content
12 /// is univariate polynomial \in Z_p[x_n]
13 struct eval_point_finder
15 typedef long value_type;
17 std::set<value_type> points;
18 const random_modint modint_generator;
19 bool operator()(value_type& b, const ex& g, const ex& x);
20 eval_point_finder(const value_type& p_) : p(p_), modint_generator(p)
24 bool eval_point_finder::operator()(value_type& b, const ex& lc, const ex& x)
26 random_modint modint_generator(p);
27 // Search for a new element of field
28 while (points.size() < p - 1) {
29 value_type b_ = modint_generator();
30 // check if this evaluation point was already used
31 if (points.find(b_) != points.end())
34 // mark found value as used, even if it's a root of lc
35 // (so we don't need to do the check once more)
37 // Now make sure it's NOT the root of GCD's leading coeffient
38 if (lc.subs(x == numeric(b_)).smod(numeric(p)).is_zero())
40 // Nice, it's our next evaluation point
44 // All possible evaluation points were used.
50 #endif /* GINAC_PGCD_EVAL_POINT_FINDER_H */