17namespace layer5_applications {
18namespace user_interface {
23 f_make_macwilliams_system =
FALSE;
24 make_macwilliams_system_q = 0;
25 make_macwilliams_system_n = 0;
26 make_macwilliams_system_k = 0;
28 f_table_of_bounds =
FALSE;
29 table_of_bounds_n_max = 0;
30 table_of_bounds_q = 0;
32 f_make_bounds_for_d_given_n_and_k_and_q =
FALSE;
44 f_Hamming_space_distance_matrix =
FALSE;
48 f_general_code_binary =
FALSE;
49 general_code_binary_n = 0;
52 f_code_diagram =
FALSE;
57 f_code_diagram_from_file =
FALSE;
63 f_metric_balls =
FALSE;
64 metric_ball_radius = 0;
66 f_linear_code_through_basis =
FALSE;
67 linear_code_through_basis_n = 0;
70 f_linear_code_through_columns_of_parity_check_projectively =
FALSE;
71 f_linear_code_through_columns_of_parity_check =
FALSE;
72 linear_code_through_columns_of_parity_check_k = 0;
79 f_encode_text_5bits =
FALSE;
83 f_field_induction =
FALSE;
86 field_induction_nb_bits = 0;
92 std::string *argv,
int i,
int verbose_level)
96 if (ST.
stringcmp(argv[i],
"-make_macwilliams_system") == 0) {
97 cout <<
"-make_macwilliams_system <int : q> <int : n> <int k>" << endl;
99 else if (ST.
stringcmp(argv[i],
"-table_of_bounds") == 0) {
100 cout <<
"-table_of_bounds <int : n_max> <int : q> " << endl;
102 else if (ST.
stringcmp(argv[i],
"-make_bounds_for_d_given_n_and_k_and_q") == 0) {
103 cout <<
"-make_bounds_for_d_given_n_and_k_and_q <int : n> <int k> <int : q> " << endl;
105 else if (ST.
stringcmp(argv[i],
"-BCH") == 0) {
106 cout <<
"-BCH <int : n> <int : q> <int t>" << endl;
108 else if (ST.
stringcmp(argv[i],
"-BCH_dual") == 0) {
109 cout <<
"-BCH_dual <int : n> <int : q> <int t>" << endl;
111 else if (ST.
stringcmp(argv[i],
"-Hamming_space_distance_matrix") == 0) {
112 cout <<
"-Hamming_space_distance_matrix <int : n> <int : q>" << endl;
114 else if (ST.
stringcmp(argv[i],
"-general_code_binary") == 0) {
115 cout <<
"-general_code_binary <int : n> <string : set> " << endl;
117 else if (ST.
stringcmp(argv[i],
"-code_diagram") == 0) {
118 cout <<
"-code_diagram <string : label> <string : codewords> <int : n> " << endl;
120 else if (ST.
stringcmp(argv[i],
"-code_diagram_from_file") == 0) {
121 cout <<
"-code_diagram_from_file <string : label> <string : fname_codewords> <int : n> " << endl;
123 else if (ST.
stringcmp(argv[i],
"-enhance") == 0) {
124 cout <<
"-enhance <int : radius>" << endl;
126 else if (ST.
stringcmp(argv[i],
"-metric_balls") == 0) {
127 cout <<
"-metric_balls <int : radius_of_metric_ball> " << endl;
129 else if (ST.
stringcmp(argv[i],
"-linear_code_through_basis") == 0) {
130 cout <<
"-linear_code_through_basis <int : n> <string : set> " << endl;
132 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check_projectively") == 0) {
133 cout <<
"-linear_code_through_columns_of_parity_check <int : k> <string : set> " << endl;
135 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check") == 0) {
136 cout <<
"-linear_code_through_columns_of_parity_check <int : k> <string : set> " << endl;
138 else if (ST.
stringcmp(argv[i],
"-long_code") == 0) {
139 cout <<
"-long_code <int : n> <int : nb_generators=k> <string : generator_1> .. <string : generator_k>" << endl;
141 else if (ST.
stringcmp(argv[i],
"-encode_text_5bits") == 0) {
142 cout <<
"-encode_text_5bits <string : text> <string : fname>" << endl;
144 else if (ST.
stringcmp(argv[i],
"-field_induction") == 0) {
145 cout <<
"-field_induction <string : fname_in> <string : fname_out> <int : nb_bits>" << endl;
150 std::string *argv,
int i,
int verbose_level)
152 int f_v = (verbose_level >= 1);
159 cout <<
"interface_coding_theory::recognize_keyword argv[i]="
160 << argv[i] <<
" i=" << i <<
" argc=" << argc << endl;
162 if (ST.
stringcmp(argv[i],
"-make_macwilliams_system") == 0) {
165 else if (ST.
stringcmp(argv[i],
"-table_of_bounds") == 0) {
168 else if (ST.
stringcmp(argv[i],
"-make_bounds_for_d_given_n_and_k_and_q") == 0) {
171 else if (ST.
stringcmp(argv[i],
"-BCH") == 0) {
174 else if (ST.
stringcmp(argv[i],
"-BCH_dual") == 0) {
177 else if (ST.
stringcmp(argv[i],
"-Hamming_space_distance_matrix") == 0) {
180 else if (ST.
stringcmp(argv[i],
"-general_code_binary") == 0) {
183 else if (ST.
stringcmp(argv[i],
"-code_diagram") == 0) {
186 else if (ST.
stringcmp(argv[i],
"-code_diagram_from_file") == 0) {
189 else if (ST.
stringcmp(argv[i],
"-enhance") == 0) {
192 else if (ST.
stringcmp(argv[i],
"-metric_balls") == 0) {
195 else if (ST.
stringcmp(argv[i],
"-linear_code_through_basis") == 0) {
198 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check_projectively") == 0) {
201 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check") == 0) {
204 else if (ST.
stringcmp(argv[i],
"-long_code") == 0) {
207 else if (ST.
stringcmp(argv[i],
"-encode_text_5bits") == 0) {
210 else if (ST.
stringcmp(argv[i],
"-field_induction") == 0) {
214 cout <<
"interface_coding_theory::recognize_keyword not recognizing" << endl;
220 std::string *argv,
int &i,
int verbose_level)
222 int f_v = (verbose_level >= 1);
226 cout <<
"interface_coding_theory::read_arguments" << endl;
232 cout <<
"interface_coding_theory::read_arguments "
233 "the next argument is " << argv[i] << endl;
237 if (ST.
stringcmp(argv[i],
"-make_macwilliams_system") == 0) {
238 f_make_macwilliams_system =
TRUE;
239 make_macwilliams_system_n = ST.
strtoi(argv[++i]);
240 make_macwilliams_system_k = ST.
strtoi(argv[++i]);
241 make_macwilliams_system_q = ST.
strtoi(argv[++i]);
243 cout <<
"-make_macwilliams_system " << make_macwilliams_system_n <<
" " << make_macwilliams_system_k <<
" " << make_macwilliams_system_q << endl;
246 else if (ST.
stringcmp(argv[i],
"-table_of_bounds") == 0) {
247 f_table_of_bounds =
TRUE;
248 table_of_bounds_n_max = ST.
strtoi(argv[++i]);
249 table_of_bounds_q = ST.
strtoi(argv[++i]);
251 cout <<
"-table_of_bounds " << table_of_bounds_n_max
252 <<
" " << table_of_bounds_q << endl;
255 else if (ST.
stringcmp(argv[i],
"-make_bounds_for_d_given_n_and_k_and_q") == 0) {
256 f_make_bounds_for_d_given_n_and_k_and_q =
TRUE;
257 make_bounds_n = ST.
strtoi(argv[++i]);
258 make_bounds_k = ST.
strtoi(argv[++i]);
259 make_bounds_q = ST.
strtoi(argv[++i]);
261 cout <<
"-make_bounds_for_d_given_n_and_k_and_q "
262 << make_bounds_n <<
" " << make_bounds_k <<
" " << make_bounds_q << endl;
265 else if (ST.
stringcmp(argv[i],
"-BCH") == 0) {
267 BCH_n = ST.
strtoi(argv[++i]);
268 BCH_q = ST.
strtoi(argv[++i]);
269 BCH_t = ST.
strtoi(argv[++i]);
272 cout <<
"-BCH " << BCH_n <<
" " << BCH_q <<
" " << BCH_t << endl;
275 else if (ST.
stringcmp(argv[i],
"-BCH_dual") == 0) {
277 BCH_n = ST.
strtoi(argv[++i]);
278 BCH_q = ST.
strtoi(argv[++i]);
279 BCH_t = ST.
strtoi(argv[++i]);
282 cout <<
"-BCH " << BCH_n <<
" " << BCH_q <<
" " << BCH_t << endl;
285 else if (ST.
stringcmp(argv[i],
"-Hamming_space_distance_matrix") == 0) {
286 f_Hamming_space_distance_matrix =
TRUE;
287 Hamming_space_n = ST.
strtoi(argv[++i]);
288 Hamming_space_q = ST.
strtoi(argv[++i]);
290 cout <<
"-Hamming_space_distance_matrix " << Hamming_space_n <<
" " << Hamming_space_q << endl;
293 else if (ST.
stringcmp(argv[i],
"-general_code_binary") == 0) {
294 f_general_code_binary =
TRUE;
295 general_code_binary_n = ST.
strtoi(argv[++i]);
296 general_code_binary_text.assign(argv[++i]);
298 cout <<
"-general_code_binary " << general_code_binary_n <<
" "
299 << general_code_binary_text << endl;
302 else if (ST.
stringcmp(argv[i],
"-code_diagram") == 0) {
303 f_code_diagram =
TRUE;
304 code_diagram_label.assign(argv[++i]);
305 code_diagram_codewords_text.assign(argv[++i]);
306 code_diagram_n = ST.
strtoi(argv[++i]);
308 cout <<
"-code_diagram " << code_diagram_label
309 <<
" " << code_diagram_codewords_text
310 <<
" " << code_diagram_n << endl;
313 else if (ST.
stringcmp(argv[i],
"-code_diagram_from_file") == 0) {
314 f_code_diagram_from_file =
TRUE;
315 code_diagram_label.assign(argv[++i]);
316 code_diagram_from_file_codewords_fname.assign(argv[++i]);
317 code_diagram_n = ST.
strtoi(argv[++i]);
319 cout <<
"-code_diagram_from_file " << code_diagram_label
320 <<
" " << code_diagram_from_file_codewords_fname
321 <<
" " << code_diagram_n << endl;
325 else if (ST.
stringcmp(argv[i],
"-enhance") == 0) {
327 enhance_radius = ST.
strtoi(argv[++i]);
329 cout <<
"-enhance " << enhance_radius << endl;
333 else if (ST.
stringcmp(argv[i],
"-metric_balls") == 0) {
334 f_metric_balls =
TRUE;
335 metric_ball_radius = ST.
strtoi(argv[++i]);
337 cout <<
"-metric_balls " << metric_ball_radius << endl;
343 else if (ST.
stringcmp(argv[i],
"-linear_code_through_basis") == 0) {
344 f_linear_code_through_basis =
TRUE;
345 linear_code_through_basis_n = ST.
strtoi(argv[++i]);
346 linear_code_through_basis_text.assign(argv[++i]);
348 cout <<
"-linear_code_through_basis " << linear_code_through_basis_n
349 <<
" " << linear_code_through_basis_text << endl;
353 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check_projectively") == 0) {
354 f_linear_code_through_columns_of_parity_check_projectively =
TRUE;
355 linear_code_through_columns_of_parity_check_k = ST.
strtoi(argv[++i]);
356 linear_code_through_columns_of_parity_check_text.assign(argv[++i]);
358 cout <<
"-linear_code_through_columns_of_parity_check_projectively "
359 << linear_code_through_columns_of_parity_check_k
360 <<
" " << linear_code_through_columns_of_parity_check_text << endl;
364 else if (ST.
stringcmp(argv[i],
"-linear_code_through_columns_of_parity_check") == 0) {
365 f_linear_code_through_columns_of_parity_check =
TRUE;
366 linear_code_through_columns_of_parity_check_k = ST.
strtoi(argv[++i]);
367 linear_code_through_columns_of_parity_check_text.assign(argv[++i]);
369 cout <<
"-linear_code_through_columns_of_parity_check "
370 << linear_code_through_columns_of_parity_check_k
371 <<
" " << linear_code_through_columns_of_parity_check_text << endl;
375 else if (ST.
stringcmp(argv[i],
"-long_code") == 0) {
377 long_code_n = ST.
strtoi(argv[++i]);
381 for (h = 0; h < n; h++) {
386 if (stringcmp(s,
"-set_builder") == 0) {
387 set_builder_description Descr;
390 cout <<
"reading -set_builder" << endl;
392 i += Descr.read_arguments(argc - (i + 1),
393 argv + i + 1, verbose_level);
396 cout <<
"-set_builder" << endl;
397 cout <<
"i = " << i << endl;
398 cout <<
"argc = " << argc << endl;
400 cout <<
"next argument is " << argv[i] << endl;
406 S.init(&Descr, verbose_level);
409 cout <<
"set_builder found the following set of size " << S.sz << endl;
418 for (j = 0; j < S.sz; j++) {
422 sprintf(str,
"%ld", S.set[j]);
426 cout <<
"as string: " << s << endl;
431 long_code_generators.push_back(s);
434 cout <<
"-long_code " << long_code_n << endl;
435 for (
int h = 0; h < n; h++) {
436 cout <<
" " << long_code_generators[h] << endl;
440 else if (ST.
stringcmp(argv[i],
"-encode_text_5bits") == 0) {
441 f_encode_text_5bits =
TRUE;
442 encode_text_5bits_input.assign(argv[++i]);
443 encode_text_5bits_fname.assign(argv[++i]);
445 cout <<
"-encode_text_5bits " << encode_text_5bits_input <<
" "
446 << encode_text_5bits_fname << endl;
449 else if (ST.
stringcmp(argv[i],
"-field_induction") == 0) {
450 f_field_induction =
TRUE;
451 field_induction_fname_in.assign(argv[++i]);
452 field_induction_fname_out.assign(argv[++i]);
453 field_induction_nb_bits = ST.
strtoi(argv[++i]);
455 cout <<
"-field_induction " << field_induction_fname_in
456 <<
" " << field_induction_fname_out
457 <<
" " << field_induction_nb_bits
462 cout <<
"interface_coding_theory::read_arguments done" << endl;
469 if (f_make_macwilliams_system) {
470 cout <<
"-make_macwilliams_system " << make_macwilliams_system_n <<
" " << make_macwilliams_system_k <<
" " << make_macwilliams_system_q << endl;
472 if (f_table_of_bounds) {
473 cout <<
"-table_of_bounds " << table_of_bounds_n_max <<
" " << table_of_bounds_q << endl;
475 if (f_make_bounds_for_d_given_n_and_k_and_q) {
476 cout <<
"-make_bounds_for_d_given_n_and_k_and_q " << make_bounds_n <<
" " << make_bounds_k <<
" " << make_bounds_q << endl;
479 cout <<
"-BCH " << BCH_n <<
" " << BCH_q <<
" " << BCH_t << endl;
482 cout <<
"-BCH " << BCH_n <<
" " << BCH_q <<
" " << BCH_t << endl;
484 if (f_Hamming_space_distance_matrix) {
485 cout <<
"-Hamming_space_distance_matrix " << Hamming_space_n <<
" " << Hamming_space_q << endl;
487 if (f_general_code_binary) {
488 cout <<
"-general_code_binary " << general_code_binary_n <<
" "
489 << general_code_binary_text << endl;
491 if (f_code_diagram) {
492 cout <<
"-code_diagram " << code_diagram_label
493 <<
" " << code_diagram_codewords_text
494 <<
" " << code_diagram_n << endl;
496 if (f_code_diagram_from_file) {
497 cout <<
"-code_diagram_from_file " << code_diagram_label
498 <<
" " << code_diagram_from_file_codewords_fname
499 <<
" " << code_diagram_n << endl;
503 cout <<
"-enhance " << enhance_radius << endl;
506 if (f_metric_balls) {
507 cout <<
"-metric_balls " << metric_ball_radius << endl;
512 if (f_linear_code_through_basis) {
513 cout <<
"-linear_code_through_basis " << linear_code_through_basis_n
514 <<
" " << linear_code_through_basis_text << endl;
517 if (f_linear_code_through_columns_of_parity_check_projectively) {
518 cout <<
"-linear_code_through_columns_of_parity_check_projectively "
519 << linear_code_through_columns_of_parity_check_k
520 <<
" " << linear_code_through_columns_of_parity_check_text
524 if (f_linear_code_through_columns_of_parity_check) {
525 cout <<
"-linear_code_through_columns_of_parity_check "
526 << linear_code_through_columns_of_parity_check_k
527 <<
" " << linear_code_through_columns_of_parity_check_text
532 cout <<
"-long_code " << long_code_n << endl;
533 for (
int h = 0; h < long_code_n; h++) {
534 cout <<
" " << long_code_generators[h] << endl;
537 if (f_encode_text_5bits) {
538 cout <<
"-encode_text_5bits " << encode_text_5bits_input <<
" "
539 << encode_text_5bits_fname << endl;
541 if (f_field_induction) {
542 cout <<
"-field_induction " << field_induction_fname_in
543 <<
" " << field_induction_fname_out
544 <<
" " << field_induction_nb_bits
552 int f_v = (verbose_level >= 1);
555 cout <<
"interface_coding_theory::worker" << endl;
558 if (f_make_macwilliams_system) {
562 Coding.
do_make_macwilliams_system(make_macwilliams_system_q, make_macwilliams_system_n, make_macwilliams_system_k, verbose_level);
564 else if (f_table_of_bounds) {
570 else if (f_make_bounds_for_d_given_n_and_k_and_q) {
580 d_singleton = Coding.
singleton_bound_for_d(make_bounds_n, make_bounds_k, make_bounds_q, verbose_level);
581 d_hamming = Coding.
hamming_bound_for_d(make_bounds_n, make_bounds_k, make_bounds_q, verbose_level);
582 d_plotkin = Coding.
plotkin_bound_for_d(make_bounds_n, make_bounds_k, make_bounds_q, verbose_level);
583 d_griesmer = Coding.
griesmer_bound_for_d(make_bounds_n, make_bounds_k, make_bounds_q, verbose_level);
585 cout <<
"n = " << make_bounds_n <<
" k=" << make_bounds_k <<
" q=" << make_bounds_q << endl;
587 cout <<
"d_GV = " << d_GV << endl;
588 cout <<
"d_singleton = " << d_singleton << endl;
589 cout <<
"d_hamming = " << d_hamming << endl;
590 cout <<
"d_plotkin = " << d_plotkin << endl;
591 cout <<
"d_griesmer = " << d_griesmer << endl;
600 else if (f_BCH_dual) {
606 else if (f_Hamming_space_distance_matrix) {
611 FALSE , verbose_level);
613 else if (f_general_code_binary) {
616 int f_embellish =
FALSE;
623 Codes.
investigate_code(set, sz, general_code_binary_n, f_embellish, verbose_level);
629 else if (f_code_diagram) {
636 Lint_vec_scan(code_diagram_codewords_text, codewords, nb_words);
643 nb_words, code_diagram_n, f_metric_balls, metric_ball_radius,
648 else if (f_code_diagram_from_file) {
656 Fio.
lint_matrix_read_csv(code_diagram_from_file_codewords_fname, codewords, m, nb_words, verbose_level);
663 nb_words, code_diagram_n, f_metric_balls, metric_ball_radius,
664 f_enhance, enhance_radius,
668 else if (f_code_diagram_from_file) {
675 Lint_vec_scan(code_diagram_codewords_text, codewords, nb_words);
682 nb_words, code_diagram_n, f_metric_balls, metric_ball_radius,
683 f_enhance, enhance_radius,
687 else if (f_linear_code_through_basis) {
690 int f_embellish =
FALSE;
699 linear_code_through_basis_n,
708 else if (f_linear_code_through_columns_of_parity_check_projectively) {
720 set, linear_code_through_columns_of_parity_check_k ,
728 else if (f_linear_code_through_columns_of_parity_check) {
740 set, linear_code_through_columns_of_parity_check_k ,
747 else if (f_long_code) {
753 long_code_generators,
759 else if (f_encode_text_5bits) {
763 encode_text_5bits_fname,
767 else if (f_field_induction) {
771 field_induction_fname_out,
772 field_induction_nb_bits,
777 cout <<
"interface_coding_theory::worker done" << endl;
various functions related to coding theory
void do_long_code(int n, std::vector< std::string > &long_code_generators_text, int f_nearest_codeword, std::string &nearest_codeword_text, int verbose_level)
int plotkin_bound_for_d(int n, int k, int q, int verbose_level)
int gilbert_varshamov_lower_bound_for_d(int n, int k, int q, int verbose_level)
void encode_text_5bits(std::string &text, std::string &fname, int verbose_level)
void do_make_macwilliams_system(int q, int n, int k, int verbose_level)
void make_BCH_codes(int n, int q, int t, int b, int f_dual, int verbose_level)
int singleton_bound_for_d(int n, int k, int q, int verbose_level)
void do_linear_code_through_columns_of_parity_check(int n, long int *columns_set, int k, int verbose_level)
void make_Hamming_graph_and_write_file(int n, int q, int f_projective, int verbose_level)
void do_linear_code_through_basis(int n, long int *basis_set, int k, int f_embellish, int verbose_level)
int griesmer_bound_for_d(int n, int k, int q, int verbose_level)
void investigate_code(long int *Words, int nb_words, int n, int f_embellish, int verbose_level)
void do_linear_code_through_columns_of_parity_check_projectively(int n, long int *columns_set, int k, int verbose_level)
void code_diagram(std::string &label, long int *Words, int nb_words, int n, int f_metric_balls, int radius_of_metric_ball, int f_enhance, int radius, int verbose_level)
void field_induction(std::string &fname_in, std::string &fname_out, int nb_bits, int verbose_level)
void make_table_of_bounds(int n_max, int q, int verbose_level)
int hamming_bound_for_d(int n, int k, int q, int verbose_level)
void print(std::ostream &ost, long int *v, int len)
a collection of functions related to file io
void lint_matrix_read_csv(std::string &fname, long int *&M, int &m, int &n, int verbose_level)
void get_lint_vector_from_label(std::string &label, long int *&v, int &sz, int verbose_level)
data_structures::lint_vec * Lint_vec
interface_coding_theory()
void print_help(int argc, std::string *argv, int i, int verbose_level)
int recognize_keyword(int argc, std::string *argv, int i, int verbose_level)
void worker(int verbose_level)
void read_arguments(int argc, std::string *argv, int &i, int verbose_level)
#define Lint_vec_scan(A, B, C)
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects