From f5888f68260b871d2d9596fbc7eb52edc0c16400 Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Wed, 28 Mar 2018 15:30:42 +0200 Subject: print chain --- ripser.cpp | 69 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/ripser.cpp b/ripser.cpp index 5d6b563..bdf8ff9 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -548,6 +548,34 @@ public: return get_pivot(working_coboundary, modulus); } + + template + void print_chain(Chain& cycle, index_t dim) { + diameter_entry_t e; + + std::cout << "{"; + while (get_index(e = get_pivot(cycle, modulus)) != -1) { + vertices.resize(dim + 1); + get_simplex_vertices(get_index(e), dim, n, + vertices.rbegin()); + + std::cout << "["; + auto it = vertices.begin(); + if (it != vertices.end()) { + std::cout << *it++; + while (it != vertices.end()) std::cout << "," << *it++; + } + std::cout << "]"; +#ifdef USE_COEFFICIENTS + std::cout << ":" << normalize(get_coefficient(e), modulus); +#endif + cycle.pop(); + if (get_index(e = get_pivot(cycle, modulus)) != -1) + std::cout << ", "; + } + std::cout << "}" << std::endl; + + } void compute_pairs(std::vector& columns_to_reduce, hash_map& pivot_column_index, index_t dim) { @@ -651,24 +679,9 @@ public: #ifdef INDICATE_PROGRESS std::cout << "\033[K"; #endif - // std::cout << " [" << diameter << "," << death << ")" << - // std::endl << std::flush; - std::cout << " [" << diameter << "," << death << "): {"; - auto cocycle = working_reduction_column; - diameter_entry_t e; - while (get_index(e = get_pivot(cocycle, modulus)) != -1) { - vertices.resize(dim + 1); - get_simplex_vertices(get_index(e), dim, n, vertices.rbegin()); - std::cout << vertices; -#ifdef USE_COEFFICIENTS - std::cout << ":" << normalize(get_coefficient(e), modulus); - ; -#endif - cocycle.pop(); - if (get_index(e = get_pivot(cocycle, modulus)) != -1) - std::cout << ", "; - } - std::cout << "}" << std::endl; +// std::cout << " [" << diameter << "," << death << ")" << std::endl << std::flush; + std::cout << " [" << diameter << "," << death << "): "; + print_chain(working_reduction_column, dim); } #endif pivot_column_index.insert( @@ -711,23 +724,9 @@ public: #ifdef INDICATE_PROGRESS std::cout << "\033[K"; #endif - // std::cout << " [" << diameter << ", )" << std::endl << - //std::flush; - std::cout << " [" << diameter << ", ): {"; - auto cocycle = working_reduction_column; - diameter_entry_t e; - while (get_index(e = get_pivot(cocycle, modulus)) != -1) { - vertices.resize(dim + 1); - get_simplex_vertices(get_index(e), dim, n, vertices.rbegin()); - std::cout << vertices; -#ifdef USE_COEFFICIENTS - std::cout << ":" << normalize(get_coefficient(e), modulus); - ; -#endif - cocycle.pop(); - if (get_index(e = get_pivot(cocycle, modulus)) != -1) std::cout << ", "; - } - std::cout << "}" << std::endl << std::flush; +// std::cout << " [" << diameter << ", )" << std::endl << std::flush; + std::cout << " [" << diameter << ", ): "; + print_chain(working_reduction_column, dim); #endif break; -- cgit v1.2.3