summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-08 10:00:57 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-08 10:00:57 +0000
commitb5667b282e8cee9e1d2bfcf90bdfbbf2bc0030b2 (patch)
treef110bbdad3eeef964c59c160dcbc0d21d8546758
parent82764fe1fa117f5a3d1cce0eb7dc7dddd7af974f (diff)
random commit.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3233 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9a3ccdd8a000bd3fd79bab61b35e50bd707cfb29
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h2
-rw-r--r--src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp23
-rw-r--r--src/common/include/gudhi/writing_persistence_to_file.h10
3 files changed, 18 insertions, 17 deletions
diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
index 969daba6..770eb55f 100644
--- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
+++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
@@ -383,7 +383,7 @@ class Bitmap_cubical_complex : public T {
std::vector<std::size_t> bdry = this->get_boundary_of_a_cell(sh);
if (globalDbg) {
std::cerr << "std::pair<Simplex_handle, Simplex_handle> endpoints( Simplex_handle sh )\n";
- std::cerr << "bdry.size() : " << bdry.size() << std::endl;
+ std::cerr << "bdry.size() : " << bdry.size() << "\n";
}
// this method returns two first elements from the boundary of sh.
if (bdry.size() < 2)
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 0da1dc20..f66c4b04 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
@@ -31,26 +31,27 @@ int main() {
// ----------------------------------------------------------------------------
// Convert correlation matrix to a distance matrix:
// ----------------------------------------------------------------------------
+ double threshold = 0;
for (size_t i = 0; i != correlations.size(); ++i) {
for (size_t j = 0; j != correlations[i].size(); ++j) {
- correlations[i][j] = 1 - correlations[i][j];
- if (correlations[i][j] < 0) {
- std::cerr << "The input matrix is not a correlation matrix. \n";
- throw "The input matrix is not a correlation matrix. \n";
- }
+ //Here we check if our data comes from corelation matrix.
+ if ( (correlations[i][j]<-1) || (correlations[i][j]>1) )
+ {
+ std::cerr << "The input matrix is not a correlation matrix. The program will now terminate.\n";
+ throw "The input matrix is not a correlation matrix. The program will now terminate.\n";
+ }
+ correlations[i][j] = 1 - correlations[i][j];
}
+ //Here we make sure that we will get the treshold value equal to maximal
+ //distance in the matrix.
+ if ( correlations[i][j] > threshold )threshold = correlations[i][j];
}
//-----------------------------------------------------------------------------
// 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.
- //------------------------------------------------------------------------------
- double threshold = 1.0;
+
Rips_complex rips_complex_from_points(distances, threshold);
diff --git a/src/common/include/gudhi/writing_persistence_to_file.h b/src/common/include/gudhi/writing_persistence_to_file.h
index 53c83533..5767c06e 100644
--- a/src/common/include/gudhi/writing_persistence_to_file.h
+++ b/src/common/include/gudhi/writing_persistence_to_file.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FILE_WRITER_
-#define FILE_WRITER_
+#ifndef WRITING_PERSISTENCE_TO_FILE_H
+#define WRITING_PERSISTENCE_TO_FILE_H
#include <iostream>
#include <string>
@@ -141,8 +141,8 @@ private:
**/
template <typename Filtration_type , typename Coefficient_field>
void write_persistence_intervals_to_stream(
-//const std::vector< Persistence_interval_common<Filtration_type,Coefficient_field> >& intervals,
-
+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 )
@@ -155,4 +155,4 @@ void write_persistence_intervals_to_stream(
}
-#endif //FILE_WRITER_
+#endif //WRITING_PERSISTENCE_TO_FILE_H