From 89cf008fb86be1c6e007f62f3916e22b248413eb Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 14 Oct 2014 16:36:20 +0100 Subject: [PATCH] minor fixes --- examples/exFit.cpp | 10 ++++++---- examples/exMin.cpp | 2 +- examples/exRootFinder.cpp | 2 +- lib/TabFunction.cpp | 5 ++++- lib/XYSampleData.hpp | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/exFit.cpp b/examples/exFit.cpp index c3cf663..9c0009c 100644 --- a/examples/exFit.cpp +++ b/examples/exFit.cpp @@ -17,22 +17,24 @@ int main(void) // generate fake data XYStatData data(nPoint, 1, 1); RandGen rg; - double x_k; + double x_k, y_k; CompiledDoubleModel f(1, 2, "return p_1*exp(-x_0*p_0);"); for (Index k = 0; k < nPoint; ++k) { x_k = k*dx; + y_k = f(&x_k, exactPar) + rg.gaussian(0.0, 0.1); + cout << x_k << " " << y_k << " " << 0.1 << endl; data.x(0, k) = x_k; - data.y(0, k) = f(&x_k, exactPar) + rg.gaussian(0.0, 0.1); + data.y(0, k) = y_k; } data.yyVar(0, 0).diagonal() = DMat::Constant(nPoint, 1, 0.1*0.1); data.assumeXExact(0); - + // fit DVec init = DVec::Constant(2, 0.5); FitResult p; - MinuitMinimizer minimizer; + MinuitMinimizer minimizer(2); data.fitAllPoints(); p = data.fit(minimizer, init, f); diff --git a/examples/exMin.cpp b/examples/exMin.cpp index c1fcffc..2c43c8b 100644 --- a/examples/exMin.cpp +++ b/examples/exMin.cpp @@ -18,7 +18,7 @@ int main(int argc, char* argv[]) source = argv[1]; CompiledDoubleFunction f(1, source); - MinuitMinimizer minimizer; + MinuitMinimizer minimizer(1); double min; minimizer.setVerbosity(Minimizer::Verbosity::Debug); diff --git a/examples/exRootFinder.cpp b/examples/exRootFinder.cpp index 0e9ca22..6a7c436 100644 --- a/examples/exRootFinder.cpp +++ b/examples/exRootFinder.cpp @@ -11,7 +11,7 @@ int main(void) DoubleFunction f1(2, [a](const double *x){return a*(1.-x[0]);}); DoubleFunction f2(2, [b](const double *x){return b*(x[1]-x[0]*x[0]);}); vector system = {&f1, &f2}; - GslHybridRootFinder solve; + GslHybridRootFinder solve(2); DVec init(2), x; solve.setVerbosity(Solver::Verbosity::Debug); diff --git a/lib/TabFunction.cpp b/lib/TabFunction.cpp index f9f2c09..a39a33a 100644 --- a/lib/TabFunction.cpp +++ b/lib/TabFunction.cpp @@ -68,7 +68,10 @@ double TabFunction::operator()(const double *arg) const if ((x < value_.begin()->first)||(x >= value_.rbegin()->first)) { - LATAN_ERROR(Range, "tabulated function variable out of range"); + LATAN_ERROR(Range, "tabulated function variable out of range (x= " + + strFrom(x) + " not in [" + + strFrom(value_.begin()->first) + ", " + + strFrom(value_.rbegin()->first) + "])"); } auto i = value_.equal_range(x); diff --git a/lib/XYSampleData.hpp b/lib/XYSampleData.hpp index f500994..a923da8 100644 --- a/lib/XYSampleData.hpp +++ b/lib/XYSampleData.hpp @@ -53,7 +53,7 @@ public: const Index j = 0) const; private: DSample chi2_; - Index nDof_{0}; + double nDof_{0.}; std::vector model_; };