From e9800d103fcdd19f0417e89781761f7f85d8ec9b Mon Sep 17 00:00:00 2001 From: Michael Kerber Date: Fri, 18 May 2018 10:52:51 +0200 Subject: Column types are separated, and the matrix representation is more general in its container type --- src/benchmark.cpp | 10 +----- src/convert.cpp | 2 +- src/phat.cpp | 11 ++---- src/self_test.cpp | 92 ++++++++++++++++++++++++-------------------------- src/simple_example.cpp | 2 +- 5 files changed, 49 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/benchmark.cpp b/src/benchmark.cpp index b552d33..7631d57 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -17,15 +17,7 @@ along with PHAT. If not, see . */ #include - -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include diff --git a/src/convert.cpp b/src/convert.cpp index 5b4d7a0..d13757f 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -17,7 +17,7 @@ along with PHAT. If not, see . */ -#include +#include #include #include diff --git a/src/phat.cpp b/src/phat.cpp index 3770cf3..46f780c 100644 --- a/src/phat.cpp +++ b/src/phat.cpp @@ -17,15 +17,8 @@ along with PHAT. If not, see . */ #include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include diff --git a/src/self_test.cpp b/src/self_test.cpp index 249b9b2..aef4043 100644 --- a/src/self_test.cpp +++ b/src/self_test.cpp @@ -18,14 +18,7 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include @@ -52,63 +45,67 @@ int main( int argc, char** argv ) std::cerr << "Error: test data " << test_data << " not found!" << std::endl; return EXIT_FAILURE; } - bool error = false; std::cout << "Comparing representations using Chunk algorithm ..." << std::endl; + + { - std::cout << "Running Chunk - Sparse ..." << std::endl; + std::cout << "Running Chunk - Vec_vec ..." << std::endl; + phat::persistence_pairs vec_vec_pairs; + phat::boundary_matrix< Vec_vec > vec_vec_boundary_matrix(boundary_matrix); + phat::compute_persistence_pairs< phat::chunk_reduction >( vec_vec_pairs, vec_vec_boundary_matrix ); + + std::cout << "Running Chunk - Vec_heap ..." << std::endl; + phat::persistence_pairs vec_heap_pairs; + phat::boundary_matrix< Vec_heap > vec_heap_boundary_matrix(boundary_matrix); + phat::compute_persistence_pairs< phat::chunk_reduction >( vec_heap_pairs, vec_heap_boundary_matrix ); + + std::cout << "Running Chunk - Vec_set ..." << std::endl; + phat::persistence_pairs vec_set_pairs; + phat::boundary_matrix< Vec_set > vec_set_boundary_matrix(boundary_matrix); + phat::compute_persistence_pairs< phat::chunk_reduction >( vec_set_pairs, vec_set_boundary_matrix ); + + std::cout << "Running Chunk - Vec_list ..." << std::endl; + phat::persistence_pairs vec_list_pairs; + phat::boundary_matrix< Vec_list > vec_list_boundary_matrix(boundary_matrix); + phat::compute_persistence_pairs< phat::chunk_reduction >( vec_list_pairs, vec_list_boundary_matrix ); + + + + std::cout << "Running Chunk - Sparse ..." << std::endl; phat::persistence_pairs sparse_pairs; - phat::boundary_matrix< Sparse > sparse_boundary_matrix = boundary_matrix; + phat::boundary_matrix< Sparse > sparse_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::chunk_reduction >( sparse_pairs, sparse_boundary_matrix ); std::cout << "Running Chunk - Heap ..." << std::endl; phat::persistence_pairs heap_pairs; - phat::boundary_matrix< Heap > heap_boundary_matrix = boundary_matrix; + phat::boundary_matrix< Heap > heap_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::chunk_reduction >( heap_pairs, heap_boundary_matrix ); - std::cout << "Running Chunk - Full ..." << std::endl; + std::cout << "Running Chunk - Full ..." << std::endl; phat::persistence_pairs full_pairs; phat::boundary_matrix< Full > full_boundary_matrix = boundary_matrix; phat::compute_persistence_pairs< phat::chunk_reduction >( full_pairs, full_boundary_matrix ); - + std::cout << "Running Chunk - BitTree ..." << std::endl; phat::persistence_pairs bit_tree_pairs; - phat::boundary_matrix< BitTree > bit_tree_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > bit_tree_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::chunk_reduction >( bit_tree_pairs, bit_tree_boundary_matrix ); - std::cout << "Running Chunk - Vec_vec ..." << std::endl; - phat::persistence_pairs vec_vec_pairs; - phat::boundary_matrix< Vec_vec > vec_vec_boundary_matrix = boundary_matrix; - phat::compute_persistence_pairs< phat::chunk_reduction >( vec_vec_pairs, vec_vec_boundary_matrix ); - - std::cout << "Running Chunk - Vec_heap ..." << std::endl; - phat::persistence_pairs vec_heap_pairs; - phat::boundary_matrix< Vec_heap > vec_heap_boundary_matrix = boundary_matrix; - phat::compute_persistence_pairs< phat::chunk_reduction >( vec_heap_pairs, vec_heap_boundary_matrix ); - - std::cout << "Running Chunk - Vec_set ..." << std::endl; - phat::persistence_pairs vec_set_pairs; - phat::boundary_matrix< Vec_set > vec_set_boundary_matrix = boundary_matrix; - phat::compute_persistence_pairs< phat::chunk_reduction >( vec_set_pairs, vec_set_boundary_matrix ); - - std::cout << "Running Chunk - Vec_list ..." << std::endl; - phat::persistence_pairs vec_list_pairs; - phat::boundary_matrix< Vec_list > vec_list_boundary_matrix = boundary_matrix; - phat::compute_persistence_pairs< phat::chunk_reduction >( vec_list_pairs, vec_list_boundary_matrix ); if( sparse_pairs != heap_pairs ) { std::cerr << "Error: sparse and heap differ!" << std::endl; error = true; } - if( heap_pairs != full_pairs ) { + if( heap_pairs != full_pairs ) { std::cerr << "Error: heap and full differ!" << std::endl; error = true; } - if( full_pairs != vec_vec_pairs ) { + if( full_pairs != vec_vec_pairs ) { std::cerr << "Error: full and vec_vec differ!" << std::endl; error = true; } - if( vec_vec_pairs != vec_heap_pairs ) { + if( vec_vec_pairs != vec_heap_pairs ) { std::cerr << "Error: vec_vec and vec_heap differ!" << std::endl; error = true; } @@ -137,27 +134,27 @@ int main( int argc, char** argv ) { std::cout << "Running Twist - BitTree ..." << std::endl; phat::persistence_pairs twist_pairs; - phat::boundary_matrix< BitTree > twist_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > twist_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::twist_reduction >( twist_pairs, twist_boundary_matrix ); std::cout << "Running Standard - BitTree ..." << std::endl; phat::persistence_pairs std_pairs; - phat::boundary_matrix< BitTree > std_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > std_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::standard_reduction >( std_pairs, std_boundary_matrix ); std::cout << "Running Chunk - BitTree ..." << std::endl; phat::persistence_pairs chunk_pairs; - phat::boundary_matrix< BitTree > chunk_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > chunk_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::chunk_reduction >( chunk_pairs, chunk_boundary_matrix ); std::cout << "Running Row - BitTree ..." << std::endl; phat::persistence_pairs row_pairs; - phat::boundary_matrix< BitTree > row_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > row_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::row_reduction >( row_pairs, row_boundary_matrix ); std::cout << "Running Spectral sequence - BitTree ..." << std::endl; phat::persistence_pairs ss_pairs; - phat::boundary_matrix< BitTree > ss_boundary_matrix = boundary_matrix; + phat::boundary_matrix< BitTree > ss_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::spectral_sequence_reduction >( ss_pairs, ss_boundary_matrix ); if( twist_pairs != std_pairs ) { @@ -188,11 +185,11 @@ int main( int argc, char** argv ) std::cout << "Comparing primal and dual approach using Chunk - Full ..." << std::endl; { phat::persistence_pairs primal_pairs; - phat::boundary_matrix< Full > primal_boundary_matrix = boundary_matrix; + phat::boundary_matrix< Full > primal_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs< phat::chunk_reduction >( primal_pairs, primal_boundary_matrix ); phat::persistence_pairs dual_pairs; - phat::boundary_matrix< Full > dual_boundary_matrix = boundary_matrix; + phat::boundary_matrix< Full > dual_boundary_matrix(boundary_matrix); phat::compute_persistence_pairs_dualized< phat::chunk_reduction >( dual_pairs, dual_boundary_matrix ); if( primal_pairs != dual_pairs ) { @@ -208,11 +205,10 @@ int main( int argc, char** argv ) { std::vector< std::vector< int > > vector_vector_matrix; std::vector< int > vector_dims; - boundary_matrix.save_vector_vector( vector_vector_matrix, vector_dims ); - phat::boundary_matrix< BitTree > vector_vector_boundary_matrix; + boundary_matrix.save_vector_vector( vector_vector_matrix, vector_dims ); + phat::boundary_matrix< BitTree > vector_vector_boundary_matrix; vector_vector_boundary_matrix.load_vector_vector( vector_vector_matrix, vector_dims ); - - if( vector_vector_boundary_matrix != boundary_matrix ) { + if( vector_vector_boundary_matrix != boundary_matrix ) { std::cerr << "Error: [load|save]_vector_vector bug" << std::endl; error = true; } diff --git a/src/simple_example.cpp b/src/simple_example.cpp index ba8aafe..e733630 100644 --- a/src/simple_example.cpp +++ b/src/simple_example.cpp @@ -22,7 +22,7 @@ #include // main data structure (choice affects performance) -#include +#include // algorithm (choice affects performance) #include -- cgit v1.2.3