summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-04-03 08:40:05 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-04-03 08:40:05 +0000
commita6b1719067462f93a7ee3b7f8f632b85fe27117d (patch)
treecccaab188a73e4b8a2c434c5150037c7cbf10708 /src
parent82c0652b06949b0b002781688565d7ecf30f04fe (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Rips_complex/doc/Intro_rips_complex.h3
-rw-r--r--src/Rips_complex/utilities/ripscomplex.md5
-rw-r--r--src/common/include/gudhi/writing_persistence_to_file.h212
-rw-r--r--src/cython/doc/rips_complex_user.rst5
-rwxr-xr-xsrc/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py5
5 files changed, 93 insertions, 137 deletions
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 <typename Filtration_type , typename Coefficient_field>
-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<unsigned>::max),
- arith_element_(std::numeric_limits<Coefficient_field>::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<Coefficient_field>::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<Coefficient_field>::max() )
- {
- out << it.arith_element_ << " ";
- }
- if ( it.dimension_ != std::numeric_limits<unsigned>::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 <typename Filtration_type, typename Coefficient_field>
+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<unsigned>::max),
+ arith_element_(std::numeric_limits<Coefficient_field>::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<Coefficient_field>::max()) {}
-/**
- * This function write a vector<Persistence_interval_common> to a stream
-**/
-template <typename Filtration_type , typename Coefficient_field>
-void write_persistence_intervals_to_stream(
-const std::vector< Persistence_interval_common<Filtration_type,Coefficient_field> >& 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<Coefficient_field>::max()) {
+ out << it.arith_element_ << " ";
+ }
+ if (it.dimension_ != std::numeric_limits<unsigned>::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<Persistence_interval_common> to a stream
+**/
+template <typename Persistence_interval_range>
+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
@@ -50,6 +50,11 @@ if not (-1. < args.min_edge_correlation < 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")
message = "RipsComplex with min_edge_correlation=" + repr(args.min_edge_correlation)