#include <Interval.h>
Interval arithmetic is a method for representing ranges of numbers. For example, given a function f(x) = 3x, then we have f(4) = 12. But if we only know the range of numbers as the input of f, then we want to (over) estimate the range of possible results. Hence f([3,5]) = [9,15] which means if f is evaluated on any value between 3 and 5 inclusive, then its result will be something between 9 and 15. We don't know what the answer is, but we know what the answer can not be less than 9 nor greater than 15.
Intervals are represented in this library using the member variables low and high. If DEBUG is def'ed, then intervals are checked that low < high. When setting an interval, only use the constructors or setInterval since these check the order (when DEBUG def'ed).
For more information on interval analysis for graphics, see:
Definition at line 79 of file Interval.h.
Public Member Functions | |
Constructors @{ | |
| Interval (void) | |
| Default constructor. | |
| Interval (Type a) | |
| Construct an interval using a single number as low and high. | |
| Interval (Type low, Type high) | |
| Construct the interval [low,high]. | |
Attribute Access and Assignment @{ | |
| Infinite< Type > | low (void) const |
| Returns smallest value the interval represents. | |
| Infinite< Type > | high (void) const |
| Returns largest value the interval represents. | |
| operator Type () const | |
| Type conversion. | |
| void | setInterval (Type low, Type high) |
| Sets the interval to [l,h]. | |
Checks @{ | |
| virtual void | print () const |
| Basic print out of the interval. | |
| virtual void | error () const |
| Error function can be called when low > high. | |
| void | check () const |
| Checks if low < high. | |
| int | thin () const |
| Checks if interval is zero width. | |
Unary Operators @{ | |
| Infinite< Type > | width () const |
| Return width of interval. | |
| Infinite< Type > | center () const |
| Return center of interval. | |
| Interval< Type > | exp () const |
| Return e to the interval power. | |
| Interval< Type > | squared () const |
| Squares the interval. Returns either endpoint or the apex of parabola. | |
| Interval< Type > | cubed () const |
| Cubes the interval. | |
| Interval< Type > | log () const |
| Returns the natural log (ln) of the interval. | |
| Interval< Type > | pow (Interval< Type > n) const |
| Raises an interval to the power of another interval. | |
| Interval< Type > | pow (int n) const |
| Integer exponents Determines if i is even or odd, and returns a tight interval in either case. | |
| Interval< Type > | sqrt () const |
| Square root of a non-negative interval. | |
| Interval< Type > | fabs () const |
| Returns absolute value of interval. | |
| Interval< Type > | operator- () const |
| Negates the interval (unary negation). | |
Binary Operators @{ | |
| Interval< Type > | intersection (Interval< Type > &b) |
| Intesection of intervals. | |
| Interval< Type > | unionWith (Interval< Type > &b) |
| Union of intervals = smallest interval containing both intervals. | |
| Interval< Type > & | operator+= (const Interval< Type > &b) |
| Add interval to me. | |
| Interval< Type > & | operator+= (const Type &b) |
| Add a basic Type to me - promotes Type to Interval. | |
| Interval< Type > & | operator-= (const Interval< Type > &b) |
| Subtract interval from me. | |
| Interval< Type > & | operator-= (const Type &b) |
| Subtract a base Type from me - promotes Type to Interval. | |
| Interval< Type > & | operator *= (const Interval< Type > &b) |
| Multiply interval times me. | |
| Interval< Type > & | operator *= (const Type &b) |
| Multiply a base Type times me - promotes Type to Interval. | |
| Interval< Type > & | operator/= (const Interval< Type > &b) |
| Divide me by interval. | |
| Interval< Type > & | operator/= (const Type &b) |
| Divide me by a base Type - promotes base Type to Interval. | |
Conditions @{ | |
| int | contains (const Interval< Type > &a) const |
| Contains is True if a is a subset of me. | |
| int | containsProper (const Interval< Type > &a) const |
| ContainsProper is True if a is a proper subset of me. | |
| int | overlaps (const Interval< Type > &a) const |
| Overlaps is True if a intersects me. | |
| int | disjoint (const Interval< Type > &a) const |
| Disjoint is True if a does not intersect me. | |
| int | isZero () const |
| Checks if the interval is pretty much [0,0]. | |
| int | isPositive () const |
| Positive is True only if interval entirely positive. | |
| int | isNegative () const |
| isNegative is True only if interval entirely negative. | |
| int | isNonnegative () const |
| isNonnegative is True only if interval entirely positive. | |
| int | isNonpositive () const |
| isNonpositive is True only if interval entirely negative. | |
| int | isMixed () const |
| True only if interval has positive and negative elements. | |
Private Member Functions | |
| void | init (Type low, Type high) |
| Convenient initialization routine called by the constructors. | |
Private Attributes | |
| Infinite< Type > | _low |
| Holds smallest value the interval represents. | |
| Infinite< Type > | _high |
| Holds largest value the interval represents. | |
|
||||||||||
|
Default constructor.
Definition at line 82 of file Interval.cpp. References Interval< Type >::init(). Referenced by Interval< Type >::operator-=(), and Interval< Type >::operator/=(). |
|
||||||||||
|
Construct an interval using a single number as low and high.
Definition at line 89 of file Interval.cpp. References Interval< Type >::init(). |
|
||||||||||||||||
|
Construct the interval [low,high].
Definition at line 96 of file Interval.cpp. References Interval< Type >::init(). |
|
|||||||||
|
Return center of interval.
Definition at line 171 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by Segment::grad(), Interval< Type >::operator Type(), and Segment::proc(). |
|
|||||||||
|
Checks if low < high.
Definition at line 142 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::error(). Referenced by IDinf(), Interval< Type >::init(), Interval< Type >::operator *=(), Interval< Type >::operator+=(), and Interval< Type >::setInterval(). |
|
||||||||||
|
Contains is True if a is a subset of me.
Definition at line 522 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by IDinf(), and Interval< Type >::isZero(). |
|
||||||||||
|
ContainsProper is True if a is a proper subset of me.
Definition at line 529 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
|||||||||
|
Cubes the interval.
Definition at line 202 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
||||||||||
|
Disjoint is True if a does not intersect me.
Definition at line 543 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
|||||||||
|
Error function can be called when low > high.
Definition at line 135 of file Interval.cpp. Referenced by Interval< Type >::check(). |
|
|||||||||
|
Return e to the interval power.
Definition at line 181 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by Blinn::kernel(), and Interval< Type >::pow(). |
|
|||||||||
|
Returns absolute value of interval.
Definition at line 358 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, and IABS_MAX. |
|
||||||||||
|
Returns largest value the interval represents.
Definition at line 110 of file Interval.cpp. References Interval< Type >::_high. Referenced by IDinf(), Interval< Type >::operator/=(), operator>(), operator>=(), and Interval< Type >::pow(). |
|
||||||||||||||||
|
Convenient initialization routine called by the constructors.
Definition at line 69 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::check(), and findEta(). Referenced by Interval< Type >::Interval(). |
|
||||||||||
|
Intesection of intervals.
Definition at line 368 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
|||||||||
|
True only if interval has positive and negative elements.
Definition at line 580 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by IDinf(), and Interval< Type >::operator/=(). |
|
|||||||||
|
isNegative is True only if interval entirely negative.
Definition at line 557 of file Interval.cpp. References Interval< Type >::_high. Referenced by IDinf(), NewtonDegenerate::NewtonSubdivisionBreak(), Interval< Type >::pow(), and Interval< Type >::squared(). |
|
|||||||||
|
isNonnegative is True only if interval entirely positive.
Definition at line 564 of file Interval.cpp. References Interval< Type >::_low. Referenced by Interval< Type >::pow(), Interval< Type >::sqrt(), and Interval< Type >::squared(). |
|
|||||||||
|
isNonpositive is True only if interval entirely negative.
Definition at line 571 of file Interval.cpp. References Interval< Type >::_high. |
|
|||||||||
|
Positive is True only if interval entirely positive.
Definition at line 550 of file Interval.cpp. References Interval< Type >::_low. Referenced by IDinf(), and NewtonDegenerate::NewtonSubdivisionBreak(). |
|
|||||||||
|
Checks if the interval is pretty much [0,0].
Definition at line 157 of file Interval.cpp. References Interval< Type >::contains(), and Interval< Type >::thin(). Referenced by Sphere::grad(), and Sphere::hess(). |
|
|||||||||
|
Returns the natural log (ln) of the interval.
Definition at line 214 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, ROUNDDOWN, ROUNDUP, and Interval< Type >::setInterval(). Referenced by Interval< Type >::pow(). |
|
||||||||||
|
Returns smallest value the interval represents.
Definition at line 103 of file Interval.cpp. References Interval< Type >::_low. Referenced by IDinf(), Interval< Type >::operator/=(), operator==(), operator>(), operator>=(), and Interval< Type >::pow(). |
|
||||||||||
|
Multiply a base Type times me - promotes Type to Interval.
Definition at line 494 of file Interval.cpp. |
|
||||||||||
|
Multiply interval times me.
Definition at line 415 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check(). |
|
|||||||||
|
Type conversion.
Definition at line 97 of file Interval.h. References Interval< Type >::center(). |
|
||||||||||
|
Add a basic Type to me - promotes Type to Interval.
Definition at line 394 of file Interval.cpp. |
|
||||||||||
|
Add interval to me.
Definition at line 382 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check(). |
|
|||||||||
|
Negates the interval (unary negation).
Definition at line 349 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
||||||||||
|
Subtract a base Type from me - promotes Type to Interval.
Definition at line 408 of file Interval.cpp. References Interval< Type >::Interval(). |
|
||||||||||
|
Subtract interval from me.
Definition at line 401 of file Interval.cpp. |
|
||||||||||
|
Divide me by a base Type - promotes base Type to Interval.
Definition at line 515 of file Interval.cpp. References Interval< Type >::Interval(). |
|
||||||||||
|
Divide me by interval. Bombs out if b.low() or b.high() NearZero, use IDinf instead. Definition at line 503 of file Interval.cpp. References Interval< Type >::high(), Interval< Type >::isMixed(), and Interval< Type >::low(). |
|
||||||||||
|
Overlaps is True if a intersects me.
Definition at line 536 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by AUnion::indomain(), and operator==(). |
|
||||||||||
|
Integer exponents Determines if i is even or odd, and returns a tight interval in either case.
Definition at line 287 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNegative(), and Interval< Type >::isNonnegative(). |
|
||||||||||
|
Raises an interval to the power of another interval.
Definition at line 237 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::exp(), Interval< Type >::high(), Interval< Type >::log(), Interval< Type >::low(), Infinite< Type >::max(), and Interval< Type >::setInterval(). Referenced by RFunction::h(), Sphere::hess(), RFunction::hf(), RFunction::hff(), RFunction::hfg(), RFunction::hg(), and RFunction::hgg(). |
|
|||||||||
|
Basic print out of the interval.
Definition at line 128 of file Interval.cpp. |
|
||||||||||||||||
|
Sets the interval to [l,h].
Definition at line 117 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check(). Referenced by Interval< Type >::log(), Interval< Type >::pow(), and Interval< Type >::sqrt(). |
|
|||||||||
|
Square root of a non-negative interval.
Definition at line 333 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNonnegative(), and Interval< Type >::setInterval(). Referenced by Sphere::grad(), Sphere::hess(), Box< Float >::length(), and Segment::proc(). |
|
|||||||||
|
Squares the interval. Returns either endpoint or the apex of parabola.
Definition at line 188 of file Interval.cpp. References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNegative(), and Interval< Type >::isNonnegative(). Referenced by RFunction::h(), ASubtraction::h(), AIntersection::h(), RFunction::hf(), ASubtraction::hf(), AIntersection::hf(), RFunction::hff(), ASubtraction::hff(), AIntersection::hff(), RFunction::hfg(), RFunction::hg(), ASubtraction::hg(), AIntersection::hg(), RFunction::hgg(), ASubtraction::hgg(), and AIntersection::hgg(). |
|
|||||||||
|
Checks if interval is zero width.
Definition at line 150 of file Interval.cpp. References Interval< Type >::width(). Referenced by Interval< Type >::isZero(), and operator==(). |
|
||||||||||
|
Union of intervals = smallest interval containing both intervals.
Definition at line 375 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. |
|
|||||||||
|
Return width of interval.
Definition at line 164 of file Interval.cpp. References Interval< Type >::_high, and Interval< Type >::_low. Referenced by Interval< Type >::thin(). |
|
|||||
|
|||||
1.3.4