Make it return =D
authorAlexey Shvetsov <alexxy@gentoo.org>
Wed, 19 Jun 2019 10:59:49 +0000 (13:59 +0300)
committerAlexey Shvetsov <alexxy@gentoo.org>
Wed, 19 Jun 2019 11:01:26 +0000 (14:01 +0300)
Signed-off-by: Alexey Shvetsov <alexxy@gentoo.org>
src/spacetimecorr.cpp

index c9602e3cc9c53f25efe6dc851c44ce1419622795..778c145954fa2826b6355608e8084b6005dc0e3c 100644 (file)
@@ -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<double > > > 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++) {