Improved tex output to file
This commit is contained in:
40
main.cpp
40
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<Storage, FUNCTION_LEN> MyFunction;
|
||||
@@ -229,7 +229,8 @@ vector<MyFunction> get_all_monomials(const vector<MyFunction> &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<MyFunction> monomials) {
|
||||
vector<int8_t> used_map(FUNCTIONS_COUNT, 0);
|
||||
size_t functions_remains = FUNCTIONS_COUNT;
|
||||
|
||||
ofstream f_out("out.txt");
|
||||
vector< vector<MyFunction> > ranks;
|
||||
ranks.push_back(vector<MyFunction>()); // empty set
|
||||
ranks.push_back(monomials); // empty set
|
||||
@@ -282,6 +282,18 @@ void fill_ranks(vector<MyFunction> 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<MyFunction>()); // empty set
|
||||
@@ -295,9 +307,9 @@ void fill_ranks(vector<MyFunction> monomials) {
|
||||
++total_unique_functions;
|
||||
MyFunction current_fn(fn_value);
|
||||
vector<MyFunction> 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<MyFunction> 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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user