Loading...
Searching...
No Matches
piecewiseFunction.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_MATHS_PIECEWISEFUNCTION_H
#define BALL_MATHS_PIECEWISEFUNCTION_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#include <limits>
namespace BALL
{
typedef std::vector<double> Coefficients;
typedef std::pair<double,double> Interval;
class BALL_EXPORT PiecewiseFunction
{
public:
BALL_CREATE(PiecewiseFunction)
PiecewiseFunction() ;
PiecewiseFunction(const PiecewiseFunction& function) ;
PiecewiseFunction(const std::vector<Interval>& intervals,
const std::vector<Coefficients>& coeffs) ;
virtual ~PiecewiseFunction() ;
PiecewiseFunction& operator = (const PiecewiseFunction& function) ;
void clear() ;
void setIntervals(const std::vector<Interval>& intervals) ;
const std::vector<Interval>& getIntervals() const ;
const Interval& getInterval(double x) const;
const Interval& getInterval(Position index) const;
Position getIntervalIndex(double x) const;
const Interval& getRange() const;
void setCoefficients(const vector<Coefficients>& coefficients) ;
const std::vector<Coefficients>& getCoefficients() const ;
const Coefficients& getCoefficients(double x) const;
const Coefficients& getCoefficients(Position index) const;
virtual double operator () (double x) const;
void set(const std::vector<Interval>& intervals,
const std::vector<Coefficients>& coeffs);
bool isInRange(double x) const;
virtual bool isValid() const;
bool operator == (const PiecewiseFunction& function) const;
virtual void dump (std::ostream& s = std::cout, Size depth = 0) const;
protected:
/*_ This vector contains the intervals of the representation
*/
std::vector<Interval> intervals_;
/*_ This vector stores the coefficients for each interval
*/
std::vector<Coefficients> coefficients_;
bool valid_;
private:
/*_ The range of the defnition, needed for isInRange() and getRange()
*/
Interval range_;
/*_ Set the internal range fields
*/
void calculateRange();
};
}
#endif
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::PiecewiseFunction::set
void set(const std::vector< Interval > &intervals, const std::vector< Coefficients > &coeffs)
BALL::PiecewiseFunction::intervals_
std::vector< Interval > intervals_
Definition piecewiseFunction.h:167
BALL::PiecewiseFunction::getRange
const Interval & getRange() const
BALL::PiecewiseFunction::setCoefficients
void setCoefficients(const vector< Coefficients > &coefficients)
BALL::PiecewiseFunction::getIntervalIndex
Position getIntervalIndex(double x) const
BALL::PiecewiseFunction::coefficients_
std::vector< Coefficients > coefficients_
Definition piecewiseFunction.h:171
BALL::PiecewiseFunction::valid_
bool valid_
Definition piecewiseFunction.h:173
BALL::PiecewiseFunction::PiecewiseFunction
PiecewiseFunction()
BALL::PiecewiseFunction::isValid
virtual bool isValid() const
BALL::PiecewiseFunction::getInterval
const Interval & getInterval(double x) const
BALL::PiecewiseFunction::getCoefficients
const std::vector< Coefficients > & getCoefficients() const
BALL::PiecewiseFunction::clear
void clear()
BALL::PiecewiseFunction::setIntervals
void setIntervals(const std::vector< Interval > &intervals)
BALL::PiecewiseFunction::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::PiecewiseFunction::getIntervals
const std::vector< Interval > & getIntervals() const
BALL::PiecewiseFunction::isInRange
bool isInRange(double x) const
common.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL::Coefficients
std::vector< double > Coefficients
Definition piecewiseFunction.h:19
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Interval
std::pair< double, double > Interval
Definition piecewiseFunction.h:23
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
std
STL namespace.