Created
November 20, 2020 14:29
-
-
Save VincentRouvreau/abd4b02f10fc1f33047de2d1019cb25c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. | |
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. | |
* Author(s): Vincent Rouvreau | |
* | |
* Copyright (C) 2020 Inria | |
* | |
* Modification(s): | |
* - YYYY/MM Author: Description of the modification | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <limits> // NaN | |
#include <cmath> | |
#define BOOST_TEST_DYN_LINK | |
#define BOOST_TEST_MODULE "simplex_tree_insert_nan" | |
#include <boost/test/unit_test.hpp> | |
#include <boost/mpl/list.hpp> | |
// ^ | |
// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. | |
#include "gudhi/Simplex_tree.h" | |
using namespace Gudhi; | |
typedef boost::mpl::list<Simplex_tree<>, Simplex_tree<Simplex_tree_options_fast_persistence>> list_of_tested_variants; | |
BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_insert_nan, Simplex_tree, list_of_tested_variants) { | |
Simplex_tree stree; | |
stree.insert_simplex_and_subfaces({0}, 2.); | |
stree.insert_simplex_and_subfaces({2}, 5.); | |
stree.insert_simplex_and_subfaces({1}, -1.); | |
stree.insert_simplex_and_subfaces({0, 2}, 6.); | |
stree.insert_simplex_and_subfaces({0, 1, 2}, std::numeric_limits<double>::quiet_NaN()); | |
stree.initialize_filtration(); | |
std::clog << "stree.filtration(stree.find({0})) = " << stree.filtration(stree.find({0})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({0})) == 2.); | |
std::clog << "stree.filtration(stree.find({1})) = " << stree.filtration(stree.find({1})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({1})) == -1.); | |
std::clog << "stree.filtration(stree.find({2})) = " << stree.filtration(stree.find({2})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({2})) == 5.); | |
std::clog << "stree.filtration(stree.find({0, 2})) = " << stree.filtration(stree.find({0, 2})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({0, 2})) == 6.); | |
std::clog << "stree.filtration(stree.find({1, 2})) = " << stree.filtration(stree.find({1, 2})) << std::endl; | |
BOOST_CHECK(std::isnan(stree.filtration(stree.find({1, 2})))); | |
stree.make_filtration_non_decreasing(); | |
std::clog << "stree.filtration(stree.find({0, 1, 2})) = " << stree.filtration(stree.find({0, 1, 2})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({0, 1, 2})) == 6.); | |
std::clog << "stree.filtration(stree.find({0, 1})) = " << stree.filtration(stree.find({0, 1})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({0, 1})) == 2.); | |
std::clog << "stree.filtration(stree.find({0, 2})) = " << stree.filtration(stree.find({0, 2})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({0, 2})) == 6.); | |
std::clog << "stree.filtration(stree.find({1})) = " << stree.filtration(stree.find({1})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({1})) == -1.); | |
std::clog << "stree.filtration(stree.find({2})) = " << stree.filtration(stree.find({2})) << std::endl; | |
BOOST_CHECK(stree.filtration(stree.find({2})) == 5.); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment