Skip to content
Snippets Groups Projects
Commit 6590d3ad authored by Lorenzo Moneta's avatar Lorenzo Moneta
Browse files

Do not use std::accumulate in the reduction function for the LogLikelihood to...

Do not use std::accumulate in the reduction function for the LogLikelihood to be sure the correct order is used
parent baaad779
No related branches found
No related tags found
No related merge requests found
...@@ -885,15 +885,27 @@ double FitUtil::EvaluateLogL(const IModelFunctionTempl<double> & func, const Un ...@@ -885,15 +885,27 @@ double FitUtil::EvaluateLogL(const IModelFunctionTempl<double> & func, const Un
} }
} }
nPoints++; nPoints++;
// {
// R__LOCKGUARD(gROOTMutex);
// std::cout << "compute Log-l for point " << i << " nPoints " << nPoints << " = " << logval << std::endl;
// }
return LikelihoodAux<double>(logval, W, W2); return LikelihoodAux<double>(logval, W, W2);
}; };
#ifdef R__USE_IMT #ifdef R__USE_IMT
// auto redFunction = [](const std::vector<LikelihoodAux<double>> & objs){
// return std::accumulate(objs.begin(), objs.end(), LikelihoodAux<double>(0.0,0.0,0.0),
// [](const LikelihoodAux<double> &l1, const LikelihoodAux<double> &l2){
// return l1+l2;
// });
// };
// do not use std::accumulate to be sure to maintain always the same order
auto redFunction = [](const std::vector<LikelihoodAux<double>> & objs){ auto redFunction = [](const std::vector<LikelihoodAux<double>> & objs){
return std::accumulate(objs.begin(), objs.end(), LikelihoodAux<double>(0.0,0.0,0.0), auto l0 = LikelihoodAux<double>(0.0,0.0,0.0);
[](const LikelihoodAux<double> &l1, const LikelihoodAux<double> &l2){ for ( auto & l : objs ) {
return l1+l2; l0 = l0 + l;
}); }
return l0;
}; };
#else #else
(void)nChunks; (void)nChunks;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment