Module: Essential Math Group: Math Collection classes
Does not inherit
#include <rw/math/mathvec.h> RWMathVec<double> x(20); cout << x(RWToEnd(4)); // output elements 4 to last
An RWToEnd object is an index which can be used for subscripting vectors, matrices, and arrays from a given element to the end. By subscripting with RWToEnd objects, you create views of selected elements. These new views are vectors, matrices, or arrays in their own right, rather than simply helper classes. This means that a view created with subscripting can be used as an rvalue, an lvalue, or kept as an object for use later. To create objects which do not share data, use the copy() or deepenShallowCopy() member functions.
The class RWToEnd is derived from RWSlice. It can be used to initialize an RWSlice object as follows:
RWSlice s = RWToEnd(3);
#include <iostream.h> #include <rw/math/genmat.h> int main() { RWGenMat<int> A(6,6); A = 0; RWToEnd I(3); // indices 3,4,5 A(I,I) = 1; cout << A << endl; }
Program output:
6x6 [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 ]
RWToEnd(int begin) RWToEnd(int begin, int stride)
Constructs an object which indexes starting at element begin and ending with the last element. The optional stride is the increment between successive selected elements.
RWRange, RWSlice, and the subscripting operator()() member operators of the vector, matrix, and array classes.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.