-template <typename meastype, typename restype>
-int obstat<meastype,restype>::computeJack(restype (*func)(vector< vector<meastype> > *vals, void *para), void *para)
-{
- int nmeas=measurements.size();
- restype *manymeans = new restype[nmeas];
- result jackres;
-
- jackres.val = 0;
- jackres.err = 0;
-
- int imeas=0;
- for(typename vector< vector<meastype> >::iterator removedIt = measurements.begin(); removedIt != measurements.end(); ++removedIt, imeas++)
- {
- vector<meastype> removed = *removedIt;
-
- *removedIt = measurements.back();
- measurements.pop_back();
-
- manymeans[imeas] = func(&measurements, para);
- jackres.val += manymeans[imeas];
-
- measurements.push_back( *removedIt );
- *removedIt = removed;
- }
- jackres.val /= nmeas;
-
- for(int imean=0; imean<nmeas; imean++)
- jackres.err += pow( manymeans[imean] - jackres.val, 2 );
- jackres.err *= (double)(nmeas-1)/nmeas;
- jackres.err = sqrt(jackres.err);
-
- computations.push_back(jackres);
-
- delete [] manymeans;
-
- return computations.size()-1;
-}
-