cgv
|
The interval template represents a closed interval of two numbers, i.e. More...
#include <interval.h>
Public Member Functions | |
interval operations | |
interval () | |
construct empty interval | |
interval (bool) | |
Construct interval over all valid values of the value type, where the parameter is only a dummy to distinguish this constructor from the standard constructor. | |
interval (const interval< T > &I) | |
copy constructor | |
interval (const T &lb, const T &ub) | |
Contruct interval from bounds, sort bounds if necessary. To construct empty interval call the standard constructor. | |
bool | empty () const |
check if interval is empty | |
void | clear () |
set to empty interval | |
bool | contains (const T &v) const |
check if given value is contained in interval | |
T | center () const |
return the center value, which is only valid if the interval is not empty | |
T | size () const |
return the size of the interval | |
interval< T > & | intersect (const interval< T > &I) |
set interval to intersection with given interval and return reference to this interval | |
interval< T > | intersection (const interval< T > &I) const |
return intersection interval | |
interval< T > & | extend (const T &v) |
extend interval such that it includes the given value | |
interval< T > & | extend (const T vs[], size_t n) |
extend interval such that it includes the n given values | |
interval< T > & | extend (const std::vector< T > &vs) |
extend interval such that it includes the given values | |
interval< T > & | extension (const T &v) |
return extension of interval so that it includes the given value | |
interval< T > & | extend (const interval< T > &I) |
extend interval such that it includes the given interval | |
interval< T > & | extension (const interval< T > &J) |
return extension of interval so that it includes the given interval | |
scalar operators | |
interval< T > & | operator*= (const T &s) |
scale the interval | |
interval< T > | operator* (const T &s) const |
return scaled interval | |
interval< T > & | operator/= (const T &s) |
divide the interval | |
interval< T > | operator/ (const T &s) const |
return divided interval | |
interval< T > & | operator+= (const T &s) |
right shift interval by adding scalar to both bounds | |
interval< T > | operator+ (const T &s) const |
return right shifted interval | |
interval< T > & | operator-= (const T &s) |
left shift interval by subtracting scalar from both bounds | |
interval< T > | operator- (const T &s) const |
return left shifted interval | |
interval operators | |
interval< T > & | operator*= (const interval< T > &I) |
compute the interval of all values of all products of values from the two intervals | |
interval< T > | operator* (const interval< T > &J) const |
return the interval of all values of products of values from the two intervals | |
interval< T > & | operator/= (const interval< T > &I) |
Compute the interval of all values of all quotients of values from the two intervals. | |
interval< T > | operator/ (const interval< T > &J) const |
return the interval of all values of quotients of values from the two intervals. See also comments on the /= operator(). | |
interval< T > | operator- () const |
unary minus operator reflects interval at zero value | |
interval< T > & | operator+= (const interval< T > &I) |
compute interval of all sums of values from the two intervals | |
interval< T > | operator+ (const interval< T > &J) const |
return interval of all sums of values from the two intervals | |
interval< T > & | operator-= (const interval< T > &I) |
compute interval of all differences of values from the two intervals | |
interval< T > | operator- (const interval< T > &J) const |
return interval of all differences of values from the two intervals | |
comparison operators | |
bool | operator== (const interval< T > &I) const |
check for equality of two intervals | |
bool | operator!= (const interval< T > &I) const |
check for inequality of two intervals | |
bool | operator< (const interval< T > &I) const |
only returns true if both intervals are not empty and the operator holds for all values in both intervals | |
bool | operator> (const interval< T > &I) const |
only returns true if both intervals are not empty and the operator holds for all values in both intervals | |
Public Attributes | |
T | lower_bound |
T | upper_bound |
The interval template represents a closed interval of two numbers, i.e.
[a,b]. All arithmetic operators are overloaded for the interval template. This allows to compute bounds for an arbitrary expression. For example if the variable x is from the interval [-1,1] then the expression x*x is from the interval [0,1], which can be computed via \codebegin interval<int> x(-1,1); interval<int> e = x*x; std::cout << e << std::endl; \codeend Furthermore, the interval template supports further interval based operations like intersection and extension of an interval.
Definition at line 26 of file interval.h.
|
inline |
construct empty interval
Definition at line 37 of file interval.h.
|
inline |
Construct interval over all valid values of the value type, where the parameter is only a dummy to distinguish this constructor from the standard constructor.
This constructor relies on cgv::type::traits::min and cgv::type::traits::max. Thus if you want to build intervals over non standard types, you need to ensure that these two traits are instantiated for your type when using this constructor.
Definition at line 43 of file interval.h.
|
inline |
copy constructor
Definition at line 45 of file interval.h.
|
inline |
Contruct interval from bounds, sort bounds if necessary. To construct empty interval call the standard constructor.
Definition at line 47 of file interval.h.
|
inline |
return the center value, which is only valid if the interval is not empty
Definition at line 55 of file interval.h.
|
inline |
set to empty interval
Definition at line 51 of file interval.h.
|
inline |
check if given value is contained in interval
Definition at line 53 of file interval.h.
Referenced by cgv::math::interval< T >::operator/=().
|
inline |
check if interval is empty
Definition at line 49 of file interval.h.
Referenced by cgv::math::interval< T >::extend(), cgv::math::interval< T >::extend(), cgv::math::interval< T >::operator*=(), cgv::math::interval< T >::operator+=(), cgv::math::interval< T >::operator-(), cgv::math::interval< T >::operator/=(), cgv::math::interval< T >::operator<(), cgv::math::interval< T >::operator==(), cgv::math::interval< T >::operator>(), and cgv::math::interval< T >::size().
|
inline |
extend interval such that it includes the given interval
Definition at line 92 of file interval.h.
References cgv::math::interval< T >::empty(), and cgv::math::interval< T >::extend().
|
inline |
extend interval such that it includes the given values
Definition at line 84 of file interval.h.
References cgv::math::interval< T >::extend().
|
inline |
extend interval such that it includes the given value
Definition at line 67 of file interval.h.
References cgv::math::interval< T >::empty().
Referenced by cgv::math::interval< T >::extend(), cgv::math::interval< T >::extend(), cgv::math::interval< T >::extend(), cgv::math::interval< T >::extension(), cgv::math::interval< T >::extension(), cgv::math::interval< T >::operator*=(), cgv::math::interval< T >::operator+=(), and cgv::math::interval< T >::operator/=().
|
inline |
extend interval such that it includes the n given values
Definition at line 78 of file interval.h.
References cgv::math::interval< T >::extend().
|
inline |
return extension of interval so that it includes the given interval
Definition at line 100 of file interval.h.
References cgv::math::interval< T >::extend().
|
inline |
return extension of interval so that it includes the given value
Definition at line 90 of file interval.h.
References cgv::math::interval< T >::extend().
|
inline |
set interval to intersection with given interval and return reference to this interval
Definition at line 59 of file interval.h.
Referenced by cgv::math::interval< T >::intersection().
|
inline |
return intersection interval
Definition at line 65 of file interval.h.
References cgv::math::interval< T >::intersect().
|
inline |
check for inequality of two intervals
Definition at line 181 of file interval.h.
|
inline |
return the interval of all values of products of values from the two intervals
Definition at line 134 of file interval.h.
|
inline |
return scaled interval
Definition at line 107 of file interval.h.
|
inline |
compute the interval of all values of all products of values from the two intervals
Definition at line 125 of file interval.h.
References cgv::math::interval< T >::empty(), and cgv::math::interval< T >::extend().
|
inline |
scale the interval
Definition at line 105 of file interval.h.
|
inline |
return interval of all sums of values from the two intervals
Definition at line 166 of file interval.h.
|
inline |
return right shifted interval
Definition at line 115 of file interval.h.
|
inline |
compute interval of all sums of values from the two intervals
Definition at line 156 of file interval.h.
References cgv::math::interval< T >::empty(), and cgv::math::interval< T >::extend().
|
inline |
right shift interval by adding scalar to both bounds
Definition at line 113 of file interval.h.
|
inline |
unary minus operator reflects interval at zero value
Definition at line 154 of file interval.h.
References cgv::math::interval< T >::empty().
|
inline |
return interval of all differences of values from the two intervals
Definition at line 170 of file interval.h.
|
inline |
return left shifted interval
Definition at line 119 of file interval.h.
|
inline |
compute interval of all differences of values from the two intervals
Definition at line 168 of file interval.h.
|
inline |
left shift interval by subtracting scalar from both bounds
Definition at line 117 of file interval.h.
|
inline |
return the interval of all values of quotients of values from the two intervals. See also comments on the /= operator().
Definition at line 152 of file interval.h.
|
inline |
return divided interval
Definition at line 111 of file interval.h.
|
inline |
Compute the interval of all values of all quotients of values from the two intervals.
Notice that if zero is contained in the second interval, the result is the complete interval of all valid values and the same precondition holds as for the constructor with the bool dummy parameter interval(bool).
Definition at line 139 of file interval.h.
References cgv::math::interval< T >::contains(), cgv::math::interval< T >::empty(), and cgv::math::interval< T >::extend().
|
inline |
divide the interval
Definition at line 109 of file interval.h.
|
inline |
only returns true if both intervals are not empty and the operator holds for all values in both intervals
Definition at line 185 of file interval.h.
References cgv::math::interval< T >::empty().
|
inline |
check for equality of two intervals
Definition at line 176 of file interval.h.
References cgv::math::interval< T >::empty().
|
inline |
only returns true if both intervals are not empty and the operator holds for all values in both intervals
Definition at line 189 of file interval.h.
References cgv::math::interval< T >::empty().
|
inline |
return the size of the interval
Definition at line 57 of file interval.h.
References cgv::math::interval< T >::empty().
T cgv::math::interval< T >::lower_bound |
Definition at line 30 of file interval.h.
T cgv::math::interval< T >::upper_bound |
Definition at line 32 of file interval.h.