diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-10-12 14:06:01 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-10-12 14:06:01 +0000 |
commit | 0b903a02242c935e7621006818e9f9dc442f0e79 (patch) | |
tree | 1a4ad46cbfcee4fec88c6bd5b7105bc5d8eadbd3 /src/Toplex_map/benchmark/chrono.cpp | |
parent | 05b163f41a8b2ee0b10b862b0c7497d3f6e9b4b3 (diff) |
Add some unitary tests
num_maximum_simplices results are a bit strange
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3950 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 86c7a4607f9d774c89c79dcc6d95f1ce2f5951d5
Diffstat (limited to 'src/Toplex_map/benchmark/chrono.cpp')
-rw-r--r-- | src/Toplex_map/benchmark/chrono.cpp | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/src/Toplex_map/benchmark/chrono.cpp b/src/Toplex_map/benchmark/chrono.cpp index a745f099..db87e217 100644 --- a/src/Toplex_map/benchmark/chrono.cpp +++ b/src/Toplex_map/benchmark/chrono.cpp @@ -15,48 +15,40 @@ typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; class ST_wrapper { public: - void insert_simplex(const Simplex& tau); - bool membership(const Simplex& tau); - Vertex contraction(const Vertex x, const Vertex y); - std::size_t num_simplices(); - -private: - Simplex_tree<> simplexTree; - void erase_max(const Simplex& sigma); -}; - -void ST_wrapper::insert_simplex(const Simplex& tau){ + void insert_simplex(const Simplex& tau) { simplexTree.insert_simplex_and_subfaces(tau); -} + } -bool ST_wrapper::membership(const Simplex& tau) { + bool membership(const Simplex& tau) { return simplexTree.find(tau) != simplexTree.null_simplex(); -} - -void ST_wrapper::erase_max(const Simplex& sigma){ - if(membership(sigma)) - simplexTree.remove_maximal_simplex(simplexTree.find(sigma)); -} + } -Vertex ST_wrapper::contraction(const Vertex x, const Vertex y){ + Vertex contraction(const Vertex x, const Vertex y) { Simplex sx; sx.insert(x); auto hx = simplexTree.find(sx); if(hx != simplexTree.null_simplex()) - for(auto h : simplexTree.cofaces_simplex_range(hx,0)){ - auto sr = simplexTree.simplex_vertex_range(h); - Simplex sigma(sr.begin(),sr.end()); - erase_max(sigma); - sigma.erase(x); - sigma.insert(y); - insert_simplex(sigma); - } + for(auto h : simplexTree.cofaces_simplex_range(hx,0)){ + auto sr = simplexTree.simplex_vertex_range(h); + Simplex sigma(sr.begin(),sr.end()); + erase_max(sigma); + sigma.erase(x); + sigma.insert(y); + insert_simplex(sigma); + } return y; -} + } -std::size_t ST_wrapper::num_simplices(){ + std::size_t num_maximal_simplices() { return simplexTree.num_simplices(); -} + } +private: + Simplex_tree<> simplexTree; + void erase_max(const Simplex& sigma) { + if(membership(sigma)) + simplexTree.remove_maximal_simplex(simplexTree.find(sigma)); + } +}; int n = 300; @@ -120,7 +112,7 @@ void chrono(int n, int d){ end = std::chrono::system_clock::now(); auto c2 = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); - std::cout << c1 << "\t \t" << c2 << "\t \t" << c3 << "\t \t" << K.num_simplices() << std::endl; + std::cout << c1 << "\t \t" << c2 << "\t \t" << c3 << "\t \t" << K.num_maximal_simplices() << std::endl; } int main(){ |