3 #ifndef _MONOTCUBICINTERPOLATOR_H
4 #define _MONOTCUBICINTERPOLATOR_H
83 if (!
read(datafilename)) {
84 throw(
"Unable to constuct MonotCubicInterpolator from file.") ;
103 if (!
read(std::string(datafilename))) {
104 throw(
"Unable to constuct MonotCubicInterpolator from file.") ;
119 if (!
read(std::string(datafilename),xColumn,fColumn)) {
120 throw(
"Unable to constuct MonotCubicInterpolator from file.") ;
134 if (!
read(datafilename,xColumn,fColumn)) {
135 throw(
"Unable to constuct MonotCubicInterpolator from file.") ;
148 const std::vector<double> & f);
173 bool read(
const std::string & datafilename) {
174 return read(datafilename,1,2) ;
185 bool read(
const std::string & datafilename,
int xColumn,
int fColumn) ;
213 double evaluate(
double x)
const throw(
const char*);
234 double evaluate(
double x,
double & errorestimate_output )
const ;
244 return *data.begin();
255 return *data.rbegin();
264 std::pair<double,double>
getMaximumF()
const throw(const
char*) ;
311 if (strictlyMonotoneCached) {
312 return strictlyMonotone;
315 computeInternalFunctionData();
316 return strictlyMonotone;
326 if (monotoneCached) {
330 computeInternalFunctionData();
344 if (strictlyMonotoneCached) {
345 return (strictlyMonotone && strictlyIncreasing);
348 computeInternalFunctionData();
349 return (strictlyMonotone && strictlyIncreasing);
359 if (monotoneCached) {
360 return (monotone && increasing);
363 computeInternalFunctionData();
364 return (monotone && increasing);
377 if (strictlyMonotoneCached) {
378 return (strictlyMonotone && strictlyDecreasing);
381 computeInternalFunctionData();
382 return (strictlyMonotone && strictlyDecreasing);
392 if (monotoneCached) {
393 return (monotone && decreasing);
396 computeInternalFunctionData();
397 return (monotone && decreasing);
416 void addPair(
double newx,
double newf)
throw(
const char*);
430 std::pair<double,double>
getMissingX()
const throw(const
char*) ;
506 std::map<double, double> data;
509 mutable std::map<double, double> ddata;
515 mutable bool strictlyMonotoneCached;
516 mutable bool monotoneCached;
518 mutable bool strictlyMonotone;
519 mutable bool monotone;
523 mutable bool strictlyDecreasing;
524 mutable bool strictlyIncreasing;
525 mutable bool decreasing;
526 mutable bool increasing;
536 double H00(
double t)
const {
537 return 2*t*t*t - 3*t*t + 1;
540 double H10(
double t)
const {
541 return t*t*t - 2*t*t + t;
544 double H01(
double t)
const {
545 return -2*t*t*t + 3*t*t;
548 double H11(
double t)
const {
563 void computeInternalFunctionData()
const ;
572 void computeSimpleDerivatives()
const ;
581 void adjustDerivativesForMonotoneness()
const ;
592 bool isMonotoneCoeff(
double alpha,
double beta)
const {
593 if ((alpha*alpha + beta*beta) <= 9) {
std::pair< double, double > getMinimumX() const
Definition: MonotCubicInterpolator.hpp:242
void addPair(double newx, double newf)
Definition: MonotCubicInterpolator.cpp:174
double operator()(double x) const
Definition: MonotCubicInterpolator.hpp:200
double evaluate(double x) const
Definition: MonotCubicInterpolator.cpp:189
void shrinkFlatAreas()
Definition: MonotCubicInterpolator.hpp:495
bool isMonotone() const
Definition: MonotCubicInterpolator.hpp:325
bool isStrictlyIncreasing()
Definition: MonotCubicInterpolator.hpp:341
std::vector< double > get_xVector() const
Definition: MonotCubicInterpolator.cpp:251
Namespace included for using the monotone cubic interpolator.
Definition: MonotCubicInterpolator.cpp:101
MonotCubicInterpolator(const char *datafilename, int xColumn, int fColumn)
Definition: MonotCubicInterpolator.hpp:117
bool read(const std::string &datafilename)
Definition: MonotCubicInterpolator.hpp:173
bool isMonotoneIncreasing() const
Definition: MonotCubicInterpolator.hpp:358
void scaleData(double factor)
Definition: MonotCubicInterpolator.cpp:723
MonotCubicInterpolator(const std::string &datafilename)
Definition: MonotCubicInterpolator.hpp:81
int getSize() const
Definition: MonotCubicInterpolator.hpp:442
bool isMonotoneDecreasing() const
Definition: MonotCubicInterpolator.hpp:391
std::pair< double, double > getMaximumX() const
Definition: MonotCubicInterpolator.hpp:253
bool isStrictlyDecreasing()
Definition: MonotCubicInterpolator.hpp:374
MonotCubicInterpolator()
Definition: MonotCubicInterpolator.hpp:156
std::vector< double > get_fVector() const
Definition: MonotCubicInterpolator.cpp:266
Represents one dimensional function f with single valued argument x that can be interpolated using mo...
Definition: MonotCubicInterpolator.hpp:69
std::pair< double, double > getMinimumF() const
Definition: MonotCubicInterpolator.cpp:368
MonotCubicInterpolator(const char *datafilename)
Definition: MonotCubicInterpolator.hpp:101
MonotCubicInterpolator(const std::string &datafilename, int xColumn, int fColumn)
Definition: MonotCubicInterpolator.hpp:132
std::pair< double, double > getMaximumF() const
Definition: MonotCubicInterpolator.cpp:345
void chopFlatEndpoints()
Definition: MonotCubicInterpolator.hpp:471
bool isStrictlyMonotone()
Definition: MonotCubicInterpolator.hpp:308
std::string toString() const
Definition: MonotCubicInterpolator.cpp:283
std::pair< double, double > getMissingX() const
Definition: MonotCubicInterpolator.cpp:311