43 template<
typename Treal>
65 else if (other.
empty()) {
87 if ( !intersection.
empty() ) {
117 inline bool cover(Treal
const value)
const {
121 return (value <= upperBound && value >=
lowerBound);
133 throw Failure(
"Interval<Treal>::increase(Treal const) : "
134 "Attempt to increase empty interval.");
163 return *
this + (-1.0 * other);
191 void puriStep(
int poly, Treal alpha);
201 template<
typename Treal>
207 template<
typename Treal>
208 inline Interval<Treal>
operator+(Treal
const value,
209 Interval<Treal>
const & other) {
210 return Interval<Treal>(value + other.lowerBound,
211 value + other.upperBound);
216 template<
typename Treal>
221 assert(other.
low() >= 0);
227 template<
typename Treal>
229 if (upperBound > 2.0 || lowerBound < -1.0)
230 throw Failure(
"Interval<Treal>::puriStep(int) : It is assumed here "
231 "that the interval I is within [-1.0, 2.0]");
245 bool nonEmptyIntervalInZeroToOne =
false;
246 if(upperBound > lowerBound && lowerBound >= 0 && upperBound <= 1)
247 nonEmptyIntervalInZeroToOne =
true;
252 upperBound = 2 * upperBound - upperBound * upperBound;
253 lowerBound = 2 * lowerBound - lowerBound * lowerBound;
254 if(nonEmptyIntervalInZeroToOne && upperBound < lowerBound) {
256 Treal midPoint = (lowerBound + upperBound) / 2;
257 upperBound = lowerBound = midPoint;
263 upperBound = upperBound * upperBound;
264 lowerBound = lowerBound * lowerBound;
268 template<
typename Treal>
270 if (upperBound > 2.0 || lowerBound < -1.0)
271 throw Failure(
"Interval<Treal>::puriStep(int) : It is assumed here "
272 "that the interval I is within [-1.0, 1.0]");
291 template<
typename Treal>
293 if (upperBound > 2.0 || lowerBound < -1.0)
294 throw Failure(
"Interval<Treal>::puriStep(int, real) : It is assumed here "
295 "that the interval I is within [-1.0, 2.0]");
309 bool nonEmptyIntervalInZeroToOne =
false;
310 if(upperBound > lowerBound && lowerBound >= 0 && upperBound <= 1)
311 nonEmptyIntervalInZeroToOne =
true;
316 upperBound = 2 * alpha * upperBound - alpha * alpha * upperBound * upperBound;
317 lowerBound = 2 * alpha * lowerBound - alpha * alpha * lowerBound * lowerBound;
318 if(nonEmptyIntervalInZeroToOne && upperBound < lowerBound) {
320 Treal midPoint = (lowerBound + upperBound) / 2;
321 upperBound = lowerBound = midPoint;
327 upperBound = ( alpha * upperBound + (1-alpha) ) * ( alpha * upperBound + (1-alpha) );
328 lowerBound = ( alpha * lowerBound + (1-alpha) ) * ( alpha * lowerBound + (1-alpha) );
332 template<
typename Treal>
334 if (upperBound > 2.0 || lowerBound < -1.0)
335 throw Failure(
"Interval<Treal>::invPuriStep(int, real) : It is assumed here "
336 "that the interval I is within [-1.0, 2.0]");
356 template<
typename Treal>
362 s<<
"["<<in.
low()<<
", "<<in.
upp()<<
"]";
Interval< Treal > operator*(Treal const &value) const
Definition: Interval.h:154
bool overlap(Interval const &other) const
Definition: Interval.h:123
Treal upp() const
Definition: Interval.h:143
Treal length() const
Returns the length of the interval.
Definition: Interval.h:107
void decrease(Treal const value)
Definition: Interval.h:138
Interval(Treal low=1, Treal upp=-1)
Definition: Interval.h:46
Interval< Treal > operator+(Treal const &value) const
Definition: Interval.h:181
static Interval intersect(Interval const &A, Interval const &B)
Definition: Interval.h:51
Interval< Treal > operator/(Treal const &value) const
Definition: Interval.h:172
void increase(Treal const value)
Increases interval with value in both directions.
Definition: Interval.h:131
bool empty() const
Definition: Interval.h:49
Definition: allocate.cc:30
Treal midPoint() const
Definition: Interval.h:113
Definition: Interval.h:44
void invPuriStep(int poly)
Definition: Interval.h:269
void puriStep(int poly)
Definition: Interval.h:228
XYZpUV< TX, TY, TZ, TU, TV > operator+(XYZ< TX, TY, TZ > const &ABC, XY< TU, TV > const &DE)
Addition of two multiplication proxys XYZ and XY.
Definition: matrix_proxy.h:235
Interval< Treal > operator-(Treal const &value) const
Definition: Interval.h:178
Treal low() const
Definition: Interval.h:142
bool cover(Treal const value) const
Definition: Interval.h:117
Interval< Treal > sqrtInt(Interval< Treal > const &other)
Definition: Interval.h:217
Treal upperBound
Definition: Interval.h:195
std::ostream & operator<<(std::ostream &s, Interval< Treal > const &in)
Definition: Interval.h:357
void intersect(Interval const &other)
Definition: Interval.h:62
Interval< Treal > operator+(Interval< Treal > const &other) const
Definition: Interval.h:168
Treal lowerBound
Definition: Interval.h:194
Interval< Treal > operator-(Interval< Treal > const &other) const
Definition: Interval.h:162
XmY< TX, TY > operator-(TX const &AA, TY const &BB)
Substraction of two objects of type TX and TY.
Definition: matrix_proxy.h:275
void intersect_always_non_empty(Interval const &other)
Definition: Interval.h:78
Treal template_blas_sqrt(Treal x)