-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoly_and_ratio.hpp
91 lines (67 loc) · 1.73 KB
/
poly_and_ratio.hpp
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
/**
* Ðåàë³çàö³ÿ êëàñ³â ïîë³íîì òà ðàö³îíàëüíà ôóíêö³ÿ, êîåô³ö³ºíòè ÿêèõ íàëåæàòü äåÿêîìó ê³ëüöþ ëèøê³â
*/
#include <unordered_map>
#include <string>
#include "modular_arithmetic.hpp"
#ifndef POLY_AND_RATIO_H
#define POLY_AND_RATIO_H
/**
* Êëàñ ïîë³íîì
* data - õåø-òàáëèöÿ êîåô³ö³ºíò³â Galois, â ÿê³é êëþ÷ ìຠìàòè âèãëÿä "m, k",
* ùî â³äïîâ³äຠìîíîìó x^m * y^k, äå k, m º íåâ³ä'ºìíèìè ö³ëèìè ÷èñëàìè
* ïàðàìåòð mod âèçíà÷ຠÿêîìó ê³ëüöþ ëèøê³â ìàþòü íàëåæàòè êîåô³ö³ºíòè
*/
class Poly
{
private:
std::unordered_map<std::string, Galois> data;
int_fast64_t mod;
public:
Poly(std::unordered_map<std::string, Galois>& data, int_fast64_t mod);
/**
* Ñòâîðþº ïîë³íîì 0 * x^0 * y^0 ç êîåô³ö³ºíòàìè, ÿê³ íàëåæàòü ê³ëüöþ ëèøê³â ïî ìîäóëþ mod
*/
Poly(uint_fast32_t mod);
Poly() {}
Poly operator+ (const Poly& other);
Poly operator* (const Poly& other);
Poly operator* (const Galois& other);
/**
* Ïîâåðòຠçíà÷åííÿ ïîë³íîìà â òî÷ö³ (x, y)
*/
Galois value(Galois& x, Galois& y);
/**
* Ïîâåðòຠñòðîêîâå ïðåäñòàâëåííÿ ïîë³íîìà
*/
std::string get_str();
int_fast16_t get_mod();
/**
* Ïîâåðòຠõåø-òàáëèöþ êîåô³ö³ºíò³â ïîë³íîìà
*/
std::unordered_map<std::string, Galois> get_data();
};
/**
* Êëàñ ðàö³îíàëüíà ôóíêö³ÿ
* numerator, denominator - ïîë³íîìè, ÿê³ ìàþòü êîåô³ö³ºíòè ç îäíîãî ê³ëüöÿ ëèøê³â
*/
class Ratio
{
private:
Poly numerator, denominator;
public:
Ratio(Poly& p1, Poly& p2);
Ratio(uint_fast32_t mod);
Ratio operator* (const Ratio& other);
Ratio operator* (const Poly& other);
Ratio operator* (const Galois& other);
/**
* Ïîâåðòຠñòðîêîâå ïðåäñòàâëåííÿ ðàö³îíàëüíî¿ ôóíêö³¿
*/
std::string get_str();
/**
* Ïîâåðòຠçíà÷åííÿ ðàö³îíàëüíî¿ ôóíêö³¿ â òî÷ö³ (x, y)
*/
Galois value(Galois& x, Galois& y);
};
#endif