Class CAMrange

(For index range specification)

Include File : access.h (automatically included with cammva.h)


A CAMrange object encapsulates a range of indices.

Chris Anderson © UCLA 8/18/97


Use of CAMrange objects for index range specification

A CAMrange object encapsulates a range of indices. These objects can be arguments to CAMdoubleMatrx, CAMdoubleArray, and CAMdoubleVector constructors and access operators.

There are two ways to create a CAMrange object. One convenient way is to use an underscore "_". Specifically,

 

_(i1, i2) An expression resulting in a CAMrange object with indices from i1 to i2.
_(i1,i2,S) An expression resulting in a CAMrange object with indices from i1 to i2 with stride S.

(The underscore character "_" is the single instance of a CAMunderscore class in which the () operator has been overloaded to return a CAMrange object).

Alternately, one can explicitly declare CAMrange objects, e.g.

CAMrange R(i1, i2); Creates a CAMrange object R with indices from i1 to i2.
CAMrange R(i1, i2, S); Creates a CAMrange object R with indices from i1 to i2 and stride S.



CAMrange Class Reference

Include File : access.h (automatically included with cammva.h)



Constructors

CAMrange() Null constructor.
CAMrange(const CAMrange& A) Copy constructor
CAMrange(long i1, long i2) Creates a CAMrange object that specifies a range of indices from i1 to i2.
CAMrange(long i1, long i2, long S) Creates a CAMrange object that specifies a range of indices from i1 to i2 with stride S.

 Initialization

void initialize() Initializes an existing CAMrange to a null CAMrange.
void initialize(const CAMrange& R) Initializes an existing CAMrange to R.
void initialize(long i1, long i2) Initializes a CAMrange object to one that specifies a range of indices from i1 to i2.
void initialize(long i1, long i2, long S) Initializes a CAMrange object to one that specifies a range of indices from i1 to i2 with stride S.

Operators/Member Functions

= The expression R = S; causes the CAMrange object R values to be set to those of S.
<< The expression cout << R; causes the the values associated with the CAMrange object R to be output to cout. (cout may be replaced by any output stream).
++ Shift by +1. The expression R ++; increments the base and bound index of R by 1.
-- Shift by -1. The expression R -- decrements the base and bound index of R by 1.
+ (long i) Shift by i. The expression R + i ; increments the base and bound index of R by i.
- (long i) Shift by - i. The expression R + i ; decrements the base and bound index of R by i.
long getBase() Returns the base (or beginning) index associated with a CAMrange object.
long getBound() Returns the bound (or ending) index associated with a CAMrange object.
long getCount() Returns the number of elements in the index range.&#9;
long getStride()&#9; Returns the stride associated with a CAMrange object.
long length()  Returns the number of elements in the index range.