SPAinterval
List of: Classes
Subjects: Mathematics
Contents: Base

Purpose: Records an interval on a line.

Derivation: SPAinterval : ACIS_OBJECT : -

Filename: base/baseutil/vector/interval.hxx

Description: This class records an interval on the real line, i.e., a one dimensional region. It is implemented as an ordered pair of reals, together with a flag that indicates whether each end is bounded or not. This allows the representation and manipulation of finite, infinite, semi-infinite, and empty intervals. The boundary value at an unbounded end is irrelevant.

References: by BASE SPAbox, SPApar_box

Constructor: public: SPAinterval::SPAinterval ();


C++ allocation constructor requests memory for this object but does not populate it.






public: SPAinterval::SPAinterval (


double d // double value


);


C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.


Constructs a zero-length interval from one double value.






public: SPAinterval::SPAinterval (


double, // double value


double // double value


);


C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.


Constructs an interval from two values. The arguments do not need to be in ascending sequence. The constructor checks and adjusts the argument sequence.






public: SPAinterval::SPAinterval (


interval_type,
// interval type


double const&
// double value



= * (double* ) NULL_REF,


double const&
// double value



= * (double* ) NULL_REF


);


C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.


Constructs a bounded or unbounded interval from a describer and up to two values. If the given interval type is interval_unknown, the type derives from the presence or absence of the real arguments (absence means infinite at the appropriate end); otherwise, the type is as given. Any required bound is taken from the arguments. If there are two real arguments, they are low/high. If there is one real argument, it is used for both ends.



Methods: public: logical SPAinterval::bounded () const;


Determines if an interval is bounded above and below.






public: logical SPAinterval::bounded_above () const;


Determines if an interval is bounded above.






public: logical SPAinterval::bounded_below () const;


Determines if an interval is bounded below.






public: void SPAinterval::debug (


FILE* // file name



= debug_file_ptr


) const;


Outputs the details of an interval to the debug file or to the specified file.






public: void SPAinterval::debug_str (


char* // string


) const;


Concatenates the value of interval to the passed string.






public: logical SPAinterval::empty () const;


Determines if an interval is empty.






public: double SPAinterval::end_pt () const;


Returns the end point of the interval. This method is only meaningful if the relevant ends are bounded; if the upper end is not bounded, there is no error.






public: logical SPAinterval::finite () const;


Determines if an interval is finite.






public: logical SPAinterval::finite_above () const;


Determines if an interval is finite above.






public: logical SPAinterval::finite_below () const;


Determines if an interval is finite below.






public: logical SPAinterval::infinite () const;


Determines if an interval is infinite.






public: double SPAinterval::interpolate (


double // double value


) const;


Interpolate within the interval. This method returns:


(1 - parameter) * low-end + parameter * high-end


for the given parameter. This method is only meaningful if the relevant ends are bounded; if the relevant ends are not bounded, there is no error.






public: double SPAinterval::length () const;


Returns the difference between the high and low ends of the interval. By historical convention, both empty and infinite return negative values (since formerly an infinite parameter range returned empty), so this is retained. For convenient distinction, empty returns exactly -1.0, and infinite (or semi-infinite) returns exactly -2.0.






public: double SPAinterval::mid_pt () const;


Returns the middle point of the interval. This method is only meaningful if the relevant ends are bounded; if the relevant ends are not bounded, there is no error.






public: SPAinterval& SPAinterval::negate ();


Negates an interval in place.






public: SPAinterval& SPAinterval::operator&= (


SPAinterval const& // interval


);


Finds the interval of overlap (the intersection of the two intervals).






public: SPAinterval& SPAinterval::operator*= (


double // double value


);


Multiplies an interval by a scalar (it multiplies both end values by a scalar value).






public: SPAinterval& SPAinterval::operator+= (


double d // double value


);


Adds a scalar value to both ends of an interval, shifting the interval by the value.






public: SPAinterval& SPAinterval::operator+= (


SPAinterval const& // interval


);


Adds two intervals together.






public: SPAinterval& SPAinterval::operator-= (


double d // double value


);


Subtracts a scalar value from both ends of an interval, shifting the interval by the value.






public: SPAinterval& SPAinterval::operator-= (


SPAinterval const& // interval


);


Subtracts an interface from an interval.






public: logical SPAinterval::operator<< (


SPAinterval const& i // interval


) const;


