/usr/include/BALL/MATHS/piecewiseFunction.h is in libball1.4-dev 1.4.1+20111206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_MATHS_PIECEWISEFUNCTION_H
#define BALL_MATHS_PIECEWISEFUNCTION_H
#ifndef BALL_COMMON_LIMITS_H
# include <BALL/COMMON/limits.h>
#endif
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
namespace BALL
{
/** Every piece of a piecewise function needs a bunch of coefficients
\ingroup FunctionClasses
*/
typedef std::vector<double> Coefficients;
/** An interval is defined by its limits
*/
typedef std::pair<double,double> Interval;
#ifdef INFINITY
#undef INFINITY
#endif
static const double INFINITY = Limits<double>::max();
/** Piecewise function object.
This class provides the interface for piecewise functions needed as
representation of radial distribution functions (@see RadialDistributionFunction).
It implements the <tt>Function</tt> interface. \par
Note that intervals <b> must </b> be disjunct and interval limits have to
meet. We require the intervals to be sorted such that the lowest interval
limit is the first interval of the vector. \par
*/
class BALL_EXPORT PiecewiseFunction
{
public:
BALL_CREATE(PiecewiseFunction)
/** @name Constructors and Destructors
*/
//@{
/** Default constructor
*/
PiecewiseFunction() ;
/** Copy constructor
*/
PiecewiseFunction(const PiecewiseFunction& function) ;
/** Detailed constructor
*/
PiecewiseFunction(const std::vector<Interval>& intervals,
const std::vector<Coefficients>& coeffs) ;
/** Destructor
*/
virtual ~PiecewiseFunction() ;
//@}
/** @name Assignment
*/
//@{
/** Assignemnt operator
*/
PiecewiseFunction& operator = (const PiecewiseFunction& function) ;
/** Clear function
*/
void clear() ;
//@}
/** @name Accessors
*/
//@{
/** Set the intervals for the piecewise definition.
Note that this method does <b>not</b> check the definition of the
intervals for sanity.
*/
void setIntervals(const std::vector<Interval>& intervals) ;
/** Get all the intervals
*/
const std::vector<Interval>& getIntervals() const ;
/** Get the interval a given x belongs to
* @throw Exception::OutOfRange if x is out of range
*/
const Interval& getInterval(double x) const;
/** Get interval limits by index
* @throw Exception::IndexOverflow if index >= intervals_.size()
*/
const Interval& getInterval(Position index) const;
/** Get the interval index for a given x
* @throw Exception::OutOfRange if x is out of range
*/
Position getIntervalIndex(double x) const;
/** Return the range of the definition
*/
const Interval& getRange() const;
/** Set the coefficients.
Note that this method does <b>not</b> check the vector of coefficients
for sanity.
*/
void setCoefficients(const vector<Coefficients>& coefficients) ;
/** */
const std::vector<Coefficients>& getCoefficients() const ;
/** Get the coefficients for a given x
* @throw Exception::OutOfRange if x is out of range
*/
const Coefficients& getCoefficients(double x) const;
/** Get the coefficients from index
* @throw Exception::IndexOverflow if index >= intervals_.size()
*/
const Coefficients& getCoefficients(Position index) const;
/** compute the value of the piecewise function data for a given x
*/
virtual double operator () (double x) const;
/** */
void set(const std::vector<Interval>& intervals,
const std::vector<Coefficients>& coeffs);
//@}
/** @name Predicates
*/
//@{
/** Check whether a given x is in the range of definition
*/
bool isInRange(double x) const;
/** check validity of the definition
*/
virtual bool isValid() const;
/** Equality operator
*/
bool operator == (const PiecewiseFunction& function) const;
//@}
/** @name Debugging and Diagnostics
*/
//@{
/** Dumps the whole content of the object
*/
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
|