X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/79dc42fe36820965127efc5755be1450521b0a26..d945435d46acac2f758c23f0a5ae99cbb9894b91:/obstat.hpp diff --git a/obstat.hpp b/obstat.hpp index 2996043..57a3431 100644 --- a/obstat.hpp +++ b/obstat.hpp @@ -17,7 +17,9 @@ public: int computeEasy(const int& ival=0) { return mean(&measurements, ival); } - int computeJack(restype (*func)(vector< vector > *vals, void *para)=NULL, void *para=NULL); + int computeJack(restype (*func)(vector< vector > *vals, void *para), void *para=NULL); + int computeJack(void (*preMeasFunc)(vector< vector > *allVals, vector *preCalculated, void *para), + restype (*measFunc)(vector *preCalculated, vector *excludedmeas, int nmeas, void *para), void *para=NULL); restype getMean(int compid) { return computations[compid].val; } restype getErr(int compid) { return computations[compid].err; } @@ -85,7 +87,7 @@ template int obstat::computeJack(restype (*func)(vector< vector > *vals, void *para), void *para) { int nmeas=measurements.size(); - restype manymeans[nmeas]; + restype *manymeans = new restype[nmeas]; result jackres; jackres.val = 0; @@ -114,6 +116,41 @@ int obstat::computeJack(restype (*func)(vector< vector +int obstat::computeJack(void (*preMeasFunc)(vector< vector > *allVals, vector *preCalculated, void *para), + restype (*measFunc)(vector *preCalculated, vector *excludedmeas, int nmeas, void *para), + void *para) { + int nmeas=measurements.size(); + restype *manymeans = new restype[nmeas]; + result jackres; + vector preCalculated; + + jackres.val = 0; + jackres.err = 0; + + preMeasFunc(&measurements, &preCalculated, para); + + int imeas=0; + for(typename vector< vector >::iterator removedIt = measurements.begin(); removedIt != measurements.end(); ++removedIt, imeas++) { + manymeans[imeas] = measFunc(&preCalculated, &(*removedIt), measurements.size(), para); + jackres.val += manymeans[imeas]; + } + jackres.val /= nmeas; + + for(int imean=0; imean