From 524c8f685c61bd3a547433ca88f6e8b996814267 Mon Sep 17 00:00:00 2001 From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch> Date: Mon, 18 Apr 2016 17:03:53 +0200 Subject: [PATCH] Fix warning and increase precision to fix a failing test in TFormula (test35) --- hist/hist/src/TF1Convolution.cxx | 5 +++-- test/TFormulaParsingTests.h | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/hist/hist/src/TF1Convolution.cxx b/hist/hist/src/TF1Convolution.cxx index 1adbd721987..5824d5419b1 100644 --- a/hist/hist/src/TF1Convolution.cxx +++ b/hist/hist/src/TF1Convolution.cxx @@ -63,8 +63,9 @@ public: Double_t operator()(Double_t x) const { // use EvalPar that is faster - Double_t xx[2]; xx[0] = x; xx[1] = fT0-x; - Double_t x2 = fT0-x; + Double_t xx[2]; + xx[0] = x; + xx[1] = fT0-x; return fFunction1->EvalPar(xx,nullptr) * fFunction2->EvalPar(xx+1,nullptr); } }; diff --git a/test/TFormulaParsingTests.h b/test/TFormulaParsingTests.h index d92aa619d46..245b539321d 100644 --- a/test/TFormulaParsingTests.h +++ b/test/TFormulaParsingTests.h @@ -573,18 +573,20 @@ bool test35() { // test for similar pre-defined functions bool ok = true; TF1 f1("f1","cheb1(0)+cheb10(2)",-1,1); - std::vector<double> p(12); - p.assign(12,1.); p[1] = 2; p[2] = 3; - TF1 g1("g1",[](double *x, double *p){ return ROOT::Math::ChebyshevN(1, x[0], p ) + ROOT::Math::ChebyshevN(10,x[0],p+2 ); }, -1, 1, 12); - f1.SetParameters(p.data()); - g1.SetParameters(p.data()); - ok &= TMath::AreEqualAbs( f1.Eval(2), g1.Eval(2), 1.E-10); + std::vector<double> par(13); + par.assign(13,1.); par[1] = 2; par[2] = 3; + TF1 g1("g1",[](double *x, double *p){ return ROOT::Math::ChebyshevN(1, x[0], p ) + ROOT::Math::ChebyshevN(10,x[0],p+2 ); }, -1, 1, 13); + f1.SetParameters(par.data()); + g1.SetParameters(par.data()); - TF1 f2("f2","cheb10(0)+cheb1(11)",-1,1); - TF1 g2("g2",[](double *x, double *p){ return ROOT::Math::ChebyshevN(10, x[0], p ) + ROOT::Math::ChebyshevN(1,x[0],p+11 ); }, -1, 1, 12); - f2.SetParameters(p.data()); - g2.SetParameters(p.data()); + ok &= TMath::AreEqualRel( f1.Eval(2), g1.Eval(2), 1.E-6); + TF1 f2("f2","cheb10(0)+cheb1(11)",-1,1); + TF1 g2("g2",[](double *x, double *p){ return ROOT::Math::ChebyshevN(10, x[0], p ) + ROOT::Math::ChebyshevN(1,x[0],p+11 ); }, -1, 1, 13); + f2.SetParameters(par.data()); + g2.SetParameters(par.data()); + + ok &= TMath::AreEqualRel( f2.Eval(2), g2.Eval(2), 1.E-6); return ok; } -- GitLab