From e99f1874ade29c8d3b891c6ff4d653ef21e2c986 Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Sun, 22 Mar 2020 18:35:13 +0300 Subject: [PATCH] Improved tex output to file --- main.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 216c3ed..74b7699 100644 --- a/main.cpp +++ b/main.cpp @@ -13,7 +13,7 @@ using namespace std; typedef uint16_t Storage; -const size_t ARGS_COUNT = 2; +const size_t ARGS_COUNT = 4; const size_t FUNCTION_LEN = 1ll << ARGS_COUNT; const size_t FUNCTIONS_COUNT = 1ll << FUNCTION_LEN; typedef Function MyFunction; @@ -229,7 +229,8 @@ vector get_all_monomials(const vector &linear_combinatio if ( is_added_now ) { Storage cur_value = (el_first and el_second).value(); function_formulas[cur_value] = preprocess_factor(function_formulas[el_first.value()]) - + " * " + preprocess_factor(function_formulas[el_second.value()]); + + " " + preprocess_factor(function_formulas[el_second.value()]); + // no symbol for multiplication needed } is_added = is_added or is_added_now; } @@ -245,7 +246,6 @@ void fill_ranks(vector monomials) { vector used_map(FUNCTIONS_COUNT, 0); size_t functions_remains = FUNCTIONS_COUNT; - ofstream f_out("out.txt"); vector< vector > ranks; ranks.push_back(vector()); // empty set ranks.push_back(monomials); // empty set @@ -282,6 +282,18 @@ void fill_ranks(vector monomials) { auto possible_tranformations = get_good_matrices(); cout << "Total " << possible_tranformations.size() << " linear tranformations" << endl; + ofstream f_out("out.tex"); + f_out << "\\begin{longtable}{| l| l | l | p{70mm} |}" << endl + << "\\hline" << endl + << "\\endhead" << endl + << "\\hline \\multicolumn{4}{r}{\\textit{Продолжение на следующей странице}} \\\\" << endl + << "\\endfoot" << endl + << "\\hline" << endl + << "\\endlastfoot" << endl + << "\\hline" << endl + << "Номер класса & Длина & Размер класса & Полином\\\\" << endl + << "\\hline" << endl; + ranks.clear(); for (auto i = total_ranks - 1; i != 0; --i) ranks.push_back(vector()); // empty set @@ -295,9 +307,9 @@ void fill_ranks(vector monomials) { ++total_unique_functions; MyFunction current_fn(fn_value); vector function_class = get_function_class( - current_fn, possible_tranformations, f_out + current_fn, possible_tranformations, cout ); - f_out << "size of function class " << current_fn.string() << " is " << function_class.size() << endl; + cout << "size of function class " << current_fn.string() << " is " << function_class.size() << endl; class_sizes[current_fn] = function_class.size(); for (auto marked_function: function_class) { if ( used_map[marked_function.value()] == 0 ) @@ -312,12 +324,24 @@ void fill_ranks(vector monomials) { cout << "total counted functions: " << total_functions << " but must be " << FUNCTIONS_COUNT << endl; cout << "total function classes: " << total_unique_functions << endl; + size_t function_index = 1; for (size_t rank_ind = 0; rank_ind < ranks.size(); ++rank_ind) { - f_out << "rank index = " << rank_ind + 1 << endl; - for (auto f: ranks.at(rank_ind)) - f_out << f.string() << " size: " << class_sizes[f] << " " + cout << "rank index = " << rank_ind + 1 << endl; + f_out << "\\hline" << endl; + for (auto f: ranks.at(rank_ind)) { + cout << f.string() << " size: " << class_sizes[f] << " " << function_formulas[f.value()] << endl; + f_out << " " << function_index << " & " << rank_ind + 1 << " & " + << class_sizes[f] << " & $" << function_formulas[f.value()] << "$ \\\\" << endl; + ++function_index; + } } + + f_out << " \\hline" << endl + << "\\end{longtable}" << endl + << "\\captionof{figure}{Классы псевдополиномов}" << endl + << "\\label{fig:polynoms}" << endl + << "\\addtocounter{table}{-1}" << endl; f_out.close(); }