-
Notifications
You must be signed in to change notification settings - Fork 2
/
GaloisFieldPolynomial.h
115 lines (93 loc) · 6.15 KB
/
GaloisFieldPolynomial.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
*********************************************************************
* *
* Galois Field Arithmetic Library (version 0.0.1) *
* *
* Class: Galois Field Polynomial *
* Version: 0.0.1 *
* Author: Arash Partow - 2000 *
* URL: http://www.partow.net/projects/galois/index.html *
* *
* Copyright Notice: *
* Free use of this library is permitted under the guidelines and *
* in accordance with the most current version of the Common Public *
* License. *
* http://www.opensource.org/licenses/cpl.php *
* *
*********************************************************************
*/
#ifndef INCLUDE_GALOISFIELDPOLYNOMIAL_H
#define INCLUDE_GALOISFIELDPOLYNOMIAL_H
#include <iostream>
#include <vector>
#include <assert.h>
#include "GaloisField.h"
#include "GaloisFieldElement.h"
namespace galois
{
class GaloisFieldPolynomial
{
public:
GaloisFieldPolynomial(GaloisField* _gf);
GaloisFieldPolynomial(GaloisField* _gf = NULL, const unsigned int size = 0, GaloisFieldElement* gfe = NULL);
GaloisFieldPolynomial(const GaloisFieldPolynomial& polynomial);
GaloisFieldPolynomial(const GaloisFieldElement& gfe);
~GaloisFieldPolynomial(){};
bool valid() const;
unsigned int deg() const;
GaloisField* field() const;
void set_degree(const unsigned int& x);
void simplify();
GaloisFieldPolynomial& operator = (const GaloisFieldPolynomial& polynomial);
GaloisFieldPolynomial& operator = (const GaloisFieldElement& gfe);
GaloisFieldPolynomial& operator+= (const GaloisFieldPolynomial& polynomial);
GaloisFieldPolynomial& operator+= (const GaloisFieldElement& gfe);
GaloisFieldPolynomial& operator-= (const GaloisFieldPolynomial& polynomial);
GaloisFieldPolynomial& operator-= (const GaloisFieldElement& gfe);
GaloisFieldPolynomial& operator*= (const GaloisFieldPolynomial& polynomial);
GaloisFieldPolynomial& operator*= (const GaloisFieldElement& gfe);
GaloisFieldPolynomial& operator/= (const GaloisFieldPolynomial& divisor);
GaloisFieldPolynomial& operator/= (const GaloisFieldElement& gfe);
GaloisFieldPolynomial& operator%= (const GaloisFieldPolynomial& divisor);
GaloisFieldPolynomial& operator%= (const unsigned int& power);
GaloisFieldPolynomial& operator^= (const int& n);
GaloisFieldPolynomial& operator<<=(const unsigned int& n);
GaloisFieldPolynomial& operator>>=(const unsigned int& n);
GaloisFieldElement& operator[] (const unsigned int& term);
GaloisFieldElement operator() (const GaloisFieldElement& value);
GaloisFieldElement operator() (GFSymbol value);
const GaloisFieldElement& operator[](const unsigned int& term) const;
const GaloisFieldElement operator()(const GaloisFieldElement& value) const;
const GaloisFieldElement operator()(GFSymbol value) const;
bool operator==(const GaloisFieldPolynomial& polynomial) const;
bool operator!=(const GaloisFieldPolynomial& polynomial) const;
GaloisFieldPolynomial derivative();
friend std::ostream& operator << (std::ostream& os, const GaloisFieldPolynomial& polynomial);
private:
void simplify(GaloisFieldPolynomial& polynomial);
GaloisField* gf;
std::vector< GaloisFieldElement > poly;
};
GaloisFieldPolynomial operator + (const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator + (const GaloisFieldPolynomial& a, const GaloisFieldElement& b);
GaloisFieldPolynomial operator + (const GaloisFieldElement& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator + (const GaloisFieldPolynomial& a, const GFSymbol& b);
GaloisFieldPolynomial operator + (const GFSymbol& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator - (const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator - (const GaloisFieldPolynomial& a, const GaloisFieldElement& b);
GaloisFieldPolynomial operator - (const GaloisFieldElement& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator - (const GaloisFieldPolynomial& a, const GFSymbol& b);
GaloisFieldPolynomial operator - (const GFSymbol& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator * (const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator * (const GaloisFieldElement& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator * (const GaloisFieldPolynomial& a, const GaloisFieldElement& b);
GaloisFieldPolynomial operator / (const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator / (const GaloisFieldPolynomial& a, const GaloisFieldElement& b);
GaloisFieldPolynomial operator % (const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
GaloisFieldPolynomial operator % (const GaloisFieldPolynomial& a, const unsigned int& power);
GaloisFieldPolynomial operator ^ (const GaloisFieldPolynomial& a, const int& n);
GaloisFieldPolynomial operator <<(const GaloisFieldPolynomial& a, const unsigned int& n);
GaloisFieldPolynomial operator >>(const GaloisFieldPolynomial& a, const unsigned int& n);
GaloisFieldPolynomial gcd(const GaloisFieldPolynomial& a, const GaloisFieldPolynomial& b);
}
#endif