summaryrefslogtreecommitdiff
path: root/src/Bitmap_cubical_complex/include/gudhi/phat/representations
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bitmap_cubical_complex/include/gudhi/phat/representations')
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/abstract_pivot_column.h158
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/bit_tree_pivot_column.h169
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/full_pivot_column.h81
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/sparse_pivot_column.h62
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_list.h98
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_set.h100
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_vector.h93
7 files changed, 0 insertions, 761 deletions
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/abstract_pivot_column.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/abstract_pivot_column.h
deleted file mode 100644
index 41104108..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/abstract_pivot_column.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include "../helpers/misc.h"
-#include "../representations/vector_vector.h"
-
-namespace phat {
-
- // Note: We could even make the rep generic in the underlying Const representation
- // But I cannot imagine that anything else than vector<vector<index>> would
- // make sense
- template< typename PivotColumn >
- class abstract_pivot_column : public vector_vector {
- public:
-
- protected:
- typedef vector_vector Base;
- typedef PivotColumn pivot_column;
-
- // For parallization purposes, it could be more than one full column
- mutable thread_local_storage< pivot_column > _pivot_columns;
- mutable thread_local_storage< index > pos_of_pivot_columns;
-
- pivot_column& get_pivot_column() const {
- return _pivot_columns();
- }
-
- bool is_represented_by_pivot_column( index idx ) const {
- return pos_of_pivot_columns() == idx;
- }
-
- void unset_pos_of_pivot_column() {
- index idx = pos_of_pivot_columns();
- if( idx != -1 ) {
- _pivot_columns().get_column_and_clear( this->matrix[ idx ] );
- }
- pos_of_pivot_columns() = -1;
- }
-
- void represent_by_pivot_column( index idx ) {
- pos_of_pivot_columns() = idx;
- get_pivot_column().add_column( matrix[ idx ] );
- }
-
- public:
-
- void _set_num_cols( index nr_of_columns ) {
- #pragma omp parallel for
- for( int tid = 0; tid < omp_get_num_threads(); tid++ ) {
- _pivot_columns[ tid ].init( nr_of_columns );
- pos_of_pivot_columns[ tid ] = -1;
- }
- Base::_set_num_cols( nr_of_columns );
- }
- // replaces(!) content of 'col' with boundary of given index
- void _get_col( index idx, column& col ) const {
- col.clear();
- if( is_represented_by_pivot_column( idx ) ) {
- pivot_column& pivot_column = get_pivot_column();
- pivot_column.get_column_and_clear( col );
- pivot_column.add_column( col );
- } else {
- Base::_get_col( idx, col );
- }
- }
-
- // true iff boundary of given idx is empty
- bool _is_empty( index idx ) const {
- return is_represented_by_pivot_column( idx ) ? get_pivot_column().empty() : Base::_is_empty( idx );
- }
-
- // largest row index of given column idx (new name for lowestOne())
- index _get_max_index( index idx ) const {
- if( is_represented_by_pivot_column( idx ) ) {
- pivot_column& pivot_column = get_pivot_column();
- if( pivot_column.empty() ) {
- return -1;
- } else {
- return pivot_column.max_index();
- }
- } else {
- return Base::_get_max_index( idx );
- }
- }
-
- // adds column 'source' to column 'target'
- void _add_to( index source, index target ) {
- if( !is_represented_by_pivot_column( target ) ) {
- unset_pos_of_pivot_column();
- represent_by_pivot_column( target );
- }
- get_pivot_column().add_column( matrix[source] );
- }
-
- // clears given column
- void _clear( index idx ) {
- if( is_represented_by_pivot_column( idx ) ) {
- column dummy;
- get_pivot_column().get_column_and_clear(dummy);
- } else {
- Base::_clear( idx );
- }
- }
-
- void _set_col( index idx, const column& col ) {
- if( is_represented_by_pivot_column( idx ) ) {
- column dummy;
- pivot_column& pivot_column = get_pivot_column();
- pivot_column.get_column_and_clear( dummy );
- pivot_column.add_column( col );
- } else {
- Base::_set_col( idx, col );
- }
- }
-
- // removes the maximal index of a column
- void _remove_max( index idx ) {
- _toggle( idx, _get_max_index( idx ) );
- }
-
- //// toggles given index pair
- void _toggle( index col_idx, index row_idx ) {
- if( !is_represented_by_pivot_column( col_idx ) ) {
- unset_pos_of_pivot_column();
- represent_by_pivot_column( col_idx );
- }
- get_pivot_column().add_index( row_idx );
- }
-
- // syncronizes all data structures (essential for openmp stuff)
- // has to be called before and after any multithreaded access!
- void _sync() {
- #pragma omp parallel for
- for( int tid = 0; tid < omp_get_num_threads(); tid++ )
- unset_pos_of_pivot_column();
- }
-
- };
-}
-
-
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/bit_tree_pivot_column.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/bit_tree_pivot_column.h
deleted file mode 100644
index 34366d6a..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/bit_tree_pivot_column.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Hubert Wagner
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include "../helpers/misc.h"
-#include "../representations/abstract_pivot_column.h"
-
-namespace phat {
-
- // This is a bitset indexed with a 64-ary tree. Each node in the index
- // has 64 bits; i-th bit says that the i-th subtree is non-empty.
- // Supports practically O(1), inplace, zero-allocation: insert, remove, max_element
- // and clear in O(number of ones in the bitset).
- // 'add_index' is still the real bottleneck in practice.
- class bit_tree_column
- {
- size_t offset; // data[i + offset] = ith block of the data-bitset
- typedef uint64_t block_type;
- std::vector< block_type > data;
-
- // this static is not a problem with OMP, it's initialized just after program starts
- static const size_t debrujin_magic_table[64];
-
- enum { block_size_in_bits = 64 };
- enum { block_shift = 6 };
-
- // Some magic: http://graphics.stanford.edu/~seander/bithacks.html
- // Gets the position of the rightmost bit of 'x'. 0 means the most significant bit.
- // (-x)&x isolates the rightmost bit.
- // The whole method is much faster than calling log2i, and very comparable to using ScanBitForward/Reverse intrinsic,
- // which should be one CPU instruction, but is not portable.
- size_t rightmost_pos(const block_type value) const
- {
- return 64 - 1 - debrujin_magic_table[((value & (-(int64_t)value))*0x07EDD5E59A4E28C2) >> 58];
- }
-
- public:
-
- void init(index num_cols)
- {
- int64_t n = 1; // in case of overflow
- int64_t bottom_blocks_needed = (num_cols+block_size_in_bits-1)/block_size_in_bits;
- int64_t upper_blocks = 1;
-
- // How many blocks/nodes of index needed to index the whole bitset?
- while(n * block_size_in_bits < bottom_blocks_needed)
- {
- n *= block_size_in_bits;
- upper_blocks += n;
- }
-
- offset = upper_blocks;
- data.resize(upper_blocks + bottom_blocks_needed, 0);
- }
-
- index max_index() const
- {
- if (!data[0])
- return -1;
-
- const size_t size = data.size();
- size_t n = 0;
-
- while(true)
- {
- const block_type val = data[n];
- const size_t index = rightmost_pos(val);
- const size_t newn = (n << block_shift) + index + 1;
-
- if (newn >= size)
- {
- const size_t bottom_index = n - offset;
- return (bottom_index << block_shift) + index;
- }
-
- n = newn;
- }
-
- return -1;
- }
-
- bool empty() const
- {
- return data[0] == 0;
- }
-
- void add_index(const size_t entry)
- {
- const block_type ONE = 1;
- const block_type block_modulo_mask = ((ONE << block_shift) - 1);
- size_t index_in_level = entry >> block_shift;
- size_t address = index_in_level + offset;
- size_t index_in_block = entry & block_modulo_mask;
-
- block_type mask = (ONE << (block_size_in_bits - index_in_block - 1));
-
- while(true)
- {
- data[address]^=mask;
-
- // First we check if we reached the root.
- // Also, if anyone else was in this block, we don't need to update the path up.
- if (!address || (data[address] & ~mask))
- return;
-
- index_in_block = index_in_level & block_modulo_mask;
- index_in_level >>= block_shift;
- --address;
- address >>= block_shift;
- mask = (ONE << (block_size_in_bits - index_in_block - 1));
- }
- }
-
- void get_column_and_clear(column &out)
- {
- out.clear();
- while(true)
- {
- index mx = this->max_index();
- if (mx == -1)
- break;
- out.push_back(mx);
- add_index(mx);
- }
-
- std::reverse(out.begin(), out.end());
- }
-
- void add_column(const column &col)
- {
- for (size_t i = 0; i < col.size(); ++i)
- {
- add_index(col[i]);
- }
- }
-
- bool empty() {
- return !data[0];
- }
- };
-
- const size_t bit_tree_column::debrujin_magic_table[64] = {
- 63, 0, 58, 1, 59, 47, 53, 2,
- 60, 39, 48, 27, 54, 33, 42, 3,
- 61, 51, 37, 40, 49, 18, 28, 20,
- 55, 30, 34, 11, 43, 14, 22, 4,
- 62, 57, 46, 52, 38, 26, 32, 41,
- 50, 36, 17, 19, 29, 10, 13, 21,
- 56, 45, 25, 31, 35, 16, 9, 12,
- 44, 24, 15, 8, 23, 7, 6, 5};
-
- typedef abstract_pivot_column<bit_tree_column> bit_tree_pivot_column;
-}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/full_pivot_column.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/full_pivot_column.h
deleted file mode 100644
index 9e0c348d..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/full_pivot_column.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include <phat/helpers/misc.h>
-#include <phat/representations/abstract_pivot_column.h>
-
-namespace phat {
- class full_column {
-
- protected:
- std::priority_queue< index > m_history;
- std::vector< char > m_isInHistory;
- std::vector< char > m_data;
-
- public:
- void init( const index total_size ) {
- m_data.resize( total_size, false );
- m_isInHistory.resize( total_size, false );
- }
-
- void add_column( const column& col ) {
- for( index idx = 0; idx < (index) col.size(); idx++ ) {
- add_index( col[ idx ] );
- }
- }
- void add_index( const index idx ) {
- if( !m_isInHistory[ idx ] ) {
- m_history.push( idx );
- m_isInHistory[ idx ] = true;
- }
-
- m_data[ idx ] = !m_data[ idx ];
- }
-
- index max_index() {
- while( m_history.size() > 0 ) {
- index topIndex = m_history.top();
- if( m_data[ topIndex ] ) {
- return topIndex;
- } else {
- m_history.pop();
- m_isInHistory[ topIndex ] = false;
- }
- }
-
- return -1;
- }
-
- void get_column_and_clear( column& col ) {
- col.clear();
- while( !empty() ) {
- col.push_back( max_index() );
- add_index( max_index() );
- }
- std::reverse( col.begin(), col.end() );
- }
-
- bool empty() {
- return (max_index() == -1);
- }
- };
-
- typedef abstract_pivot_column< full_column > full_pivot_column;
-}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/sparse_pivot_column.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/sparse_pivot_column.h
deleted file mode 100644
index c851a2b5..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/sparse_pivot_column.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include <phat/helpers/misc.h>
-#include <phat/representations/abstract_pivot_column.h>
-
-namespace phat {
- class sparse_column {
-
- protected:
- std::set< index > m_data;
-
- public:
- void init( const index total_size ) {
- m_data.clear();
- }
-
- void add_column( const column& col ) {
- for( index idx = 0; idx < (index) col.size(); idx++ )
- add_index( col[ idx ] );
- }
-
- void add_index( const index idx ) {
- std::pair< std::set< index >::iterator, bool > result = m_data.insert( idx );
- if( result.second == false )
- m_data.erase( result.first );
- }
-
- index max_index() {
- return m_data.empty() ? -1 : *m_data.rbegin();
- }
-
- void get_column_and_clear( column& col ) {
- col.clear();
- col.assign( m_data.begin(), m_data.end() );
- m_data.clear();
- }
-
- bool empty() {
- return m_data.empty();
- }
- };
-
- typedef abstract_pivot_column< sparse_column > sparse_pivot_column;
-}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_list.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_list.h
deleted file mode 100644
index 38e3090c..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_list.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include <phat/helpers/misc.h>
-
-namespace phat {
- class vector_list {
-
- protected:
- typedef std::list< index > internal_column;
- std::vector< dimension > dims;
- std::vector< internal_column > matrix;
-
- public:
- // overall number of cells in boundary_matrix
- index _get_num_cols() const {
- return (index)matrix.size();
- }
- void _set_num_cols( index nr_of_columns ) {
- dims.resize( nr_of_columns );
- matrix.resize( nr_of_columns );
- }
-
- // dimension of given index
- dimension _get_dim( index idx ) const {
- return dims[ idx ];
- }
- void _set_dim( index idx, dimension dim ) {
- dims[ idx ] = dim;
- }
-
- // replaces(!) content of 'col' with boundary of given index
- void _get_col( index idx, column& col ) const {
- col.clear();
- col.reserve( matrix[idx].size() );
- std::copy (matrix[idx].begin(), matrix[idx].end(), std::back_inserter(col) );
- }
-
- void _set_col( index idx, const column& col ) {
- matrix[ idx ].clear();
- matrix[ idx ].resize( col.size() );
- std::copy (col.begin(), col.end(), matrix[ idx ].begin() );
- }
-
- // true iff boundary of given idx is empty
- bool _is_empty( index idx ) const {
- return matrix[ idx ].empty();
- }
-
- // largest row index of given column idx (new name for lowestOne())
- index _get_max_index( index idx ) const {
- return matrix[ idx ].empty() ? -1 : *matrix[ idx ].rbegin();
- }
-
- // removes the maximal index of a column
- void _remove_max( index idx ) {
- internal_column::iterator it = matrix[ idx ].end();
- it--;
- matrix[ idx ].erase( it );
- }
-
- // clears given column
- void _clear( index idx ) {
- matrix[ idx ].clear();
- }
-
- // syncronizes all data structures (essential for openmp stuff)
- void _sync() {}
-
- // adds column 'source' to column 'target'
- void _add_to( index source, index target ) {
- internal_column& source_col = matrix[ source ];
- internal_column& target_col = matrix[ target ];
- internal_column temp_col;
- target_col.swap( temp_col );
- std::set_symmetric_difference( temp_col.begin(), temp_col.end(),
- source_col.begin(), source_col.end(),
- std::back_inserter( target_col ) );
- }
- };
-}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_set.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_set.h
deleted file mode 100644
index dadf1b34..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_set.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include <phat/helpers/misc.h>
-
-namespace phat {
- class vector_set {
-
- protected:
- typedef std::set< index > internal_column;
- std::vector< dimension > dims;
- std::vector< internal_column > matrix;
-
- public:
- // overall number of cells in boundary_matrix
- index _get_num_cols() const {
- return (index)matrix.size();
- }
- void _set_num_cols( index nr_of_columns ) {
- dims.resize( nr_of_columns );
- matrix.resize( nr_of_columns );
- }
-
- // dimension of given index
- dimension _get_dim( index idx ) const {
- return dims[ idx ];
- }
- void _set_dim( index idx, dimension dim ) {
- dims[ idx ] = dim;
- }
-
- // replaces(!) content of 'col' with boundary of given index
- void _get_col( index idx, column& col ) const {
- col.clear();
- col.reserve( matrix[idx].size() );
- std::copy (matrix[idx].begin(), matrix[idx].end(), std::back_inserter(col) );
- }
- void _set_col( index idx, const column& col ) {
- matrix[ idx ].clear();
- matrix[ idx ].insert( col.begin(), col.end() );
- }
-
- // true iff boundary of given idx is empty
- bool _is_empty( index idx ) const {
- return matrix[ idx ].empty();
- }
-
- // largest row index of given column idx (new name for lowestOne())
- index _get_max_index( index idx ) const {
- return matrix[ idx ].empty() ? -1 : *matrix[ idx ].rbegin();
- }
-
- // removes the maximal index of a column
- void _remove_max( index idx ) {
- internal_column::iterator it = matrix[ idx ].end();
- it--;
- matrix[ idx ].erase( it );
- }
-
- // clears given column
- void _clear( index idx ) {
- matrix[ idx ].clear();
- }
-
- // syncronizes all data structures (essential for openmp stuff)
- void _sync() {}
-
- // adds column 'source' to column 'target'
- void _add_to( index source, index target ) {
- for( internal_column::iterator it = matrix[ source ].begin(); it != matrix[ source ].end(); it++ )
- _toggle( target, *it );
- }
-
- //// toggles given index pair
- void _toggle( index col_idx, index row_idx ) {
- internal_column& col = matrix[ col_idx ];
- std::pair< internal_column::iterator, bool > result = col.insert( row_idx );
- if( !result.second ) {
- col.erase( result.first );
- }
- }
- };
-}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_vector.h b/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_vector.h
deleted file mode 100644
index efe8de4d..00000000
--- a/src/Bitmap_cubical_complex/include/gudhi/phat/representations/vector_vector.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright 2013 IST Austria
- Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
-
- This file is part of PHAT.
-
- PHAT is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PHAT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include "../helpers/misc.h"
-
-namespace phat {
- class vector_vector {
-
- protected:
- std::vector< dimension > dims;
- std::vector< column > matrix;
-
- thread_local_storage< column > temp_column_buffer;
-
- public:
- // overall number of cells in boundary_matrix
- index _get_num_cols() const {
- return (index)matrix.size();
- }
- void _set_num_cols( index nr_of_columns ) {
- dims.resize( nr_of_columns );
- matrix.resize( nr_of_columns );
- }
-
- // dimension of given index
- dimension _get_dim( index idx ) const {
- return dims[ idx ];
- }
- void _set_dim( index idx, dimension dim ) {
- dims[ idx ] = dim;
- }
-
- // replaces(!) content of 'col' with boundary of given index
- void _get_col( index idx, column& col ) const {
- col = matrix[ idx ];
- }
- void _set_col( index idx, const column& col ) {
- matrix[ idx ] = col;
- }
-
- // true iff boundary of given idx is empty
- bool _is_empty( index idx ) const {
- return matrix[ idx ].empty();
- }
-
- // largest row index of given column idx (new name for lowestOne())
- index _get_max_index( index idx ) const {
- return matrix[ idx ].empty() ? -1 : matrix[ idx ].back();
- }
-
- // removes the maximal index of a column
- void _remove_max( index idx ) {
- matrix[ idx ].pop_back();
- }
-
- // clears given column
- void _clear( index idx ) {
- matrix[ idx ].clear();
- }
-
- // syncronizes all data structures (essential for openmp stuff)
- void _sync() {}
-
- // adds column 'source' to column 'target'
- void _add_to( index source, index target ) {
- column& source_col = matrix[ source ];
- column& target_col = matrix[ target ];
- column& temp_col = temp_column_buffer();
- temp_col.clear();
- std::set_symmetric_difference( target_col.begin(), target_col.end(),
- source_col.begin(), source_col.end(),
- std::back_inserter( temp_col ) );
- target_col.swap( temp_col );
- }
- };
-}