BALL 1.5.0
Loading...
Searching...
No Matches
piecewiseFunction.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_MATHS_PIECEWISEFUNCTION_H
6#define BALL_MATHS_PIECEWISEFUNCTION_H
7
8#ifndef BALL_COMMON_H
9# include <BALL/common.h>
10#endif
11
12#include <limits>
13
14namespace BALL
15{
19 typedef std::vector<double> Coefficients;
20
23 typedef std::pair<double,double> Interval;
24
35 {
36 public:
37
39
40
43
47
51
54 PiecewiseFunction(const std::vector<Interval>& intervals,
55 const std::vector<Coefficients>& coeffs) ;
56
59 virtual ~PiecewiseFunction() ;
60
62
65
68 PiecewiseFunction& operator = (const PiecewiseFunction& function) ;
69
72 void clear() ;
73
75
78
83 void setIntervals(const std::vector<Interval>& intervals) ;
84
87 const std::vector<Interval>& getIntervals() const ;
88
92 const Interval& getInterval(double x) const;
93
97 const Interval& getInterval(Position index) const;
98
102 Position getIntervalIndex(double x) const;
103
106 const Interval& getRange() const;
107
112 void setCoefficients(const vector<Coefficients>& coefficients) ;
113
115 const std::vector<Coefficients>& getCoefficients() const ;
116
120 const Coefficients& getCoefficients(double x) const;
121
126
129 virtual double operator () (double x) const;
130
132 void set(const std::vector<Interval>& intervals,
133 const std::vector<Coefficients>& coeffs);
134
136
139
142 bool isInRange(double x) const;
143
146 virtual bool isValid() const;
147
150 bool operator == (const PiecewiseFunction& function) const;
151
153
156
159 virtual void dump (std::ostream& s = std::cout, Size depth = 0) const;
160
162
163 protected:
164
165 /*_ This vector contains the intervals of the representation
166 */
168
169 /*_ This vector stores the coefficients for each interval
170 */
172
173 bool valid_;
174
175
176 private:
177
178 /*_ The range of the defnition, needed for isInRange() and getRange()
179 */
180 Interval range_;
181
182 /*_ Set the internal range fields
183 */
184 void calculateRange();
185
186 };
187}
188
189#endif
#define BALL_EXPORT
void set(const std::vector< Interval > &intervals, const std::vector< Coefficients > &coeffs)
std::vector< Interval > intervals_
const Interval & getRange() const
void setCoefficients(const vector< Coefficients > &coefficients)
Position getIntervalIndex(double x) const
std::vector< Coefficients > coefficients_
virtual bool isValid() const
const Interval & getInterval(double x) const
const std::vector< Coefficients > & getCoefficients() const
void setIntervals(const std::vector< Interval > &intervals)
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
const std::vector< Interval > & getIntervals() const
bool isInRange(double x) const
#define BALL_CREATE(name)
Definition create.h:62
std::vector< double > Coefficients
BALL_SIZE_TYPE Size
std::pair< double, double > Interval
BALL_SIZE_TYPE Position
STL namespace.