summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <ulrich.bauer@tum.de>2015-10-20 10:11:32 +0200
committerUlrich Bauer <ulrich.bauer@tum.de>2015-10-20 10:11:32 +0200
commitd40eaeeeee4f98a9d4841fefa19be6e5606d8b3b (patch)
tree932ccc2df3df7628d2026e60936ca5a960918138
parent082f4cc0f915bf64c17904e5bb99033ac27c2d7a (diff)
show reduction cochain and fill-in
-rw-r--r--ripser.cpp44
1 files changed, 36 insertions, 8 deletions
diff --git a/ripser.cpp b/ripser.cpp
index 4e1ee62..eef3f08 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -254,7 +254,7 @@ public:
};
template <typename Heap>
-int get_pivot(Heap& column)
+int pop_pivot(Heap& column)
{
if( column.empty() )
return -1;
@@ -270,13 +270,32 @@ int get_pivot(Heap& column)
column.pop();
}
}
- if( max_element != -1 )
- column.push( max_element );
-
return max_element;
}
}
+template <typename Heap>
+int get_pivot(Heap& column)
+{
+ int max_element = pop_pivot(column);
+ if( max_element != -1 )
+ column.push( max_element );
+ return max_element;
+}
+
+template <typename Heap>
+std::vector<int> move_to_column_vector(Heap& column)
+{
+ std::vector<int> temp_col;
+ int pivot = pop_pivot( column );
+ while( pivot != -1 ) {
+ temp_col.push_back( pivot );
+ pivot = pop_pivot( column );
+ }
+ return temp_col;
+}
+
+
void print_help_and_exit()
{
std::cerr << "Usage: " << "ripser " << "[options] input_filename output_filename" << std::endl;
@@ -504,8 +523,6 @@ int main( int argc, char** argv ) {
rips_filtration_comparator<decltype(dist)> comp(dist, dim + 1, binomial_coeff);
std::unordered_map<int, int> pivot_column_index;
-
- //std::vector<int> reduction_column;
std::cout << "reduce columns in dim " << dim << std::endl;
@@ -527,7 +544,7 @@ int main( int argc, char** argv ) {
// }
for (int index: columns_to_reduce) {
- //reduction_column.clear();
+ std::priority_queue<int, std::vector<int>, rips_filtration_comparator<decltype(dist)> > reduction_column(comp);
std::priority_queue<int, std::vector<int>, rips_filtration_comparator<decltype(dist)> > working_coboundary(comp);
@@ -537,6 +554,8 @@ int main( int argc, char** argv ) {
int pivot, column = index;
do {
+
+ reduction_column.push( column );
coboundary.clear();
get_simplex_coboundary( column, dim, n, binomial_coeff, std::back_inserter(coboundary) );
@@ -599,7 +618,16 @@ int main( int argc, char** argv ) {
*/
} while ( pivot != -1 );
-// std::cout << std::endl;
+ std::vector<int> cochain = move_to_column_vector( reduction_column );
+ std::cout << "reduction cochain: " << cochain << std::endl;
+
+// if ( pivot != -1 ) {
+// std::vector<int> coboundary = move_to_column_vector( working_coboundary );
+// std::cout << "reduced coboundary: " << coboundary << std::endl;
+// }
+
+ std::cout << "fill-in: " << cochain.size()-1 << std::endl;
+
}