8 #if !defined(__clang_major__) || __clang_major__ < 5
9 # include <ext/algorithm>
11 #include <utl/AugerException.h>
12 #include <utl/TabulatedFunctionIterators.h>
13 #include <utl/TabulatedFunctionErrors.h>
14 #include <utl/ErrorLogger.h>
20 void TabulatedFunctionErrors::FillTable(
const std::vector<double>& xValues,
21 const std::vector<double>& xErrValues,
22 const std::vector<double>& yValues,
23 const std::vector<double>& yErrValues)
26 const unsigned int xSize = xValues.size();
28 if (xSize != yValues.size() || xSize != xErrValues.size() ||
29 xSize != yErrValues.size()) {
31 err <<
"size of x, xErr, y, yErr arrays are different";
41 if (is_sorted(fX.begin(), fX.end()))
45 for (
unsigned int i = 0; i < xSize; ++i) {
46 unsigned int mini = i;
48 for (
unsigned int j = i+1; j < xSize; ++j) {
49 const double x = fX[j];
57 swap(fX[i], fX[mini]);
58 swap(fY[i], fY[mini]);
59 swap(fXErr[i], fXErr[mini]);
60 swap(fYErr[i], fYErr[mini]);
67 TabulatedFunctionErrors::PushBack(
const double x,
const double xErr,
68 const double y,
const double yErr)
72 fXErr.push_back(xErr);
73 fYErr.push_back(yErr);
96 TabulatedFunctionErrors::FindX(
const double x)
99 const Array::const_iterator xBegin = fX.begin();
100 const Array::const_iterator xEnd = fX.end();
101 const Array::const_iterator xIt = lower_bound(xBegin, xEnd, x);
102 if (xIt == xEnd || x != *xIt)
105 const int off = xIt - xBegin;
106 const Array::const_iterator yIt = fY.begin() + off;
107 const Array::const_iterator xErrIt = fXErr.begin() + off;
108 const Array::const_iterator yErrIt = fYErr.begin() + off;
115 TabulatedFunctionErrors::FindY(
const double y)
118 const Array::const_iterator yIt = find(fY.begin(), fY.end(), y);
122 const int off = yIt - fY.begin();
123 const Array::const_iterator xIt = fX.begin() + off;
124 const Array::const_iterator xErrIt = fXErr.begin() + off;
125 const Array::const_iterator yErrIt = fYErr.begin() + off;
133 const double x,
const double xErr,
const double y,
const double yErr)
136 while (it != pos && it != End())
144 xIt = fX.insert(xIt, x);
145 xErrIt = fXErr.insert(xErrIt, xErr);
146 yIt = fY.insert(yIt, y);
147 yErrIt = fYErr.insert(yErrIt, yErr);
154 TabulatedFunctionErrors::Clear()
156 TabulatedFunction::Clear();
void swap(utl::Trace< T > &t1, utl::Trace< T > &t2)
InternalIterator fYErrIterator
InternalIterator fYIterator
InternalIterator fXIterator
Exception for reporting variable out of valid range.
#define ERROR(message)
Macro for logging error messages.
InternalIterator fXErrIterator