]> git.treefish.org Git - phys/u1casc.git/commitdiff
Using precalc jack functions.
authorAlexander Schmidt <alex@treefish.org>
Thu, 20 Feb 2014 23:02:18 +0000 (00:02 +0100)
committerAlexander Schmidt <alex@treefish.org>
Thu, 20 Feb 2014 23:02:18 +0000 (00:02 +0100)
latlib
u1casc-ordinary/obs_phi2.hpp
u1casc-ordinary/obs_plaq.hpp

diff --git a/latlib b/latlib
index 33ee1f81e21dbb384b48c8083aff790ca313558e..e9c0e0b98886738917300348a522759c25d4a9c7 160000 (submodule)
--- a/latlib
+++ b/latlib
@@ -1 +1 @@
-Subproject commit 33ee1f81e21dbb384b48c8083aff790ca313558e
+Subproject commit e9c0e0b98886738917300348a522759c25d4a9c7
index 9afc39050c4802ce5dab97f935c4759ee92eb396..3e4fe4878b87afb8df0526776ef9a184c2911f11 100644 (file)
@@ -27,7 +27,9 @@ private:
   obsmem* OM;
 
   void phi2Compute();
-  static double phi2Sus(vector< vector<double> > *vals, void *para);
+
+  static void prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
+  static double phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
 
   sim *Sim;
   obstat<double,double> oPhi2[2];
@@ -61,7 +63,7 @@ void obs_phi2::_finish() {
 
   for (int iflav=0; iflav<2; iflav++) {
     compid_phi2[iflav] = oPhi2[iflav].computeEasy();
-    compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::phi2Sus, &(Sim->lsize4));
+    compid_phi2sus[iflav] = oPhi2[iflav].computeJack(obs_phi2::prePhi2Sus, obs_phi2::phi2Sus, &(Sim->lsize4));
 
     *out << "\t" << oPhi2[iflav].getMean(compid_phi2[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2[iflav]);
     *out << "\t" << oPhi2[iflav].getMean(compid_phi2sus[iflav]) << "\t" << oPhi2[iflav].getErr(compid_phi2sus[iflav]);
@@ -84,17 +86,21 @@ void obs_phi2::phi2Compute()
   }
 }
 
-double obs_phi2::phi2Sus(vector< vector<double> > *vals, void *para) {
-  double mean=0, mean2=0;
-  for(vector< vector<double> >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt)  
-    {
-      mean += (*valIt)[0];
-      mean2 += pow((*valIt)[0],2);
-    }
-  mean /= vals->size();
-  mean2 /= vals->size();
-  
-  return ( mean2 - pow(mean,2) ) * *(int*)para;
+void obs_phi2::prePhi2Sus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
+  preCalculated->push_back(0);
+  preCalculated->push_back(0);
+
+  for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
+    (*preCalculated)[0] += (*valIt)[0];
+    (*preCalculated)[1] += pow((*valIt)[0],2);
+  }
+}
+
+double obs_phi2::phi2Sus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
+  return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) )
+         - pow( (*preCalculated)[0] - (*excludedMeas)[0], 2 ))
+    * *(int*)para
+    / (nmeas-1);
 }
 
 #endif
index 5dacf68bf31543b278de7e21a84cf99810e0852d..2f09096bd1837033a5ec22ff3be971b7af5bbfcd 100644 (file)
@@ -27,7 +27,9 @@ private:
   obsmem* OM;
 
   void plaqCompute();
-  static double plaqSus(vector< vector<double> > *vals, void *para);
+
+  static void prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para);
+  static double plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para);
 
   sim *Sim;
   obstat<double,double> oPlaq;
@@ -57,7 +59,7 @@ void obs_plaq::_finish() {
   int compid_plaq, compid_plaqsus;
 
   compid_plaq = oPlaq.computeEasy();
-  compid_plaqsus = oPlaq.computeJack(obs_plaq::plaqSus, &(Sim->lsize4));
+  compid_plaqsus = oPlaq.computeJack(obs_plaq::prePlaqSus, obs_plaq::plaqSus, &(Sim->lsize4));
 
   *out << "\t" << oPlaq.getMean(compid_plaq) << "\t" << oPlaq.getErr(compid_plaq);
   *out << "\t" << oPlaq.getMean(compid_plaqsus) << "\t" << oPlaq.getErr(compid_plaqsus);
@@ -81,17 +83,21 @@ void obs_plaq::plaqCompute()
   OM->plaq /= Sim->lsize4*6;
 }
 
-double obs_plaq::plaqSus(vector< vector<double> > *vals, void *para) {
-  double mean=0, mean2=0;
-  for(vector< vector<double> >::iterator valIt = vals->begin(); valIt != vals->end(); ++valIt)  
-    {
-      mean += (*valIt)[0];
-      mean2 += pow((*valIt)[0],2);
-    }
-  mean /= vals->size();
-  mean2 /= vals->size();
-  
-  return ( mean2 - pow(mean,2) ) * *(int*)para * 6;
+void obs_plaq::prePlaqSus(vector< vector <double> > *allVals, vector <double> *preCalculated, void *para) {
+  preCalculated->push_back(0);
+  preCalculated->push_back(0);
+
+  for(vector< vector<double> >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) {
+    (*preCalculated)[0] += (*valIt)[0];
+    (*preCalculated)[1] += pow((*valIt)[0],2);
+  }
+}
+
+double obs_plaq::plaqSus(vector <double> *preCalculated, vector<double> *excludedMeas, int nmeas, void *para) {
+  return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) )
+         - pow( (*preCalculated)[0] - (*excludedMeas)[0], 2 ))
+    * *(int*)para * 6
+    / (nmeas-1);
 }
 
 #endif