From: Alex Schmidt Date: Wed, 26 Jun 2013 12:11:32 +0000 (+0200) Subject: ... X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/3675da388f7ca12cdc6d93f4a8b94ef4bdd96b19 ... --- diff --git a/obstat.hpp b/obstat.hpp index 2996043..6818792 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, 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, 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), para); + jackres.val += manymeans[imeas]; + } + jackres.val /= nmeas; + + for(int imean=0; imean