From b5667b282e8cee9e1d2bfcf90bdfbbf2bc0030b2 Mon Sep 17 00:00:00 2001 From: pdlotko Date: Thu, 8 Feb 2018 10:00:57 +0000 Subject: 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 --- ...e_one_skeleton_rips_from_correlation_matrix.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/Rips_complex/example') 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); -- cgit v1.2.3