From c95e71eef54cd36ba206e497d564b96682b2e926 Mon Sep 17 00:00:00 2001 From: "ulrich.bauer@gmail.com" Date: Tue, 3 Jun 2014 13:31:14 +0000 Subject: finalize git-svn-id: https://phat.googlecode.com/svn/trunk@182 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d --- include/phat/algorithms/chunk_reduction.h | 2 ++ include/phat/algorithms/row_reduction.h | 1 + include/phat/algorithms/spectral_sequence_reduction.h | 1 + include/phat/algorithms/standard_reduction.h | 1 + include/phat/algorithms/twist_reduction.h | 1 + include/phat/boundary_matrix.h | 5 ++++- include/phat/representations/abstract_pivot_column.h | 2 ++ include/phat/representations/vector_heap.h | 6 ++++++ include/phat/representations/vector_list.h | 4 ++++ include/phat/representations/vector_set.h | 5 +++++ include/phat/representations/vector_vector.h | 6 ++++++ 11 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/phat/algorithms/chunk_reduction.h b/include/phat/algorithms/chunk_reduction.h index 32a0fe0..1797023 100644 --- a/include/phat/algorithms/chunk_reduction.h +++ b/include/phat/algorithms/chunk_reduction.h @@ -101,6 +101,7 @@ namespace phat { lowest_one_lookup[ lowest_one ] = cur_col; boundary_matrix.clear( lowest_one ); } + boundary_matrix.finalize( cur_col ); } } } @@ -130,6 +131,7 @@ namespace phat { column_type[ cur_col ] = LOCAL_NEGATIVE; column_type[ lowest_one ] = LOCAL_POSITIVE; boundary_matrix.clear( lowest_one ); + boundary_matrix.finalize( cur_col ); } } } diff --git a/include/phat/algorithms/row_reduction.h b/include/phat/algorithms/row_reduction.h index 62528e1..cdd1a8f 100644 --- a/include/phat/algorithms/row_reduction.h +++ b/include/phat/algorithms/row_reduction.h @@ -36,6 +36,7 @@ namespace phat { if( !lowest_one_lookup[ cur_col ].empty() ) { boundary_matrix.clear( cur_col ); + boundary_matrix.finalize( cur_col ); std::vector< index >& cols_with_cur_lowest = lowest_one_lookup[ cur_col ]; index source = *min_element( cols_with_cur_lowest.begin(), cols_with_cur_lowest.end() ); for( index idx = 0; idx < (index)cols_with_cur_lowest.size(); idx++ ) { diff --git a/include/phat/algorithms/spectral_sequence_reduction.h b/include/phat/algorithms/spectral_sequence_reduction.h index b0d4ec1..bf442e6 100644 --- a/include/phat/algorithms/spectral_sequence_reduction.h +++ b/include/phat/algorithms/spectral_sequence_reduction.h @@ -65,6 +65,7 @@ namespace phat { if( lowest_one >= row_begin && lowest_one < row_end ) { lowest_one_lookup[ lowest_one ] = cur_col; boundary_matrix.clear( lowest_one ); + boundary_matrix.finalize( cur_col ); } else { unreduced_cols_next_pass[ cur_stripe ].push_back( cur_col ); } diff --git a/include/phat/algorithms/standard_reduction.h b/include/phat/algorithms/standard_reduction.h index 9b3a286..d8762fa 100644 --- a/include/phat/algorithms/standard_reduction.h +++ b/include/phat/algorithms/standard_reduction.h @@ -39,6 +39,7 @@ namespace phat { if( lowest_one != -1 ) { lowest_one_lookup[ lowest_one ] = cur_col; } + boundary_matrix.finalize( cur_col ); } } }; diff --git a/include/phat/algorithms/twist_reduction.h b/include/phat/algorithms/twist_reduction.h index b9aae08..2357df0 100644 --- a/include/phat/algorithms/twist_reduction.h +++ b/include/phat/algorithms/twist_reduction.h @@ -42,6 +42,7 @@ namespace phat { lowest_one_lookup[ lowest_one ] = cur_col; boundary_matrix.clear( lowest_one ); } + boundary_matrix.finalize( cur_col ); } } } diff --git a/include/phat/boundary_matrix.h b/include/phat/boundary_matrix.h index bb5b33a..10c66cc 100644 --- a/include/phat/boundary_matrix.h +++ b/include/phat/boundary_matrix.h @@ -64,7 +64,10 @@ namespace phat { // clears given column void clear( index idx ) { rep._clear( idx ); } - + + // finalizes given column + void finalize( index idx ) { rep._finalize( idx ); } + // syncronizes all internal data structures -- has to be called before and after any multithreaded access! void sync() { rep._sync(); } diff --git a/include/phat/representations/abstract_pivot_column.h b/include/phat/representations/abstract_pivot_column.h index fbee368..e16d7a5 100644 --- a/include/phat/representations/abstract_pivot_column.h +++ b/include/phat/representations/abstract_pivot_column.h @@ -94,6 +94,8 @@ namespace phat { void _set_col( index idx, const column& col ) { is_pivot_col( idx ) ? get_pivot_col().set_col( col ) : Base::_set_col( idx, col ); } void _remove_max( index idx ) { is_pivot_col( idx ) ? get_pivot_col().remove_max() : Base::_remove_max( idx ); } + + void finalize( index idx ) { Base::_finalize( idx ); } }; } diff --git a/include/phat/representations/vector_heap.h b/include/phat/representations/vector_heap.h index 78501f0..db0420f 100644 --- a/include/phat/representations/vector_heap.h +++ b/include/phat/representations/vector_heap.h @@ -160,5 +160,11 @@ namespace phat { if( 2 * inserts_since_last_prune[ target ] > ( index )matrix[ target ].size() ) _prune( target ); } + + // finalizes given column + void _finalize( index idx ) { + _prune( idx ); + } + }; } diff --git a/include/phat/representations/vector_list.h b/include/phat/representations/vector_list.h index fdd5818..ca0b5b8 100644 --- a/include/phat/representations/vector_list.h +++ b/include/phat/representations/vector_list.h @@ -93,5 +93,9 @@ namespace phat { source_col.begin(), source_col.end(), std::back_inserter( target_col ) ); } + + // finalizes given column + void _finalize( index idx ) { + } }; } diff --git a/include/phat/representations/vector_set.h b/include/phat/representations/vector_set.h index ea6df09..6878a27 100644 --- a/include/phat/representations/vector_set.h +++ b/include/phat/representations/vector_set.h @@ -90,5 +90,10 @@ namespace phat { col.erase( result.first ); } } + + // finalizes given column + void _finalize( index idx ) { + } + }; } diff --git a/include/phat/representations/vector_vector.h b/include/phat/representations/vector_vector.h index 15dbfb1..f111d6b 100644 --- a/include/phat/representations/vector_vector.h +++ b/include/phat/representations/vector_vector.h @@ -97,5 +97,11 @@ namespace phat { target_col.swap(temp_col); } + + // finalizes given column + void _finalize( index idx ) { + column& col = matrix[ idx ]; + column(col.begin(), col.end()).swap(col); + } }; } -- cgit v1.2.3