sort of desided const
authorAnatoly <Titov_AI@pnpi.nrcki.ru>
Thu, 7 Mar 2019 11:19:47 +0000 (14:19 +0300)
committerAnatoly <Titov_AI@pnpi.nrcki.ru>
Thu, 7 Mar 2019 11:19:47 +0000 (14:19 +0300)
src/fitng.cpp

index ea7c7e7a50f806c822f18fe57a6e319f2b95fe0d..5f4e0380c50abd86d6c4e275e21ac62b547d4cd2 100644 (file)
@@ -212,16 +212,16 @@ void searchF0xyzabc (double &F, double &Fx, double &Fy, double &Fz, double &Fa,
 
 void ApplyFit (std::vector< RVec > &b, double x, double y, double z, double A, double B, double C) {
     RVec temp;
-    //#pragma omp parallel
-    //{
-        //#pragma omp for schedule(dynamic)
+    #pragma omp parallel
+    {
+        #pragma omp for schedule(dynamic)
         for (int i = 0; i < b.size(); i++) {
             temp = b[i];
             b[i][0] = (temp[2] + z) * (sin(A) * sin(C) + cos(A) * cos(C) * sin(B)) - (temp[1] + y) * (cos(A) * sin(C) - cos(C) * sin(A) * sin(B)) + cos(B) * cos(C) * (temp[0] + x);
             b[i][1] = (temp[1] + y) * (cos(A) * cos(C) + sin(A) * sin(B) * sin(C)) - (temp[2] + z) * (cos(C) * sin(A) - cos(A) * sin(B) * sin(C)) + cos(B) * sin(C) * (temp[0] + x);
             b[i][2] = cos(A) * cos(B) * (temp[2] + z) - sin(B) * (temp[0] + x) + cos(B) * sin(A) * (temp[1] + y);
         }
-    //}
+    }
 }
 
 void CalcMid (std::vector< RVec > a, std::vector< RVec > b, RVec &midA, RVec &midB, std::vector< std::pair< int, int > > pairs) {
@@ -267,12 +267,12 @@ void MyFitNew (std::vector< RVec > a, std::vector< RVec > &b, std::vector< std::
         f1 += F(a[pairs[i].first][0], a[pairs[i].first][1], a[pairs[i].first][2], b[pairs[i].second][0] + x, b[pairs[i].second][1] + y, b[pairs[i].second][2] + z, A, B, C);
     }
     if (FtCnst == 0) {
-        FtCnst = 0.00001;
+        FtCnst = 0.0001;
     }
     if (f1 == 0) {
         return;
     } else {
-        int count = 0;
+        //int count = 0;
         while (f1 - f2 < 0 || f1 - f2 > FtCnst) {
             f1 = 0; fx = 0; fy = 0; fz = 0; fa = 0; fb = 0; fc = 0;
             for (int i = 0; i < pairs.size(); i++) {
@@ -283,17 +283,17 @@ void MyFitNew (std::vector< RVec > a, std::vector< RVec > &b, std::vector< std::
                 for (int i = 0; i < pairs.size(); i++) {
                     f2 += F(a[pairs[i].first][0], a[pairs[i].first][1], a[pairs[i].first][2], b[pairs[i].second][0] + (x - l * fx), b[pairs[i].second][1] + (y - l * fy), b[pairs[i].second][2] + (z - l * fz), A - l * fa, B - l * fb, C - l * fc);
                 }
-                count++;
+                //count++;
                 if (f2 < f1) {
                     x -= l * fx; y -= l * fy; z -= l * fz; A -= l * fa; B -= l * fb; C -= l * fc;
                     fx = 0; fy = 0; fz = 0; fa = 0; fb = 0; fc = 0;
                     break;
                 } else {
-                    l *= 0.85; // may be put somewhere l > 0
+                    l *= 0.99; // may be put somewhere l > 0
                 }
             }
-            count++;
         }
+        //std::cout << " " << count << "\n";
         ApplyFit(b, x, y, z, A, B, C);
     }
 }
@@ -404,8 +404,12 @@ void TrajFitting(std::vector< std::vector < RVec > > &trj, double FC, std::vecto
         std::vector< std::vector < RVec > > clone;
         clone.resize(0);
         clone.resize(prs.size(), trj[i]);
+        std::chrono::time_point<std::chrono::system_clock> now1, now2;
         for (int j = 0; j < prs.size(); j++) {
+            now1 = std::chrono::system_clock::now();
             MyFitNew(trj[0], clone[j], prs[j], FC);
+            now2 = std::chrono::system_clock::now();
+            std::cout << " " << std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count() << "\n";
             for (int k = 0; k < prs[j].size(); k++) {
                 trj[i][prs[j][k].first] = clone[j][prs[j][k].first];
             }
@@ -458,7 +462,7 @@ class Fitng : public TrajectoryAnalysisModule
         std::vector< std::vector< std::pair< int, int > > >         pairs;
         int                                                         frames = 0;
         int                                                         method = 1;
-        double                                                      FitConst = 0.0001;
+        double                                                      FitConst = 0;
         std::string                                                 OutPutTrjName;
         t_trxstatus                                                 *op;
 };