Teuchos - Trilinos Tools Package
Version of the Day
|
Subregion Index Range Class. More...
#include <Teuchos_Range1D.hpp>
Public Types | |
enum | EInvalidRange |
typedef Teuchos_Ordinal | Index |
Deprecated. More... | |
typedef Teuchos_Ordinal | Ordinal |
Deprecated. More... | |
Public Member Functions | |
Range1D () | |
Construct a full range. More... | |
Range1D (EInvalidRange) | |
Constructs an invalid range. More... | |
Range1D (Ordinal lbound, Ordinal ubound) | |
Construct a finite range [lbound, ubound] . More... | |
bool | full_range () const |
Returns true if the range represents the entire region. More... | |
Ordinal | lbound () const |
Return lower bound of the range. More... | |
Ordinal | ubound () const |
Return upper bound of the range. More... | |
Ordinal | size () const |
Return the size of the range (ubound() - lbound() + 1 ) More... | |
bool | in_range (Ordinal i) const |
Return true if the index is in range. More... | |
Range1D & | operator+= (Ordinal incr) |
Increment the range by a constant. More... | |
Range1D & | operator-= (Ordinal incr) |
Deincrement the range by a constant. More... | |
Static Public Attributes | |
static const Range1D | Invalid |
Used for Range1D(INVALID) More... | |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const Range1D &rng1, const Range1D &rng2) |
rng1 == rng2. More... | |
bool | operator!= (const Range1D &rng1, const Range1D &rng2) |
rng1 == rng2. More... | |
Range1D | operator+ (const Range1D &rng_rhs, Range1D::Ordinal i) |
rng_lhs = rng_rhs + i. More... | |
Range1D | operator+ (Range1D::Ordinal i, const Range1D &rng_rhs) |
rng_lhs = i + rng_rhs. More... | |
Range1D | operator- (const Range1D &rng_rhs, Range1D::Ordinal i) |
rng_lhs = rng_rhs - i. More... | |
Range1D | full_range (const Range1D &rng, Range1D::Ordinal lbound, Range1D::Ordinal ubound) |
Return a bounded index range from a potentially unbounded index range. More... | |
TEUCHOSCORE_LIB_DLL_EXPORT std::ostream & | operator<< (std::ostream &out, const Range1D &rng) |
Print out to ostream. More... | |
Subregion Index Range Class.
The class Range1D
encapsulates a 1-D, zero-based, range of non-negative indexes. It is used to index into vectors and matrices and return subregions of them respectively.
Constructing using Range1D()
yields a range that represents the entire dimension of an object [0, max_ubound]
(an entire std::vector, all the rows in a matrix, or all the columns in a matrix etc.).
Constructing using Range1D(INVALID)
yields an invalid range [0,-2]
with size() == -1
. Once constructed with Range1D(INVALID)
, a Range1D
object can pass through many other operations that may change lbound()
and ubound()
but will never change size()==-1
.
Constructing using Range1D(lbound,ubound)
yields a finite-dimensional zero-based range. The validity of constructed range will only be checked if TEUCHOS_DEBUG
is defined.
There are many non-member functions that can be used with Range1D
objects.
The default copy constructor and assignment operator functions are allowed since they have the correct semantics.
Definition at line 56 of file Teuchos_Range1D.hpp.
typedef Teuchos_Ordinal Teuchos::Range1D::Index |
Deprecated.
Definition at line 60 of file Teuchos_Range1D.hpp.
typedef Teuchos_Ordinal Teuchos::Range1D::Ordinal |
Deprecated.
Definition at line 63 of file Teuchos_Range1D.hpp.
Definition at line 66 of file Teuchos_Range1D.hpp.
|
inline |
Construct a full range.
Postconditions:
this->full_range()==true
this->size()
is a very large number this->lbound()==0
this->ubound()
is a very large number Definition at line 256 of file Teuchos_Range1D.hpp.
|
inline |
Constructs an invalid range.
Postconditions:
this->full_range() == false
this->size() == -1
this->lbound()==0
this->ubound()==-2
Definition at line 261 of file Teuchos_Range1D.hpp.
Construct a finite range [lbound, ubound]
.
Preconditions:
lbound >= 0
(throw out_of_range
) ubound >= lbound-1
(throw out_of_range
) Postconditions:
this->full_range() == false
this->size() == ubound - lbound + 1
this->lbound() == lbound
this->ubound() == ubound
ubound == lbound-1
which yields a zero-sized range. There are use cases where this is useful so it is allowed. Definition at line 267 of file Teuchos_Range1D.hpp.
|
inline |
Returns true
if the range represents the entire region.
Definition at line 274 of file Teuchos_Range1D.hpp.
|
inline |
Return lower bound of the range.
Definition at line 279 of file Teuchos_Range1D.hpp.
|
inline |
Return upper bound of the range.
Definition at line 284 of file Teuchos_Range1D.hpp.
|
inline |
Return the size of the range (ubound() - lbound() + 1
)
Definition at line 289 of file Teuchos_Range1D.hpp.
|
inline |
Return true if the index is in range.
Definition at line 294 of file Teuchos_Range1D.hpp.
Increment the range by a constant.
this->lbound() + incr >= 0
(throws out_of_range
)
Definition at line 299 of file Teuchos_Range1D.hpp.
Deincrement the range by a constant.
this->lbound() - incr >= 0
(throws out_of_range
)
Definition at line 307 of file Teuchos_Range1D.hpp.
rng1 == rng2.
rng1.lbound() == rng2.ubound() && rng1.ubound() == rng2.ubound()
. Definition at line 156 of file Teuchos_Range1D.hpp.
rng1 == rng2.
rng1.lbound() == rng2.ubound() && rng1.ubound() == rng2.ubound()
. Definition at line 168 of file Teuchos_Range1D.hpp.
|
related |
rng_lhs = rng_rhs + i.
Increments the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == rng_rhs.lbound() + i
rng_lhs.ubound() == rng_rhs.ubound() + i
Definition at line 185 of file Teuchos_Range1D.hpp.
|
related |
rng_lhs = i + rng_rhs.
Increments the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == i + rng_rhs.lbound()
rng_lhs.ubound() == i + rng_rhs.ubound()
Definition at line 202 of file Teuchos_Range1D.hpp.
|
related |
rng_lhs = rng_rhs - i.
Deincrements the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == rng_rhs.lbound() - i
rng_lhs.ubound() == rng_rhs.ubound() - i
Definition at line 219 of file Teuchos_Range1D.hpp.
|
related |
Return a bounded index range from a potentially unbounded index range.
Return a index range of lbound to ubound if rng.full_range() == true , otherwise just return a copy of rng.
Postconditions:
rng.full_range() == true
] return.lbound() == lbound
rng.full_range() == true
] return.ubound() == ubound
rng.full_range() == false
] return.lbound() == rng.lbound()
rng.full_range() == false
] return.ubound() == rng.ubound()
Definition at line 240 of file Teuchos_Range1D.hpp.
|
related |
Print out to ostream.
|
static |
Used for Range1D(INVALID)
Definition at line 69 of file Teuchos_Range1D.hpp.