From baa98e772b9d97d8b7c22fc8292f54b5047f0569 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Feb 2018 16:49:52 +0000 Subject: Fix readme and doc issue after merge git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3213 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4fd050a6f686044aa6f6dcc290025e321e0dba1b --- src/Rips_complex/utilities/ripscomplex.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/Rips_complex/utilities/ripscomplex.md') diff --git a/src/Rips_complex/utilities/ripscomplex.md b/src/Rips_complex/utilities/ripscomplex.md index 4291fae7..3f064e67 100644 --- a/src/Rips_complex/utilities/ripscomplex.md +++ b/src/Rips_complex/utilities/ripscomplex.md @@ -39,11 +39,32 @@ Same as `rips_persistence` but taking a distance matrix as input. **Usage** -`rips_persistence [options] ` +`rips_distance_matrix_persistence [options] ` where `` is the path to the file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'. +The code do not check if it is dealing with a distance matrix. It is the user responsibility to provide a valid input. +Please refer to data/distance_matrix/lower_triangular_distance_matrix.csv for an example of a file. **Example** `rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` + + +## rips_correlation_matrix_persistence ## + +Same as `rips_distance_matrix_persistence` but taking a correlation matrix as input. + +**Usage** + +`rips_correlation_matrix_persistence [options] ` + +where +`` is the path to the file containing a correlation matrix. Can be square or lower triangular matrix. Separator is ';'. +Note that no check is performed if the matrix given as the input is a correlation matrix. +It is the user responsibility to ensure that this is the case. +Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv for an example of a file. + +**Example** + +`rips_correlation_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` -- cgit v1.2.3 From b77699a3188d6674427cffaa35f26ec57aadec8b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Mar 2018 17:13:25 +0000 Subject: Web site review after Editorial Board Do not need to import gudhi twice in py git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3270 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7d7a4bba27f4cbcad5f8b18cb86587a15e6a8435 --- src/Alpha_complex/utilities/alphacomplex.md | 10 ++++++++++ src/Bitmap_cubical_complex/utilities/cubicalcomplex.md | 10 ++++++++++ src/Bottleneck_distance/utilities/bottleneckdistance.md | 10 ++++++++++ src/Nerve_GIC/utilities/covercomplex.md | 10 ++++++++++ src/Rips_complex/utilities/ripscomplex.md | 10 ++++++++++ src/Witness_complex/utilities/witnesscomplex.md | 10 ++++++++++ src/common/utilities/pointsetgenerator.md | 16 +++++++++++++--- src/cython/example/bottleneck_basic_example.py | 2 -- 8 files changed, 73 insertions(+), 5 deletions(-) (limited to 'src/Rips_complex/utilities/ripscomplex.md') diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md index aace85d3..ede749a9 100644 --- a/src/Alpha_complex/utilities/alphacomplex.md +++ b/src/Alpha_complex/utilities/alphacomplex.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Alpha complex" +meta_title: "Alpha complex" +teaser: "" +permalink: /alphacomplex/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Alpha complex # diff --git a/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md index 6e1b2578..a1bb9007 100644 --- a/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md +++ b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Cubical complex" +meta_title: "Cubical complex" +teaser: "" +permalink: /cubicalcomplex/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Cubical complex# diff --git a/src/Bottleneck_distance/utilities/bottleneckdistance.md b/src/Bottleneck_distance/utilities/bottleneckdistance.md index 526f5822..f2749acc 100644 --- a/src/Bottleneck_distance/utilities/bottleneckdistance.md +++ b/src/Bottleneck_distance/utilities/bottleneckdistance.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Bottleneck distance" +meta_title: "Bottleneck distance" +teaser: "" +permalink: /bottleneckdistance/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Bottleneck distance # diff --git a/src/Nerve_GIC/utilities/covercomplex.md b/src/Nerve_GIC/utilities/covercomplex.md index f33cb2e0..6d16d16f 100644 --- a/src/Nerve_GIC/utilities/covercomplex.md +++ b/src/Nerve_GIC/utilities/covercomplex.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Cover complex" +meta_title: "Cover complex" +teaser: "" +permalink: /covercomplex/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Cover complex # diff --git a/src/Rips_complex/utilities/ripscomplex.md b/src/Rips_complex/utilities/ripscomplex.md index 4291fae7..c1f2210e 100644 --- a/src/Rips_complex/utilities/ripscomplex.md +++ b/src/Rips_complex/utilities/ripscomplex.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Rips complex" +meta_title: "Rips complex" +teaser: "" +permalink: /ripscomplex/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Rips complex # diff --git a/src/Witness_complex/utilities/witnesscomplex.md b/src/Witness_complex/utilities/witnesscomplex.md index 2341759b..3be9bc55 100644 --- a/src/Witness_complex/utilities/witnesscomplex.md +++ b/src/Witness_complex/utilities/witnesscomplex.md @@ -1,3 +1,13 @@ +--- +layout: page +title: "Witness complex" +meta_title: "Witness complex" +teaser: "" +permalink: /witnesscomplex/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} # Witness complex # diff --git a/src/common/utilities/pointsetgenerator.md b/src/common/utilities/pointsetgenerator.md index 284715d4..3b23e668 100644 --- a/src/common/utilities/pointsetgenerator.md +++ b/src/common/utilities/pointsetgenerator.md @@ -1,6 +1,16 @@ - - -# common # +--- +layout: page +title: "OFF point set generator" +meta_title: "OFF point set generator" +teaser: "" +permalink: /pointsetgenerator/ +--- +{::comment} +Leave the lines above as it is required by the web site generator 'Jekyll' +{:/comment} + + +# Miscellaneous # ## off_file_from_shape_generator ## diff --git a/src/cython/example/bottleneck_basic_example.py b/src/cython/example/bottleneck_basic_example.py index 31cecb29..a7fa01c1 100755 --- a/src/cython/example/bottleneck_basic_example.py +++ b/src/cython/example/bottleneck_basic_example.py @@ -28,8 +28,6 @@ __author__ = "Francois Godi, Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -import gudhi - diag1 = [[2.7, 3.7],[9.6, 14.],[34.2, 34.974], [3.,float('Inf')]] diag2 = [[2.8, 4.45],[9.5, 14.1],[3.2,float('Inf')]] -- cgit v1.2.3 From a6b1719067462f93a7ee3b7f8f632b85fe27117d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 3 Apr 2018 08:40:05 +0000 Subject: Add warnings for rips persistence from correlation matrix (points under the diagonal). Use range instead of vector in write_persistence_intervals_to_stream git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3326 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ea0fdc32c91f1927c5a9f2a3864360895ce8128a --- src/Rips_complex/doc/Intro_rips_complex.h | 3 + src/Rips_complex/utilities/ripscomplex.md | 5 + .../include/gudhi/writing_persistence_to_file.h | 212 ++++++++------------- src/cython/doc/rips_complex_user.rst | 5 + ...istence_from_correlation_matrix_file_example.py | 5 + 5 files changed, 93 insertions(+), 137 deletions(-) (limited to 'src/Rips_complex/utilities/ripscomplex.md') diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 3f02206b..496c4218 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -170,6 +170,9 @@ namespace rips_complex { * All the other constructions discussed for Rips complex for distance matrix can be also performed for Rips complexes * construction from correlation matrices. * + * @warning As persistence diagrams points will be under the diagonal, bottleneck distance and persistence graphical + * tool will not work properly, this is a known issue. + * */ /** @} */ // end defgroup rips_complex diff --git a/src/Rips_complex/utilities/ripscomplex.md b/src/Rips_complex/utilities/ripscomplex.md index 3f064e67..857e6293 100644 --- a/src/Rips_complex/utilities/ripscomplex.md +++ b/src/Rips_complex/utilities/ripscomplex.md @@ -68,3 +68,8 @@ Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv **Example** `rips_correlation_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` + +**Warning** + +As persistence diagrams points will be under the diagonal, bottleneck distance and persistence graphical tool will not work +properly, this is a known issue. diff --git a/src/common/include/gudhi/writing_persistence_to_file.h b/src/common/include/gudhi/writing_persistence_to_file.h index 5457cf48..5020b5fb 100644 --- a/src/common/include/gudhi/writing_persistence_to_file.h +++ b/src/common/include/gudhi/writing_persistence_to_file.h @@ -29,150 +29,88 @@ namespace Gudhi { - /** -* This is a class to store persistence intervals. Its main purpose is to +* This is a class to store persistence intervals. Its main purpose is to * exchange data in between different packages and provide unified way -* of writing a collection of persistence intervals to file. +* of writing a collection of persistence intervals to file. **/ -template -class Persistence_interval_common -{ -public: - /** - * Constructor taking as an input birth and death of the pair. - **/ - Persistence_interval_common( Filtration_type birth , Filtration_type death ): - birth_(birth),death_(death),dimension_(std::numeric_limits::max), - arith_element_(std::numeric_limits::max() ){} - - /** - * Constructor taking as an input birth, death and dimension of the pair. - **/ - Persistence_interval_common( Filtration_type birth , Filtration_type death, - unsigned dim ): - birth_(birth),death_(death),dimension_(dim), - arith_element_(std::numeric_limits::max()){} - - /** - * Constructor taking as an input birth, death, dimension of the pair as well - * as the number p such that this interval is present over Z_p field. - **/ - Persistence_interval_common( Filtration_type birth , Filtration_type death, - unsigned dim , Coefficient_field field ): - birth_(birth),death_(death),dimension_(dim), - arith_element_(field){} - - /** - * Operator to compare two persistence pairs. During the comparision all the - * fields: birth, death, dimensiona and arith_element_ are taken into account - * and they all have to be equal for two pairs to be equal. - **/ - inline bool operator == ( const Persistence_interval_common &i2) - { - return ( - (this->birth_ == i2.birth_) && (this->death_ == i2.death_) && - (this->dimension_ == i2.dimension_) && (this->arith_element_ == i2.arith_element_) - ); - } - - /** - * Check if two persistence paris are not equal. - **/ - inline bool operator != ( const Persistence_interval_common &i2) - { - return (!((*this)==i2)); - } - - - /** - * Operator to compare objects of a type Persistence_interval_common. - * One intervals is smaller than the other if it has lower persistence. - * Note that this operator do not take Arith_element into account when doing comparisions. - **/ - inline bool operator < ( const Persistence_interval_common &i2) - { - return fabs( this->death_-this->birth_ ) < fabs( i2.death_-i2.birth_ ); - //if ( this->birth_ < i2.birth_ ) - //{ - // return true; - //} - //else - //{ - // if ( this->birth_ > i2.birth_ ) - // { - // return false; - // } - // else - // { - // //in this case this->birth_ == i2.birth_ - // if ( this->death_ > i2.death_ ) - // { - // return true; - // } - // else - // { - // if ( this->death_ < i2.death_ ) - // { - // return false; - // } - // else - // { - // //in this case this->death_ == i2.death_ - // if ( this->dimension_ < i2.dimension_ ) - // { - // return true; - // } - // else - // { - // //in this case this->dimension >= i2.dimension - // return false; - // } - // } - // } - // } - //} - } - - friend std::ostream& operator<<(std::ostream& out, const Persistence_interval_common& it) - { - if ( it.arith_element_ != std::numeric_limits::max() ) - { - out << it.arith_element_ << " "; - } - if ( it.dimension_ != std::numeric_limits::max() ) - { - out << it.dimension_ << " "; - } - out << it.birth_ << " " << it.death_ << " "; - return out; - } - -private: - Filtration_type birth_; - Filtration_type death_; - unsigned dimension_; - Coefficient_field arith_element_; -};//Persistence_interval_common +template +class Persistence_interval_common { + public: + /** + * Constructor taking as an input birth and death of the pair. + **/ + Persistence_interval_common(Filtration_type birth, Filtration_type death) + : birth_(birth), + death_(death), + dimension_(std::numeric_limits::max), + arith_element_(std::numeric_limits::max()) {} + /** + * Constructor taking as an input birth, death and dimension of the pair. + **/ + Persistence_interval_common(Filtration_type birth, Filtration_type death, unsigned dim) + : birth_(birth), death_(death), dimension_(dim), arith_element_(std::numeric_limits::max()) {} -/** - * This function write a vector to a stream -**/ -template -void write_persistence_intervals_to_stream( -const std::vector< Persistence_interval_common >& intervals, -//TODO: change to ranges when it is clear how to do that. - std::ostream& out = std::cout ) -{ - for ( auto interval : intervals ) - { - out << interval << "\n"; - } -}//write_persistence_intervals_to_stream + /** +* Constructor taking as an input birth, death, dimension of the pair as well +* as the number p such that this interval is present over Z_p field. +**/ + Persistence_interval_common(Filtration_type birth, Filtration_type death, unsigned dim, Coefficient_field field) + : birth_(birth), death_(death), dimension_(dim), arith_element_(field) {} + + /** + * Operator to compare two persistence pairs. During the comparision all the + * fields: birth, death, dimensiona and arith_element_ are taken into account + * and they all have to be equal for two pairs to be equal. + **/ + inline bool operator==(const Persistence_interval_common& i2) { + return ((this->birth_ == i2.birth_) && (this->death_ == i2.death_) && (this->dimension_ == i2.dimension_) && + (this->arith_element_ == i2.arith_element_)); + } + + /** + * Check if two persistence paris are not equal. + **/ + inline bool operator!=(const Persistence_interval_common& i2) { return (!((*this) == i2)); } + /** + * Operator to compare objects of a type Persistence_interval_common. + * One intervals is smaller than the other if it has lower persistence. + * Note that this operator do not take Arith_element into account when doing comparisions. + **/ + inline bool operator<(const Persistence_interval_common& i2) { + return fabs(this->death_ - this->birth_) < fabs(i2.death_ - i2.birth_); + } + friend std::ostream& operator<<(std::ostream& out, const Persistence_interval_common& it) { + if (it.arith_element_ != std::numeric_limits::max()) { + out << it.arith_element_ << " "; + } + if (it.dimension_ != std::numeric_limits::max()) { + out << it.dimension_ << " "; + } + out << it.birth_ << " " << it.death_ << " "; + return out; + } + private: + Filtration_type birth_; + Filtration_type death_; + unsigned dimension_; + Coefficient_field arith_element_; +}; + +/** + * This function write a vector to a stream +**/ +template +void write_persistence_intervals_to_stream(const Persistence_interval_range& intervals, + std::ostream& out = std::cout) { + for (auto interval : intervals) { + out << interval << "\n"; + } +} } -#endif //WRITING_PERSISTENCE_TO_FILE_H +#endif // WRITING_PERSISTENCE_TO_FILE_H diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index b80ff7fe..7738aef0 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -305,3 +305,8 @@ until dimension 1 - one skeleton graph in other words), the output is: [2, 4] -> 0.97 [0, 3] -> 0.99 [1, 3] -> 0.99 + +.. note:: + As persistence diagrams points will be under the diagonal, + bottleneck distance and persistence graphical tool will not work properly, + this is a known issue. diff --git a/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py index ad990fdc..aa82ef71 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py @@ -49,6 +49,11 @@ if not (-1. < args.min_edge_correlation < 1.): print("Wrong value of the treshold corelation (should be between -1 and 1).") sys.exit(1) +print("#####################################################################") +print("Caution: as persistence diagrams points will be under the diagonal,") +print("bottleneck distance and persistence graphical tool will not work") +print("properly, this is a known issue.") + print("#####################################################################") print("RipsComplex creation from correlation matrix read in a csv file") -- cgit v1.2.3