From e7322c42a98f9f85bed30cbeb034c7627aa8d79f Mon Sep 17 00:00:00 2001 From: Alexey Shvetsov Date: Wed, 19 Jun 2019 13:59:49 +0300 Subject: [PATCH] Make it return =D Signed-off-by: Alexey Shvetsov --- src/spacetimecorr.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/spacetimecorr.cpp b/src/spacetimecorr.cpp index c9602e3..778c145 100644 --- a/src/spacetimecorr.cpp +++ b/src/spacetimecorr.cpp @@ -59,9 +59,10 @@ using namespace gmx; using gmx::RVec; -void read_correlation_matrix_file(std::vector< std::vector< std::vector< double > > > &crrlts, const char* file_name, unsigned long size, unsigned int length) +const std::vector< std::vector< std::vector< double > > > read_correlation_matrix_file(const char* file_name, unsigned long size, unsigned int length) { FILE *file; + std::vector< std::vector< std::vector< double > > > crrlts; file = std::fopen(file_name, "r+"); std::vector< double > c; c.resize(size, 0); @@ -85,9 +86,10 @@ void read_correlation_matrix_file(std::vector< std::vector< std::vector< double } std::fclose(file); std::cout << "\n"; + return crrlts; } -void make_correlation_matrix_file(std::vector< std::vector< std::vector< double > > > correlations, const char* file_name) +void make_correlation_matrix_file(const std::vector< std::vector< std::vector< double > > > correlations, const char* file_name) { FILE *file; file = std::fopen(file_name, "w+"); @@ -192,7 +194,8 @@ bool isitsubset (std::vector< int > a, std::vector< int > b) { } } -void correlation_evaluation(std::vector< RVec > ref, std::vector< std::vector< RVec > > traj, std::vector< std::vector< std::vector< double > > > &crl, unsigned int tauE) { +const std::vector< std::vector< std::vector< double > > > correlation_evaluation(std::vector< RVec > ref, std::vector< std::vector< RVec > > traj, unsigned int tauE) { + std::vector< std::vector< std::vector< double > > > crl; crl.resize(tauE + 1); for (unsigned int i = 0; i < crl.size(); i++) { crl[i].resize(traj.front().size()); @@ -244,12 +247,13 @@ void correlation_evaluation(std::vector< RVec > ref, std::vector< std::vector< R } #pragma omp barrier std::cout << "\n"; + return crl; } void graph_calculation( std::vector< std::vector< std::pair< double, long int > > > &graph, std::vector< std::vector< unsigned int > > &s_graph, std::vector< std::vector< std::pair< unsigned int, unsigned int > > > &s_graph_rbr, std::vector< std::vector< RVec > > traj, std::vector< RVec > ref, - std::vector< std::vector< std::vector< double > > > crl, double crl_b, double e_rad, unsigned int tauB, unsigned int tauE) { + const std::vector< std::vector< std::vector > > crl, double crl_b, double e_rad, unsigned int tauB, unsigned int tauE) { graph.resize(traj.front().size()); for (unsigned int i = 0; i < traj.front().size(); i++) { graph[i].resize(traj.front().size(), std::make_pair(0, -1)); @@ -568,7 +572,7 @@ SpaceTimeCorr::finishAnalysis(int nframes) if (mode == 0) { std::cout << "\nCorrelation's evaluation - start\n"; - correlation_evaluation(reference, trajectory, crltns, k); + crltns = correlation_evaluation(reference, trajectory, k); for (unsigned int i1 = 0; i1 < crltns.size(); i1++) { for (unsigned int i2 = 0; i2 < crltns[i1].size(); i2++) { @@ -586,7 +590,7 @@ SpaceTimeCorr::finishAnalysis(int nframes) std::cout << "Correlation's evaluation - end\n" << "graph evaluation: start\n"; } else if (mode == 1) { - read_correlation_matrix_file(crltns, (MtrxNm).c_str(), index.size(), k); + crltns = read_correlation_matrix_file((MtrxNm).c_str(), index.size(), k); for (unsigned int i1 = 0; i1 < crltns.size(); i1++) { for (unsigned int i2 = 0; i2 < crltns[i1].size(); i2++) { -- 2.22.0