From e9840a1bbb0e1abb9bb8ebe31eb30293efa49aac Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Fri, 7 May 2021 00:42:49 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B2=D1=81=D0=B5=D1=85=20=D0=BF=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2?= =?UTF-8?q?=D1=81=D0=B5=D1=85=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 752d56a..947c3c4 100644 --- a/main.cpp +++ b/main.cpp @@ -18,9 +18,15 @@ const size_t ARGS_COUNT = 4; const size_t FUNCTION_LEN = 1ll << ARGS_COUNT; const size_t FUNCTIONS_COUNT = 1ll << FUNCTION_LEN; const bool ONLY_CREATE_CLASSES = false; +const bool GENERATE_ALL_REPRESENTATIONS = true; typedef Function MyFunction; typedef BoolSquareMatrix MyMatrix; +static_assert( + GENERATE_ALL_REPRESENTATIONS || !ONLY_CREATE_CLASSES, + "representations required NOT ONLY_CREATE_CLASSES" +); + map function_formulas; void test_function() { @@ -131,6 +137,11 @@ vector< MyMatrix > get_good_matrices() { vector get_function_class(MyFunction f, const vector< MyMatrix >& tranformations, ostream& out) { set cur_res; + if constexpr ( GENERATE_ALL_REPRESENTATIONS ) { + // Тут достаточно использовать функциональный класс из одной функции. + // Хорошо работает для k=4 и меньше + return vector{f}; + } for (Storage i = 0; i < FUNCTION_LEN; ++i) { MyFunction cur_f = f; for (Storage arg_ind = 0; arg_ind < ARGS_COUNT; ++arg_ind) @@ -335,7 +346,12 @@ void fill_ranks(vector monomials) { --functions_remains; used_map.at(el.value()) = 1; } - size_t total_ranks = recover_ranks(ranks, used_map, functions_remains); + + size_t total_ranks = 2; + if constexpr ( ONLY_CREATE_CLASSES ) { + total_ranks = recover_ranks(ranks, used_map, functions_remains); + } + clean_trash_ranks(ranks); cout << "recovered to " << total_ranks << endl; cout << "current ranks: " << endl; @@ -405,7 +421,7 @@ void fill_ranks(vector monomials) { << "\\hline" << endl << "\\endlastfoot" << endl << "\\hline" << endl - << "Номер класса & Длина & Размер класса & Полином\\\\" << endl + << "Номер класса & Длина & Размер класса & ПСПФ\\\\" << endl << "\\hline" << endl; ranks.clear(); @@ -423,7 +439,7 @@ void fill_ranks(vector monomials) { vector function_class = get_function_class( current_fn, possible_tranformations, cout ); - cout << "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 ) @@ -477,5 +493,12 @@ int main() { cout << "Monomials: " << monomials.size() << endl; fill_ranks(monomials); + + if constexpr ( GENERATE_ALL_REPRESENTATIONS ) { + ofstream f_out(("functions_strings_" + to_string(ARGS_COUNT) + ".txt").c_str()); + for (size_t i = 0; i < FUNCTIONS_COUNT; ++i) { + f_out << function_formulas[i] << "\n"; + } + } return 0; }