X-Git-Url: http://git.treefish.org/~alex/phys/u1casc.git/blobdiff_plain/122860ecfb20eedd86f4e9c674f7afa21099caa2..33f700a8121cd3f356902483d7af9a9a253037a0:/u1casc-ordinary/obs_plaq.hpp diff --git a/u1casc-ordinary/obs_plaq.hpp b/u1casc-ordinary/obs_plaq.hpp index 5dacf68..63e5296 100644 --- a/u1casc-ordinary/obs_plaq.hpp +++ b/u1casc-ordinary/obs_plaq.hpp @@ -27,7 +27,9 @@ private: obsmem* OM; void plaqCompute(); - static double plaqSus(vector< vector > *vals, void *para); + + static void prePlaqSus(vector< vector > *allVals, vector *preCalculated, void *para); + static double plaqSus(vector *preCalculated, vector *excludedMeas, int nmeas, void *para); sim *Sim; obstat 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,20 @@ void obs_plaq::plaqCompute() OM->plaq /= Sim->lsize4*6; } -double obs_plaq::plaqSus(vector< vector > *vals, void *para) { - double mean=0, mean2=0; - for(vector< vector >::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 > *allVals, vector *preCalculated, void *para) { + preCalculated->push_back(0); + preCalculated->push_back(0); + + for(vector< vector >::iterator valIt = allVals->begin(); valIt != allVals->end(); ++valIt) { + (*preCalculated)[0] += (*valIt)[0]; + (*preCalculated)[1] += pow((*valIt)[0],2); + } +} + +double obs_plaq::plaqSus(vector *preCalculated, vector *excludedMeas, int nmeas, void *para) { + return (( (*preCalculated)[1] - pow((*excludedMeas)[0], 2) ) / (nmeas-1) + - pow( ( (*preCalculated)[0] - (*excludedMeas)[0] ) / (nmeas-1), 2 )) + * *(int*)para * 6; } #endif