-
Notifications
You must be signed in to change notification settings - Fork 0
/
PolynomOther.h
55 lines (43 loc) · 1.85 KB
/
PolynomOther.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
#include "PolynomInt.h"
template<typename T>
class Polynom<T, typename std::enable_if<!std::is_integral<T>::value>::type>{
public:
Polynom(const Polynom<T>&); //theta(n)
Polynom(int size,T *data);
Polynom(std::initializer_list<T> l):coefficients(l){}
Polynom(Polynom<T>&&);
Polynom<T>& operator=(Polynom<T>&&);
Polynom<T>& operator=(const Polynom<T>&); //theta(n)
Polynom<T> operator+(Polynom<T>); //theta(n)
Polynom<T> operator+(); //O(1)
Polynom<T>& operator+=(const Polynom<T>& o){return *this=*this+o;};
Polynom<T> operator-(); //theta(n)
Polynom<T> operator-(Polynom<T>); //theta(n)
Polynom<T>& operator-=(const Polynom<T>& o){return *this=*this-o;};
Polynom<T> operator*(const Polynom<T>&);
Polynom<T>& operator*=(const Polynom<T>& o){return *this=*this*o;};
Polynom<T> operator*(const T&); //theta(n)
Polynom<T> operator/(const Polynom<T>& o) const{return euclidian(o).first;}; //O((n-m)*m)
Polynom<T> operator/(const T&); //theta(n)
Polynom<T>& operator/=(const Polynom<T>& o){return *this=*this/o;};
Polynom<T> operator%(const Polynom<T>& o) const{return euclidian(o).second;}; //O((n-m)*m)
Polynom<T>& operator%=(const Polynom<T>& o){return *this=*this%o;};
T operator()(const T&); //theta(n)
Polynom<T> derivate(std::size_t); //theta(n)
int border() const {return coefficients.size();};
bool operator==(const Polynom<T>&); //theta(n)
bool operator!=(const Polynom<T>&);
bool operator<(const Polynom<T>&); //O(1)
bool operator>(const Polynom<T>&);
template <typename U>
friend std::ostream& operator<<(std::ostream& os,const Polynom<U>&); //theta(n)
private:
std::vector<T> coefficients;
static const char *super[];
std::pair<Polynom<T>,Polynom<T>> euclidian(const Polynom<T>&) const;
void align(Polynom<T>&,Polynom<T>&);
void trimZeros();
Polynom(); //theta(deg)
Polynom<T> mult(int,T)const;
std::string sup(int num) const;
};