38#define POLY_GETIDENTITY(X)
39#define POLY_STOREIDENTITY
41#define POLY_GETIDENTITY(X) ALLPRIVATES *B = (X).Bpointer
42#define POLY_STOREIDENTITY Bpointer = B
47const int POLY_MAX_HASH_SIZE = MiN(1<<20, MAXPOSITIVE);
55 ALLPRIVATES *Bpointer;
63 poly (PHEAD
int, WORD=-1, WORD=1);
64 poly (PHEAD
const UWORD *, WORD, WORD=-1, WORD=1);
65 poly (
const poly &, WORD=-1, WORD=1);
75 const poly operator+ (
const poly&)
const;
76 const poly operator- (
const poly&)
const;
77 const poly operator* (
const poly&)
const;
78 const poly operator/ (
const poly&)
const;
79 const poly operator% (
const poly&)
const;
81 bool operator== (
const poly&)
const;
82 bool operator!= (
const poly&)
const;
84 WORD& operator[] (
int);
85 const WORD& operator[] (
int)
const;
88 void termscopy (
const WORD *,
int,
int);
89 void check_memory(
int);
90 void expand_memory(
int);
93 bool is_zero ()
const;
95 bool is_integer ()
const;
96 bool is_monomial ()
const;
101 int degree (
int)
const;
102 int total_degree ()
const;
103 int first_variable ()
const;
104 int number_of_terms ()
const;
105 const std::vector<int> all_variables ()
const;
106 const poly integer_lcoeff ()
const;
107 const poly lcoeff_univar (
int)
const;
108 const poly lcoeff_multivar (
int)
const;
109 const poly coefficient (
int,
int)
const;
110 const poly derivative (
int)
const;
113 void setmod(WORD, WORD=1);
114 void coefficients_modulo (UWORD *, WORD,
bool);
117 static const poly simple_poly (PHEAD
int,
int=0,
int=1,
int=0,
int=1);
118 static const poly simple_poly (PHEAD
int,
const poly&,
int=1,
int=0,
int=1);
121 static void get_variables (PHEAD std::vector<WORD *>,
bool,
bool);
122 static const poly argument_to_poly (PHEAD WORD *,
bool,
bool,
poly *den=NULL);
123 static void poly_to_argument (
const poly &, WORD *,
bool);
124 static void poly_to_argument_with_den (
const poly &, WORD,
const UWORD *, WORD *,
bool);
125 int size_of_form_notation ()
const;
126 int size_of_form_notation_with_den (WORD)
const;
127 const poly & normalize ();
130 static const poly from_coefficient_list (PHEAD
const std::vector<WORD> &,
int, WORD);
131 static const std::vector<WORD> to_coefficient_list (
const poly &);
132 static const std::vector<WORD> coefficient_list_divmod (
const std::vector<WORD> &,
const std::vector<WORD> &, WORD,
int);
135 const std::string to_string()
const;
138 static int monomial_compare (PHEAD
const WORD *,
const WORD *);
139 WORD last_monomial_index ()
const;
140 WORD* last_monomial ()
const;
141 int compare_degree_vector(
const poly &)
const;
142 std::vector<int> degree_vector()
const;
143 int compare_degree_vector(
const std::vector<int> &)
const;
152 static bool divides (
const poly &,
const poly &);
154 static void mul_one_term (
const poly &,
const poly &,
poly &);
155 static void mul_univar (
const poly &,
const poly &,
poly &,
int);
158 static void divmod_one_term (
const poly &,
const poly &,
poly &,
poly &,
bool);
162 static void push_heap (PHEAD WORD **,
int);
163 static void pop_heap (PHEAD WORD **,
int);
180 bool operator()(
const WORD *a,
const WORD *b) {
181 return poly::monomial_compare(BHEAD a, b) > 0;
186std::ostream& operator<< (std::ostream &,
const poly &);
194inline void poly::check_memory (
int i) {
195 POLY_GETIDENTITY(*
this);
196 if (i + 3 + AN.poly_num_vars + AM.MaxTal >= size_of_terms) expand_memory(i + AM.MaxTal);
201inline WORD& poly::operator[] (
int i) {
205inline const WORD& poly::operator[] (
int i)
const {
212inline void poly::termscopy (
const WORD *source,
int dest,
int num) {
213 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 &)