-
Notifications
You must be signed in to change notification settings - Fork 0
/
Polynomial.h
56 lines (44 loc) · 1.61 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
50
51
52
53
54
#pragma once
#include "Value.h"
#include "Error.h"
#include <vector>
#include <string>
using namespace std;
class Polynomial
{
vector<Value> m_valuesVector;
string m_name;
static bool m_debug;
public:
Polynomial(const vector<Value>& valuesVector);
void name(const string& name);
const string& name() const;
int degree() const;
int size() const;
static bool debug();
static void debug(bool flag);
void debugPrint() const;
public:
Value& operator[](int index);
//const Value& operator[](int index) const;
Value operator()(const Value& x) const;
friend bool operator==(const Polynomial& lvalue, const Polynomial& rvalue);
friend bool operator!=(const Polynomial& lvalue, const Polynomial& rvalue){return !operator==(lvalue,rvalue);}
friend Polynomial operator+(const Polynomial& lvalue, const Polynomial& rvalue);
friend Polynomial operator-(const Polynomial& lvalue, const Polynomial& rvalue);
friend Polynomial operator*(const Polynomial& lvalue, const Polynomial& rvalue);
friend Polynomial operator*(const Value& lvalue, const Polynomial& rvalue);
friend Polynomial operator%(const Polynomial& lvalue, const Polynomial& rvalue);
// friend Polynomial operator/(const Polynomial& lvalue, const Polynomial& rvalue);
Polynomial& operator=(const Polynomial& rvalue);
friend std::ostream& operator<<(std::ostream& os, const Polynomial& obj);
public:
class IndexError : public Error
{
public:
IndexError() : Error() {};
IndexError(const string& message) : Error(message) {};
};
private:
Polynomial() {};
};