Module: Essential Math Group: Math Collection classes
Does not inherit
#include <rw/math/mtharray.h> /* Any array class will do */ for(RWMultiIndex i(n); i; ++i) { ... } // n is an IntVec
Class RWMultiIndex is an n-dimensional index class. It is a tool for traversing arrays of arbitrary dimension. As shown in the Example below, you can use RWMultiIndex to help you write subroutines that operate on arrays of arbitrary dimension. Using automatic type conversion, you can then call these subroutines with vectors, matrices, or arrays. For instance, you can use the Example subroutine as follows:
RWMathVec<int> v; RWGenMat<int> A; RWMathArray<int> X; . . . int vZeros = numZeros(v); int AZeros = numZeros(A); int XZeros = numZeros(X)
#include <rw/math/mtharray.h> int numZeros(const RWMathArray<int>& X) // Count the number
// of zeros in X { int count=0; for(RWMultiIndex i(X.length()); i; ++i) { if (X(i)==0) ++count; } return count; }
RWMultiIndex(const RWGenMat<int>& n);
Constructs an index to count from 0 to n.
void operator++()
Increments the index.
operator void*()
Returns 0 if the index is no longer valid. An index becomes invalid when it is incremented beyond its limit.
© 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.