-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpseudocode.tex
173 lines (152 loc) · 4.5 KB
/
pseudocode.tex
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
\documentclass[fleqn,14pt,a5paper]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian, english]{babel}
\usepackage{fullpage}
\usepackage{times}
\usepackage{graphicx,amssymb, amstext, amsmath, epstopdf, booktabs, verbatim, gensymb, appendix, natbib, lmodern}
\usepackage[margin=0.5in]{geometry}
\geometry{a5paper}
\pagenumbering{gobble}
\usepackage{algpseudocode}
\usepackage{amsmath}
\begin{document}
% Берлекамп
\par ВХОД: $poly$ - многочлен над полем Галуа $GF[P]$
\par РЕЗУЛЬТАТ: $true$ если многочлен неприводим, иначе $false$
\begin{algorithmic}[1]
\If{$poly = 0$}
\State return $false$
\EndIf
\State $n = \deg(poly)$
\If{$n = 0$ or ($poly[0] = 0$ and $n > 1$)}
\State return $false$
\EndIf
\If{$n = 1$}
\State return $true$
\EndIf
\State
\State $poly' = \frac{\partial poly}{\partial x}$
\If{$poly' = 0$}
\State return $false$
\EndIf
\If{$\deg\left(\gcd\left(poly, poly'\right)\right) = 0$}
\State \textbf{return} $false$
\EndIf
\State $B =
\begin{pmatrix}
x^0 & mod & poly \\
x^P & mod & poly \\
\dots & \dots & \dots \\
x^{P\times (P-1)} & mod & poly
\end{pmatrix}$
\State $B = B - E$
\State $r = rank(B)$
\If{$r = \deg(poly) - 1$}
\State return $true$
\Else
\State return $false$
\EndIf
\end{algorithmic}
\clearpage
% Рабин
\par ВХОД: $poly$ - многочлен над полем Галуа $GF[P]$ степени $n$,
\par $p_1, \dots, p_k$ – простые делители $n$
\par РЕЗУЛЬТАТ: $true$ если многочлен неприводим, иначе $false$
\begin{algorithmic}[1]
\If{$poly = 0$}
\State return $false$
\EndIf
\If{$n = 0$ or ($poly[0] = 0$ and $n > 1$)}
\State return $false$
\EndIf
\If{$n = 1$}
\State return $true$
\EndIf
\State
\For{$i = 1..k$}
\State $n_i = \frac{n}{p_j}$
\State $g = \gcd\left( poly, x^{P^{n_i}} - x \; (mod \; poly) \right)$
\If{$g = 0$ or $\deg(g) > 0$}
\State return $false$
\EndIf
\EndFor
\State $g = \gcd\left( poly, x^{P^n} - x \; (mod \; poly) \right)$
\If{$g = 0$}
\State return $true$
\Else
\State return $false$
\EndIf
\end{algorithmic}
\clearpage
% Бен-Ор
\par ВХОД: $poly$ - многочлен над полем Галуа $GF[P]$
\par РЕЗУЛЬТАТ: $true$ если многочлен неприводим, иначе $false$
\begin{algorithmic}[1]
\If{$poly = 0$}
\State return $false$
\EndIf
\State $n = \deg(poly)$
\If{$n = 0$ or ($poly[0] = 0$ and $n > 1$)}
\State return $false$
\EndIf
\If{$n = 1$}
\State return $true$
\EndIf
\State
\State $n = \deg(poly)$
\For{$i = 1..\left[\frac{m}{2}\right]$}
\State $g = \gcd\left( poly, x^{P^{i}} - x \; (mod \; poly) \right)$
\If{$g = 0$ or $\deg(g) > 0$}
\State return $false$
\EndIf
\EndFor
\State return $true$
\end{algorithmic}
\clearpage
% Примитивность
\par ВХОД: $poly$ - многочлен над полем Галуа $GF[P]$,
\par $p_1, \dots, p_k$ – простые дилители $P-1$ за исключением $1$ и самого $P-1$
\par РЕЗУЛЬТАТ: $true$ если многочлен неприводим, иначе $false$
\begin{algorithmic}[1]
\If{$poly = 0$}
\State return $false$
\EndIf
\State $n = \deg(poly)$
\If{$n = 0$ or ($poly[0] = 0$ and $n > 1$)}
\State return $false$
\EndIf
\State
\State $poly = noramlize(poly)$
\If{$poly = x$}
\State return $true$
\EndIf
\If{$P = 2$ and $poly = 1 + x$}
\State return $false$
\EndIf
\State
\If{$P > 2$}
\For{$i = 1..k$}
\State $l = (-1)^n \;(mod \; P)$
\State $el = l^{\frac{P-1}{p_i}}$
\If{$el = 1$}
\State return $false$
\EndIf
\EndFor
\EndIf
\State
\State $l = (-1)^n \;(mod \; P)$
\State $r = \frac{p^n - 1}{p - 1}$
\If{$x^r \neq l$}
\State return $false$
\EndIf
\State
\For{$i = 1..k$}
\State $tmp = x^{\frac{r}{q_i}} \; (mod \; poly)$
\If{$\deg(tmp) = 0$}
\State return $false$
\EndIf
\EndFor
\State return $true$
\end{algorithmic}
\end{document}