summaryrefslogtreecommitdiff
path: root/src/Rips_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-05 08:45:01 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-05 08:45:01 +0000
commit6d759732282c4b79a4c93a0dbceb4667af2c8940 (patch)
treeff4eb4341e236c450546a3524c70bf2efd0c5117 /src/Rips_complex
parentbaa98e772b9d97d8b7c22fc8292f54b5047f0569 (diff)
clang format files
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3216 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 09a40b92cc8e0cc1a08f962de14daed975338d1c
Diffstat (limited to 'src/Rips_complex')
-rw-r--r--src/Rips_complex/doc/Intro_rips_complex.h3
-rw-r--r--src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp11
-rw-r--r--src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp83
3 files changed, 45 insertions, 52 deletions
diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h
index 0c1acba7..3f02206b 100644
--- a/src/Rips_complex/doc/Intro_rips_complex.h
+++ b/src/Rips_complex/doc/Intro_rips_complex.h
@@ -167,7 +167,8 @@ namespace rips_complex {
*
* \include Rips_complex/one_skeleton_rips_from_correlation_matrix_for_doc.txt
*
- * All the other constructions discussed for Rips complex for distance matrix can be also performed for Rips complexes construction from correlation matrices.
+ * All the other constructions discussed for Rips complex for distance matrix can be also performed for Rips complexes
+ * construction from correlation matrices.
*
*/
/** @} */ // end defgroup rips_complex
diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp
index d1ccbf31..0da1dc20 100644
--- a/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp
+++ b/src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp
@@ -42,17 +42,16 @@ int main() {
}
//-----------------------------------------------------------------------------
- // Now the correlation matrix is a distance matrix and can be processed further.
+ // Now the correlation matrix is a distance matrix and can be processed further.
//-----------------------------------------------------------------------------
Distance_matrix distances = correlations;
//------------------------------------------------------------------------------
- //Note that this treshold mean that the points in the distance 1, i.e. corelation
- //0 will be connected.
+ // Note that this treshold mean that the points in the distance 1, i.e. corelation
+ // 0 will be connected.
//------------------------------------------------------------------------------
double threshold = 1.0;
-
-
+
Rips_complex rips_complex_from_points(distances, threshold);
Simplex_tree stree;
@@ -63,7 +62,7 @@ int main() {
// above, which is 1 - initial correlation matrix. Only this way, we obtain
// a complex with filtration. If a correlation matrix is used instead, we would
// have a reverse filtration (i.e. filtration of boundary of each simplex S
- // is greater or equal to the filtration of S).
+ // is greater or equal to the filtration of S).
// ----------------------------------------------------------------------------
std::cout << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - "
<< stree.num_vertices() << " vertices." << std::endl;
diff --git a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp
index 676ef793..3fe0edb0 100644
--- a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp
+++ b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp
@@ -39,7 +39,7 @@ using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>;
using Correlation_matrix = std::vector<std::vector<Filtration_value>>;
-using intervals_common = Gudhi::Persistence_interval_common< double , int >;
+using intervals_common = Gudhi::Persistence_interval_common<double, int>;
void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::string& filediag,
Filtration_value& correlation_min, int& dim_max, int& p, Filtration_value& min_persistence);
@@ -69,16 +69,14 @@ int main(int argc, char* argv[]) {
}
Filtration_value threshold;
- //If the correlation_min, being minimal corelation is in the range [0,1],
- //change it to 1-correlation_min
- if ( ( correlation_min>=0 ) && ( correlation_min<=1 ) )
- {
- threshold = 1-correlation_min;
- }
- else
- {
- std::cout << "Wrong value of the treshold corelation (should be between 0 and 1). The program will now terminate.\n";
- return 1;
+ // If the correlation_min, being minimal corelation is in the range [0,1],
+ // change it to 1-correlation_min
+ if ((correlation_min >= 0) && (correlation_min <= 1)) {
+ threshold = 1 - correlation_min;
+ } else {
+ std::cout
+ << "Wrong value of the treshold corelation (should be between 0 and 1). The program will now terminate.\n";
+ return 1;
}
Rips_complex rips_complex_from_file(correlations, threshold);
@@ -97,34 +95,30 @@ int main(int argc, char* argv[]) {
Persistent_cohomology pcoh(simplex_tree);
// initializes the coefficient field for homology
pcoh.init_coefficients(p);
- //compute persistence
+ // compute persistence
pcoh.compute_persistent_cohomology(min_persistence);
-
- //invert the persistence diagram
+ // invert the persistence diagram
auto pairs = pcoh.get_persistent_pairs();
- std::vector< intervals_common > processed_persistence_intervals;
- processed_persistence_intervals.reserve( pairs.size() );
- for (auto pair :pairs )
- {
- double birth = 1-simplex_tree.filtration( get<0>(pair) );
- double death = 1-simplex_tree.filtration( get<1>(pair) );
- unsigned dimension = (unsigned)simplex_tree.dimension( get<0>(pair) );
- int field = get<2>(pair);
- processed_persistence_intervals.push_back(
- intervals_common(birth, death,dimension,field)
- );
+ std::vector<intervals_common> processed_persistence_intervals;
+ processed_persistence_intervals.reserve(pairs.size());
+ for (auto pair : pairs) {
+ double birth = 1 - simplex_tree.filtration(get<0>(pair));
+ double death = 1 - simplex_tree.filtration(get<1>(pair));
+ unsigned dimension = (unsigned)simplex_tree.dimension(get<0>(pair));
+ int field = get<2>(pair);
+ processed_persistence_intervals.push_back(intervals_common(birth, death, dimension, field));
}
- //sort the processed intervals:
- std::sort( processed_persistence_intervals.begin() , processed_persistence_intervals.end() );
+ // sort the processed intervals:
+ std::sort(processed_persistence_intervals.begin(), processed_persistence_intervals.end());
- //and write them to a file
+ // and write them to a file
if (filediag.empty()) {
write_persistence_intervals_to_stream(processed_persistence_intervals);
} else {
std::ofstream out(filediag);
- write_persistence_intervals_to_stream(processed_persistence_intervals,out);
+ write_persistence_intervals_to_stream(processed_persistence_intervals, out);
out.close();
}
return 0;
@@ -134,23 +128,22 @@ void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::
Filtration_value& correlation_min, int& dim_max, int& p, Filtration_value& min_persistence) {
namespace po = boost::program_options;
po::options_description hidden("Hidden options");
- hidden.add_options()
- ("input-file", po::value<std::string>(&csv_matrix_file),
- "Name of file containing a corelation matrix. Can be square or lower triangular matrix. Separator is ';'.");
+ hidden.add_options()(
+ "input-file", po::value<std::string>(&csv_matrix_file),
+ "Name of file containing a corelation matrix. Can be square or lower triangular matrix. Separator is ';'.");
po::options_description visible("Allowed options", 100);
- visible.add_options()
- ("help,h", "produce help message")
- ("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")
- ("min-edge-corelation,c",
- po::value<Filtration_value>(&correlation_min)->default_value(0),
- "Minimal corelation of an edge for the Rips complex construction.")
- ("cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
- "Maximal dimension of the Rips complex we want to compute.")
- ("field-charac,p", po::value<int>(&p)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")
- ("min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals");
+ visible.add_options()("help,h", "produce help message")(
+ "output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
+ "Name of file in which the persistence diagram is written. Default print in std::cout")(
+ "min-edge-corelation,c", po::value<Filtration_value>(&correlation_min)->default_value(0),
+ "Minimal corelation of an edge for the Rips complex construction.")(
+ "cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
+ "Maximal dimension of the Rips complex we want to compute.")(
+ "field-charac,p", po::value<int>(&p)->default_value(11),
+ "Characteristic p of the coefficient field Z/pZ for computing homology.")(
+ "min-persistence,m", po::value<Filtration_value>(&min_persistence),
+ "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length "
+ "intervals");
po::positional_options_description pos;
pos.add("input-file", 1);