summaryrefslogtreecommitdiff
path: root/src/Rips_complex
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 /src/Rips_complex
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
Diffstat (limited to 'src/Rips_complex')
-rw-r--r--src/Rips_complex/example/example_one_skeleton_rips_from_correlation_matrix.cpp23
1 files changed, 12 insertions, 11 deletions
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);