summaryrefslogtreecommitdiff
path: root/src/Witness_complex/example
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-28 16:16:08 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-02-28 16:16:08 +0000
commitf2b63bcaa647d1ec839dbe2e5edbe5c4fde1b304 (patch)
tree106ab2bbf7c34a2b0f6cd73cb4221661a05bc9c0 /src/Witness_complex/example
parentba56545de435b62e0528d01fbde342bc4653da13 (diff)
Fix cppcheck
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@2120 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 49a5c2c6e94d9fbf235eecc92fa30e62980c7c70
Diffstat (limited to 'src/Witness_complex/example')
-rw-r--r--src/Witness_complex/example/example_nearest_landmark_table.cpp34
-rw-r--r--src/Witness_complex/example/example_strong_witness_complex_off.cpp28
-rw-r--r--src/Witness_complex/example/example_strong_witness_persistence.cpp54
-rw-r--r--src/Witness_complex/example/example_witness_complex_off.cpp11
-rw-r--r--src/Witness_complex/example/example_witness_complex_persistence.cpp22
-rw-r--r--src/Witness_complex/example/example_witness_complex_sphere.cpp33
-rw-r--r--src/Witness_complex/example/generators.h14
7 files changed, 143 insertions, 53 deletions
diff --git a/src/Witness_complex/example/example_nearest_landmark_table.cpp b/src/Witness_complex/example/example_nearest_landmark_table.cpp
index b3883248..65b675f9 100644
--- a/src/Witness_complex/example/example_nearest_landmark_table.cpp
+++ b/src/Witness_complex/example/example_nearest_landmark_table.cpp
@@ -1,16 +1,31 @@
-#define BOOST_PARAMETER_MAX_ARITY 12
-
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
-#include <sys/types.h>
-#include <sys/stat.h>
+#define BOOST_PARAMETER_MAX_ARITY 12
#include <gudhi/Simplex_tree.h>
#include <gudhi/Witness_complex.h>
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistent_cohomology.h>
-#include <CGAL/Epick_d.h>
-
#include <iostream>
#include <fstream>
#include <ctime>
@@ -24,6 +39,8 @@ int main(int argc, char * const argv[]) {
using Nearest_landmark_table = std::vector<Nearest_landmark_range>;
using Witness_complex = Gudhi::witness_complex::Witness_complex<Nearest_landmark_table>;
using Simplex_tree = Gudhi::Simplex_tree<>;
+ using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
+ using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>;
Simplex_tree simplex_tree;
Nearest_landmark_table nlt;
@@ -45,8 +62,7 @@ int main(int argc, char * const argv[]) {
std::cout << "Number of simplices: " << simplex_tree.num_simplices() << std::endl;
- using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
- Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp > pcoh(simplex_tree);
+ Persistent_cohomology pcoh(simplex_tree);
// initializes the coefficient field for homology
pcoh.init_coefficients(11);
diff --git a/src/Witness_complex/example/example_strong_witness_complex_off.cpp b/src/Witness_complex/example/example_strong_witness_complex_off.cpp
index 6a4925b8..0ee9ee90 100644
--- a/src/Witness_complex/example/example_strong_witness_complex_off.cpp
+++ b/src/Witness_complex/example/example_strong_witness_complex_off.cpp
@@ -1,5 +1,24 @@
-#include <sys/types.h>
-#include <sys/stat.h>
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <gudhi/Simplex_tree.h>
#include <gudhi/Euclidean_strong_witness_complex.h>
@@ -16,9 +35,8 @@
using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
using Point_d = typename K::Point_d;
-typedef typename Gudhi::witness_complex::Euclidean_strong_witness_complex<K> Witness_complex;
-using typeVectorVertex = std::vector< typename Gudhi::Simplex_tree<>::Vertex_handle >;
-using Point_vector = std::vector< Point_d >;
+using Witness_complex = Gudhi::witness_complex::Euclidean_strong_witness_complex<K>;
+using Point_vector = std::vector<Point_d>;
int main(int argc, char * const argv[]) {
if (argc != 5) {
diff --git a/src/Witness_complex/example/example_strong_witness_persistence.cpp b/src/Witness_complex/example/example_strong_witness_persistence.cpp
index d42603aa..5efe69fd 100644
--- a/src/Witness_complex/example/example_strong_witness_persistence.cpp
+++ b/src/Witness_complex/example/example_strong_witness_persistence.cpp
@@ -1,3 +1,25 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <gudhi/Simplex_tree.h>
#include <gudhi/Euclidean_strong_witness_complex.h>
#include <gudhi/Persistent_cohomology.h>
@@ -12,18 +34,17 @@
#include <vector>
#include <limits> // infinity
-using namespace Gudhi;
-using namespace Gudhi::persistent_cohomology;
+using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
+using Point_d = K::Point_d;
-typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
-typedef typename K::Point_d Point_d;
+using Point_vector = std::vector<Point_d>;
+using Strong_witness_complex = Gudhi::witness_complex::Euclidean_strong_witness_complex<K>;
+using SimplexTree = Gudhi::Simplex_tree<>;
-typedef typename std::vector<Point_d> Point_vector;
-typedef typename Gudhi::witness_complex::Euclidean_strong_witness_complex<K> Strong_witness_complex;
-typedef Gudhi::Simplex_tree<> SimplexTree;
+using Filtration_value = SimplexTree::Filtration_value;
-typedef int Vertex_handle;
-typedef double Filtration_value;
+using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
+using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<SimplexTree, Field_Zp>;
void program_options(int argc, char * argv[]
, int & nbL
@@ -61,9 +82,9 @@ int main(int argc, char * argv[]) {
// Compute witness complex
Strong_witness_complex strong_witness_complex(landmarks,
witnesses);
-
+
strong_witness_complex.create_complex(simplex_tree, max_squared_alpha, lim_d);
-
+
std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n";
std::cout << " and has dimension " << simplex_tree.dimension() << " \n";
@@ -71,7 +92,7 @@ int main(int argc, char * argv[]) {
simplex_tree.initialize_filtration();
// Compute the persistence diagram of the complex
- persistent_cohomology::Persistent_cohomology<SimplexTree, Field_Zp > pcoh(simplex_tree);
+ Persistent_cohomology pcoh(simplex_tree);
// initializes the coefficient field for homology
pcoh.init_coefficients(p);
@@ -89,7 +110,6 @@ int main(int argc, char * argv[]) {
return 0;
}
-
void program_options(int argc, char * argv[]
, int & nbL
, std::string & file_name
@@ -98,14 +118,12 @@ void program_options(int argc, char * argv[]
, int & p
, int & dim_max
, Filtration_value & min_persistence) {
-
namespace po = boost::program_options;
-
+
po::options_description hidden("Hidden options");
hidden.add_options()
("input-file", po::value<std::string>(&file_name),
"Name of file containing a point set in off format.");
-
po::options_description visible("Allowed options", 100);
visible.add_options()
@@ -122,7 +140,7 @@ void program_options(int argc, char * argv[]
"Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals")
("cpx-dimension,d", po::value<int>(&dim_max)->default_value(std::numeric_limits<int>::max()),
"Maximal dimension of the strong witness complex we want to compute.");
-
+
po::positional_options_description pos;
pos.add("input-file", 1);
@@ -133,7 +151,7 @@ void program_options(int argc, char * argv[]
po::store(po::command_line_parser(argc, argv).
options(all).positional(pos).run(), vm);
po::notify(vm);
-
+
if (vm.count("help") || !vm.count("input-file")) {
std::cout << std::endl;
std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
diff --git a/src/Witness_complex/example/example_witness_complex_off.cpp b/src/Witness_complex/example/example_witness_complex_off.cpp
index 38c6bedc..b36dac0d 100644
--- a/src/Witness_complex/example/example_witness_complex_off.cpp
+++ b/src/Witness_complex/example/example_witness_complex_off.cpp
@@ -14,11 +14,10 @@
#include <string>
#include <vector>
-typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
-typedef typename K::Point_d Point_d;
-typedef typename Gudhi::witness_complex::Euclidean_witness_complex<K> Witness_complex;
-typedef std::vector< typename Gudhi::Simplex_tree<>::Vertex_handle > typeVectorVertex;
-typedef std::vector< Point_d > Point_vector;
+using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
+using Point_d = K::Point_d;
+using Witness_complex = Gudhi::witness_complex::Euclidean_witness_complex<K>;
+using Point_vector = std::vector< Point_d >;
int main(int argc, char * const argv[]) {
if (argc != 5) {
@@ -41,7 +40,7 @@ int main(int argc, char * const argv[]) {
exit(-1); // ----- >>
}
point_vector = Point_vector(off_reader.get_point_cloud());
-
+
std::cout << "Successfully read " << point_vector.size() << " points.\n";
std::cout << "Ambient dimension is " << point_vector[0].dimension() << ".\n";
diff --git a/src/Witness_complex/example/example_witness_complex_persistence.cpp b/src/Witness_complex/example/example_witness_complex_persistence.cpp
index fbb18cb4..364a114a 100644
--- a/src/Witness_complex/example/example_witness_complex_persistence.cpp
+++ b/src/Witness_complex/example/example_witness_complex_persistence.cpp
@@ -1,3 +1,25 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <gudhi/Simplex_tree.h>
#include <gudhi/Euclidean_witness_complex.h>
#include <gudhi/Persistent_cohomology.h>
diff --git a/src/Witness_complex/example/example_witness_complex_sphere.cpp b/src/Witness_complex/example/example_witness_complex_sphere.cpp
index 1ea9408c..06fe3889 100644
--- a/src/Witness_complex/example/example_witness_complex_sphere.cpp
+++ b/src/Witness_complex/example/example_witness_complex_sphere.cpp
@@ -1,8 +1,26 @@
-#define BOOST_PARAMETER_MAX_ARITY 12
-
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
-#include <sys/types.h>
-#include <sys/stat.h>
+#define BOOST_PARAMETER_MAX_ARITY 12
#include <gudhi/Simplex_tree.h>
#include <gudhi/Euclidean_witness_complex.h>
@@ -32,8 +50,9 @@ void write_data(Data_range & data, std::string filename) {
}
int main(int argc, char * const argv[]) {
- typedef Gudhi::witness_complex::Euclidean_witness_complex<CGAL::Epick_d<CGAL::Dynamic_dimension_tag>> Witness_complex;
-
+ using Kernel = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
+ using Witness_complex = Gudhi::witness_complex::Euclidean_witness_complex<Kernel>;
+
if (argc != 2) {
std::cerr << "Usage: " << argv[0]
<< " number_of_landmarks \n";
@@ -66,8 +85,6 @@ int main(int argc, char * const argv[]) {
double time = static_cast<double>(end - start) / CLOCKS_PER_SEC;
std::cout << "Witness complex for " << number_of_landmarks << " landmarks took "
<< time << " s. \n";
- //assert(1 == 0);
- //std::cout << simplex_tree << "\n";
std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << "\n";
l_time.push_back(std::make_pair(nbP, time));
}
diff --git a/src/Witness_complex/example/generators.h b/src/Witness_complex/example/generators.h
index 731a52b0..7df43db5 100644
--- a/src/Witness_complex/example/generators.h
+++ b/src/Witness_complex/example/generators.h
@@ -32,12 +32,12 @@
#include <vector>
#include <cmath>
-typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
-typedef K::FT FT;
-typedef K::Point_d Point_d;
-typedef std::vector<Point_d> Point_Vector;
-typedef CGAL::Random_points_in_cube_d<Point_d> Random_cube_iterator;
-typedef CGAL::Random_points_in_ball_d<Point_d> Random_point_iterator;
+using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
+using FT = K::FT;
+using Point_d = K::Point_d;
+using Point_Vector = std::vector<Point_d>;
+using Random_cube_iterator = CGAL::Random_points_in_cube_d<Point_d>;
+using Random_point_iterator = CGAL::Random_points_in_ball_d<Point_d>;
/**
* \brief Rock age method of reading off file
@@ -155,7 +155,7 @@ void generate_points_torus(Point_Vector& W, int nbP, int dim) {
for (int i = 0; i < nbP; i++) {
std::vector<FT> point;
for (int j = 0; j < dim; j++) {
- double alpha = rand.uniform_real((double)0, 2*pi);
+ double alpha = rand.uniform_real(static_cast<double>(0), 2*pi);
point.push_back(sin(alpha));
point.push_back(cos(alpha));
}