-
Notifications
You must be signed in to change notification settings - Fork 0
/
Polynomial.h
49 lines (33 loc) · 1.02 KB
/
Polynomial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <vector>
#include "Term.h"
/*
A polynomial in R[x_1, x_2,..., x_N].
Essentially an ordered list of terms.
When a term is added to the list, the list is sorted and reduced as
much as possible. The list always has at least one element.
Ordering is specified in constructor.
Valid options are: "lex", "grlex", and "grevlex".
*/
template<unsigned int N>
class Polynomial
{
public:
Polynomial(const char* monomialOrdering);
Polynomial(const char* polynomial, const char* monomialOrdering);
const char* getOrdering() const;
Term<N> leadingTerm() const;
void operator+=(const Term<N>& term);
void operator-=(Term<N> term);
void operator-=(const Polynomial<N>& polynomial);
Polynomial<N> operator-(const Polynomial<N>& polynomial) const;
Polynomial<N> operator*(const Term<N>& monomial) const;
void printP() const;
bool isZero() const;
private:
std::vector<Term<N>> terms;
const char* ordering;
void sortTerms();
void reduceTerms();
void printM(const Term<N>& t) const;
};