X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/79dc42fe36820965127efc5755be1450521b0a26..598fe7b7a358769fc1b6c48772f35cf7b719e8b4:/obstat.hpp?ds=inline diff --git a/obstat.hpp b/obstat.hpp index 2996043..2824e69 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; } @@ -117,4 +119,35 @@ 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[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