Inverses the given interval. Determine whether an interval is entirely enclosed within another interval. The given method returns TRUE if this interval is NULL, FALSE if this interval is NULL; otherwise, it returns TRUE if low end of this interval exceeds low end of this interval (less SPAresabs) and high end of this interval is less than high end of this interval (plus SPAresabs).






public: SPAinterval& SPAinterval::operator/= (


double // double value


);


Divides an interval (end value) by a scalar (value).






public: logical SPAinterval::operator>> (


double // point


) const;


Determines whether a point lies within an interval. This method returns TRUE if this interval is NULL or if given value lies within this interval (expanded by SPAresabs at each end).






public: logical SPAinterval::operator>> (


SPAinterval const& // interval


) const;


Determine whether an interval is entirely enclosed within another interval. This method returns TRUE if this interval is NULL, FALSE if given interval is NULL; otherwise, it returns TRUE if low end of given interval exceeds low end of this interval (less SPAresabs) and high end of given interval is less than high end of this interval (plus SPAresabs).






public: SPAinterval& SPAinterval::operator|= (


SPAinterval const& // interval


);


Constructs an interval containing two intervals (returns the union of both intervals).






public: logical SPAinterval::scalar () const;


Determine if the interval is a scalar (consisting of a single point).






public: double SPAinterval::start_pt () const;


Returns the start point of the interval. This method is only meaningful if the relevant ends are bounded; if the lower end is not bounded, there is no error.






public: interval_type SPAinterval::type () const;


Returns the type of interval_type.






public: logical SPAinterval::unbounded () const;


Determines if an interval is unbounded (not a finite interval).






public: logical SPAinterval::unbounded_above () const;


Determines if an interval is unbounded above.






public: logical SPAinterval::unbounded_below () const;


Determines if an interval is unbounded below.






friend: SPAinterval operator& (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Finds the interval of overlap.






friend: SPAinterval operator/ (


SPAinterval const&, // interval


double // scalar value


);


Divide an interval by a scalar.






friend: SPAinterval operator* (


double, // scalar value


SPAinterval const& // interval


);


Multiply a scalar by an interval.






friend: SPAinterval operator* (


SPAinterval const&, // interval


double // scalar value


);


Multiply an interval by a scalar.






friend: SPAinterval operator+ (


double d, // double


SPAinterval const& i // interval


);


Add a double and an interval.






friend: SPAinterval operator+ (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Add two intervals together.






friend: SPAinterval operator+ (


SPAinterval const& i, // interval


double d // double


);


Add an interval and a double.






friend: SPAinterval operator- (


double d, // double


SPAinterval const& i // interval


);


Subtract an interval from a double.






friend: SPAinterval operator- (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Subtract two intervals.






friend: SPAinterval operator- (


SPAinterval const& i, // interval


double d // double


);


Subtract a double from an interval.






friend: SPAinterval operator- (


SPAinterval const& // interval


);


Negates an interval.






friend: SPAinterval operator| (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Construct an interval containing two intervals.






friend: logical operator!= (


SPAinterval const& i1, // interval


SPAinterval const& i2 // interval


);


Equality operator for determining whether two intervals are identical. The criteria are strict, so this operator should not be used when arithmetic equality is intended.






friend: logical operator&& (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Determine whether two intervals overlap. We test with respect to SPAresabs, to accommodate touching cases.






friend: logical operator< (


double d, // double


SPAinterval const& i // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator< (


SPAinterval const& i, // interval


double d // double


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator< (


SPAinterval const& i1, // interval


SPAinterval const& i2 // double


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator<< (


double r, // value


SPAinterval const& i // interval


);


Inverse of operator>> function.






friend: logical operator<= (


double d, // double


SPAinterval const& i // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator<= (


SPAinterval const& i, // interval


double d // double


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator<= (


SPAinterval const& i1, // interval


SPAinterval const& i2 // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator== (


SPAinterval const&, // interval


SPAinterval const& // interval


);


Equality operator for determining whether two intervals are identical. The criteria are strict, so this operator should not be used when arithmetic equality is intended.






friend: logical operator> (


double d, // double


SPAinterval const& i // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator> (


SPAinterval const& i, // interval


double d // double


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator> (


SPAinterval const& i1, // interval


SPAinterval const& i2 // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator>= (


double d, // double


SPAinterval const& i // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator>= (


SPAinterval const& i, // interval


double d // double


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.






friend: logical operator>= (


SPAinterval const& i1, // interval


SPAinterval const& i2 // interval


);


Arithmetic comparison. The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.
PDF/BASE/03CL.PDF
HTM/DATA/BASE/BASE/03CL/0010.HTM