#ifndef _utl_TabulatedFunctionErrors_h_ #define _utl_TabulatedFunctionErrors_h_ /*! \file Tabulated function with errors \author Stefano Argiro \date 26 Jan 2003 \version $Id$ */ #include #include #include namespace utl { /* \class TabulatedFunctionErrors TabulatedFunctionErrors.h "utl/TabulatedFunctionErrors.h" */ class TabulatedFunctionErrors : public TabulatedFunction { public: typedef TabulatedFunctionErrIterator IteratorErr; typedef ConstTabulatedFunctionErrIterator ConstIteratorErr; TabulatedFunctionErrors(const unsigned int interpolationOrder = 1, const double borderTolerance = 1e-3) : TabulatedFunction(interpolationOrder, borderTolerance) { } TabulatedFunctionErrors(const std::vector& xValues, const std::vector& xValuesErr, const std::vector& yValues, const std::vector& yValuesErr, const unsigned int interpolationOrder = 1, const double borderTolerance = 1e-3) : TabulatedFunction(interpolationOrder, borderTolerance) { FillTable(xValues, xValuesErr,yValues, yValuesErr); } virtual ~TabulatedFunctionErrors() { } PairErr operator[](const int idx) const { return PairErr(fX[idx], fXErr[idx], fY[idx], fYErr[idx]); } void Clear(); void PushBack(const double x, const double xErr, const double y, const double yErr); IteratorErr Begin() { return IteratorErr(fX.begin(), fXErr.begin(), fY.begin(), fYErr.begin()); } IteratorErr End() { return IteratorErr(fX.end(), fXErr.end(), fY.end(), fYErr.end()); } ConstIteratorErr Begin() const { return ConstIteratorErr(fX.begin(), fXErr.begin(), fY.begin(), fYErr.begin()); } ConstIteratorErr End() const { return ConstIteratorErr(fX.end(), fXErr.end(), fY.end(), fYErr.end()); } /// begin of array of errors X ArrayIterator XErrBegin() { return fXErr.begin(); } /// begin of array of errors X ArrayConstIterator XErrBegin() const { return fXErr.begin(); } /// begin of array of errors Y ArrayIterator YErrBegin() { return fYErr.begin(); } /// begin of array of errors Y ArrayConstIterator YErrBegin() const { return fYErr.begin(); } /// end of array of errors X ArrayIterator XErrEnd() { return fXErr.end(); } /// end of array of errors X ArrayConstIterator XErrEnd() const { return fXErr.end(); } /// end of array of errors Y ArrayIterator YErrEnd() { return fYErr.end(); } /// end of array of errors Y ArrayConstIterator YErrEnd() const { return fYErr.end(); } const double& GetXErr(const unsigned int idx) const { return fXErr[idx]; } const double& GetYErr(const unsigned int idx) const { return fYErr[idx]; } double& GetXErr(const unsigned int idx) { return fXErr[idx]; } double& GetYErr(const unsigned int idx) { return fYErr[idx]; } IteratorErr Insert(const IteratorErr& pos, const double x, const double xErr, const double y, const double yErr); //ConstIteratorErr Find(const double x, const double y) const; ConstIteratorErr FindX(const double x) const; ConstIteratorErr FindY(const double y) const; void Swap(TabulatedFunctionErrors& tf) { TabulatedFunction::Swap(tf); std::swap(fXErr, tf.fXErr); std::swap(fYErr, tf.fYErr); } private: void FillTable(const std::vector& xValues, const std::vector& xValuesErr, const std::vector& yValues, const std::vector& yValuesErr); private: Array fXErr; Array fYErr; }; } namespace std { template<> inline void swap(utl::TabulatedFunctionErrors& t1, utl::TabulatedFunctionErrors& t2) { t1.Swap(t2); } } #endif // Configure (x)emacs for this file ... // Local Variables: // mode: c++ // compile-command: "make -C .. -k" // End: