42#define POLY_GETIDENTITY(X)
43#define POLY_STOREIDENTITY
45#define POLY_GETIDENTITY(X) ALLPRIVATES *B = (X).Bpointer
46#define POLY_STOREIDENTITY Bpointer = B
51const int POLY_MAX_HASH_SIZE = MiN(1<<20, MAXPOSITIVE);
59 ALLPRIVATES *Bpointer;
67 poly (PHEAD
int, WORD=-1, WORD=1);
68 poly (PHEAD
const UWORD *, WORD, WORD=-1, WORD=1);
69 poly (
const poly &, WORD=-1, WORD=1);
79 const poly operator+ (
const poly&)
const;
80 const poly operator- (
const poly&)
const;
81 const poly operator* (
const poly&)
const;
82 const poly operator/ (
const poly&)
const;
83 const poly operator% (
const poly&)
const;
85 bool operator== (
const poly&)
const;
86 bool operator!= (
const poly&)
const;
88 WORD& operator[] (
int);
89 const WORD& operator[] (
int)
const;
91#if __cplusplus >= 201103L
93 poly (
poly &&, WORD=-1, WORD=1)
noexcept;
98 void termscopy (
const WORD *,
int,
int);
99 void check_memory(
int);
100 void expand_memory(
int);
103 bool is_zero ()
const;
104 bool is_one ()
const;
105 bool is_integer ()
const;
106 bool is_monomial ()
const;
111 int degree (
int)
const;
112 int total_degree ()
const;
113 int first_variable ()
const;
114 int number_of_terms ()
const;
115 const std::vector<int> all_variables ()
const;
116 const poly integer_lcoeff ()
const;
117 const poly lcoeff_univar (
int)
const;
118 const poly lcoeff_multivar (
int)
const;
119 const poly coefficient (
int,
int)
const;
120 const poly derivative (
int)
const;
123 void setmod(WORD, WORD=1);
124 void coefficients_modulo (UWORD *, WORD,
bool);
127 static const poly simple_poly (PHEAD
int,
int=0,
int=1,
int=0,
int=1);
128 static const poly simple_poly (PHEAD
int,
const poly&,
int=1,
int=0,
int=1);
131 static void get_variables (PHEAD
const std::vector<WORD *> &,
bool,
bool);
132 static const poly argument_to_poly (PHEAD WORD *,
bool,
bool,
poly *den=NULL);
133 static void poly_to_argument (
const poly &, WORD *,
bool);
134 static void poly_to_argument_with_den (
const poly &, WORD,
const UWORD *, WORD *,
bool);
135 int size_of_form_notation ()
const;
136 int size_of_form_notation_with_den (WORD)
const;
137 const poly & normalize ();
140 static const poly from_coefficient_list (PHEAD
const std::vector<WORD> &,
int, WORD);
141 static const std::vector<WORD> to_coefficient_list (
const poly &);
142 static const std::vector<WORD> coefficient_list_divmod (
const std::vector<WORD> &,
const std::vector<WORD> &, WORD,
int);
145 const std::string to_string()
const;
148 static int monomial_compare (PHEAD
const WORD *,
const WORD *);
149 WORD last_monomial_index ()
const;
150 WORD* last_monomial ()
const;
151 int compare_degree_vector(
const poly &)
const;
152 std::vector<int> degree_vector()
const;
153 int compare_degree_vector(
const std::vector<int> &)
const;
162 static bool divides (
const poly &,
const poly &);
164 static void mul_one_term (
const poly &,
const poly &,
poly &);
165 static void mul_univar (
const poly &,
const poly &,
poly &,
int);
168 static void divmod_one_term (
const poly &,
const poly &,
poly &,
poly &,
bool);
172 static void push_heap (PHEAD WORD **,
int);
173 static void pop_heap (PHEAD WORD **,
int);
188 bool operator()(
const WORD *a,
const WORD *b) {
189 return poly::monomial_compare(BHEAD a, b) > 0;
194std::ostream& operator<< (std::ostream &,
const poly &);
198#if __cplusplus >= 201103L
200inline poly::poly (
poly &&a, WORD modp, WORD modn)
noexcept {
201#ifdef POLY_MOVE_DEBUG
202 std::cout <<
"poly move ctor" << std::endl;
207 size_of_terms = a.size_of_terms;
214 a.size_of_terms = -1;
217inline poly& poly::operator= (
poly &&a)
noexcept {
218#ifdef POLY_MOVE_DEBUG
219 std::cout <<
"poly move assign" << std::endl;
222 WORD *old_terms = terms;
223 LONG old_size_of_terms = size_of_terms;
225 size_of_terms = a.size_of_terms;
229 a.size_of_terms = old_size_of_terms;
240inline void poly::check_memory (
int i) {
241 POLY_GETIDENTITY(*
this);
242 if (i + 3 + AN.poly_num_vars + AM.MaxTal >= size_of_terms) expand_memory(i + AM.MaxTal);
247inline WORD& poly::operator[] (
int i) {
251inline const WORD& poly::operator[] (
int i)
const {
258inline void poly::termscopy (
const WORD *source,
int dest,
int num) {
259#ifdef POLY_MOVE_DEBUG
260 std::cout <<
"poly termscopy: num=" << num << std::endl;
262 memcpy (terms+dest, source, num*
sizeof(WORD));
static void divmod(const poly &, const poly &, poly &, poly &, bool only_divides)
static void mul_heap(const poly &, const poly &, poly &)
int is_dense_univariate() const
static void divmod_univar(const poly &, const poly &, poly &, poly &, int, bool)
static void mul(const poly &, const poly &, poly &)
static void divmod_heap(const poly &, const poly &, poly &, poly &, bool, bool, bool &)