Orbiter 2022
Combinatorial Objects
create_BCH_code.cpp
Go to the documentation of this file.
1/*
2 * create_BCH_code.cpp
3 *
4 * Created on: Jan 13, 2022
5 * Author: betten
6 */
7
8
9
10#include "foundations.h"
11
12using namespace std;
13
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace coding_theory {
19
21{
22 n = 0;
23 d = 0;
24 F = NULL;
25
26 Nth = NULL;
27
28 P = NULL;
29
30 Selection = NULL;
31 Sel = NULL;
32 nb_sel = 0;
33
34 degree = 0;
35 k = 0;
36 Genma = NULL;
38}
39
41{
42}
43
44void create_BCH_code::init(field_theory::finite_field *F, int n, int d, int verbose_level)
45{
46 int f_v = (verbose_level >= 1);
47
48 if (f_v) {
49 cout << "create_BCH_code::init" << endl;
50 }
51
53
57
59
60 Nth->init(F, n, verbose_level);
61
62 int i, j;
63
64
66 Sel = NEW_int(Nth->Cyc->S->nb_sets);
67
68 for (i = 0; i < Nth->Cyc->S->nb_sets; i++) {
69 Selection[i] = FALSE;
70 }
71
72 for (i = 0; i < d - 1; i++) {
73 j = Nth->Cyc->Index[(1 + i) % n];
74 Selection[j] = TRUE;
75 }
76
77 nb_sel = 0;
78 for (i = 0; i < Nth->Cyc->S->nb_sets; i++) {
79 if (Selection[i]) {
80 Sel[nb_sel++] = i;
81 }
82 }
83
84 if (f_v) {
85 cout << "coding_theory_domain::make_BCH_code Sel=";
86 Int_vec_print(cout, Sel, nb_sel);
87 cout << endl;
88 }
89
91
93 Nth->FX->create_object_by_rank(*P, 1, __FILE__, __LINE__, 0 /*verbose_level*/);
94 Nth->FX->create_object_by_rank(Q, 1, __FILE__, __LINE__, 0 /*verbose_level*/);
95
96 for (i = 0; i < nb_sel; i++) {
97
98 j = Sel[i];
99
100 if (f_v) {
101 cout << "coding_theory_domain::make_BCH_code P=";
102 Nth->FX->print_object(*P, cout);
103 cout << endl;
104 cout << "j=" << j << endl;
105 Nth->FX->print_object(Nth->generator_Fq[j], cout);
106 cout << endl;
107 }
108 Nth->FX->mult(*P, Nth->generator_Fq[j], Q, verbose_level);
109 if (f_v) {
110 cout << "coding_theory_domain::make_BCH_code Q=";
111 Nth->FX->print_object(Q, cout);
112 cout << endl;
113 }
114 Nth->FX->assign(Q, *P, 0 /* verbose_level */);
115 }
116
117
118 degree = Nth->FX->degree(*P);
120 for (i = 0; i <= degree; i++) {
121 generator_polynomial[i] = Nth->FX->s_i(*P, i);
122 }
123
126
127 k = n - degree;
128
129
130 if (f_v) {
131 cout << "create_BCH_code::init done" << endl;
132 }
133}
134
135
136void create_BCH_code::report(std::ostream &ost, int verbose_level)
137{
138 int f_v = (verbose_level >= 1);
139 int i;
140 string label;
143
144 if (f_v) {
145 cout << "create_BCH_code::report" << endl;
146 }
147
148
149 ost << "\\noindent" << endl;
150 ost << "BCH-code:\\\\" << endl;
151 ost << "$n=" << n << ",$ $k=" << k << ",$ $d_0=" << d << ",$ $q=" << F->q << ",$ \\\\" << endl;
152 ost << "$g(x) = ";
153 for (i = 0; i < nb_sel; i++) {
154 ost << "m_{" << Sel[i] << "}";
155 }
156 ost << "=" << endl;
157 //ost << "$" << endl;
158 Nth->FX->print_object(*P, ost);
159 ost << "$" << endl;
160 ost << "\\\\" << endl;
161
162
163 ost << "\\noindent" << endl;
164 ost << "Chosen cyclotomic sets:\\\\" << endl;
166
167 ost << "\\bigskip" << endl;
168
169
170 ost << "The generator polynomial has degree " << degree << endl;
171
172 ost << "\\begin{verbatim}" << endl;
173 ost << "-dense \"";
174 Nth->FX->print_object_dense(*P, ost);
175 ost << "\"" << endl;
176 ost << endl;
177
178 ost << "-sparse \"";
179 Nth->FX->print_object_sparse(*P, ost);
180 ost << "\"" << endl;
181 ost << endl;
182 ost << "\\end{verbatim}" << endl;
183
184
185 if (n < 22) {
186
187 ost << "The generator matrix is:" << endl;
188 ost << "$$" << endl;
189 ost << "\\left[" << endl;
190 Li.int_matrix_print_tex(ost, Genma, k, n);
191 ost << "\\right]" << endl;
192 ost << "$$" << endl;
193
194 }
195
196 if (f_v) {
197 cout << "create_BCH_code::report done" << endl;
198 }
199}
200
201}}}
202
203
204
void generator_matrix_cyclic_code(field_theory::finite_field *F, int n, std::string &poly_coeffs, int verbose_level)
void report(std::ostream &ost, int verbose_level)
void init(field_theory::finite_field *F, int n, int d, int verbose_level)
the nth roots over Fq using an extension field
void init(finite_field *F, int n, int verbose_level)
Definition: nth_roots.cpp:62
void print_latex_with_selection(std::ostream &ost, int *Selection, int nb_sel)
void int_matrix_print_tex(std::ostream &ost, int *p, int m, int n)
void print_object_dense(unipoly_object p, std::ostream &ost)
void mult(unipoly_object a, unipoly_object b, unipoly_object &c, int verbose_level)
void create_object_by_rank(unipoly_object &p, long int rk, const char *file, int line, int verbose_level)
void print_object_sparse(unipoly_object p, std::ostream &ost)
void assign(unipoly_object a, unipoly_object &b, int verbose_level)
void print_object(unipoly_object p, std::ostream &ost)
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects