SourcePro® C++ API Reference Guide

Product Documentation:
   SourcePro C++
Documentation Home
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Member Functions
RWMultiIndex Class Reference

An n-dimensional index class for traversing arrays of arbitrary dimension. More...

#include <rw/array.h>

Inheritance diagram for RWMultiIndex:
RWMathVec< int > RWVecView RWDataView

Public Member Functions

 RWMultiIndex (const RWIntVec &n)
 
 operator void * ()
 
void operator++ ()
 
- Public Member Functions inherited from RWMathVec< int >
 RWMathVec (size_t n, RWRandInterface &r)
 
 RWMathVec ()
 
 RWMathVec (const RWMathVec< int > &a)
 
 RWMathVec (size_t n, RWUninitialized)
 
 RWMathVec (size_t n, const int &initval)
 
 RWMathVec (size_t n, const int &initval, const int &incr)
 
 RWMathVec (const char *s)
 
 RWMathVec (const RWMathVecPick< int > &p)
 
 RWMathVec (const int *dat, size_t n)
 
 RWMathVec (const RWMathVec< double > &re, const RWMathVec< double > &im)
 
RWMathVec< int > apply (typename rw_numeric_traits< int >::mathFunType f) const
 
RWMathVec< norm_typeapply2 (mathFunType2 f) const
  More...
 
iterator begin ()
 
const_iterator begin () const
  More...
 
size_t binaryStoreSize () const
 
const_iterator cbegin () const
  More...
 
const_iterator cend () const
  More...
 
RWMathVec< int > copy () const
 
const_reverse_iterator crbegin () const
  More...
 
const_reverse_iterator crend () const
  More...
 
int * data ()
 
const int * data () const
  More...
 
RWMathVec< int > deepCopy () const
 
void deepenShallowCopy ()
 
iterator end ()
 
const_iterator end () const
  More...
 
size_t length () const
 
 operator RWMathVec< promote_type > ()
 
bool operator!= (const RWMathVec< int > &v) const
 
int & operator() (int i)
 
int operator() (int i) const
 
RWMathVec< int > operator() (const RWSlice &)
 
const RWMathVec< int > operator() (const RWSlice &) const
 
RWMathVec< int > & operator*= (const int &v)
 
RWMathVec< int > & operator*= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator++ ()
 
void operator++ (int)
  More...
 
RWMathVec< int > & operator+= (const int &v)
 
RWMathVec< int > & operator+= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator-- ()
 
void operator-- (int)
  More...
 
RWMathVec< int > & operator-= (const int &v)
 
RWMathVec< int > & operator-= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator/= (const int &v)
 
RWMathVec< int > & operator/= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator= (const RWMathVec< int > &v)
 
RWMathVec< int > & operator= (const RWMathVecPick< int > &v)
  More...
 
RWMathVec< int > & operator= (const int &v)
 
bool operator== (const RWMathVec< int > &) const
 
int & operator[] (int i)
 
int operator[] (int i) const
  More...
 
RWMathVec< int > operator[] (const RWSlice &)
  More...
 
const RWMathVec< int > operator[] (const RWSlice &) const
  More...
 
RWMathVecPick< int > pick (const RWIntVec &v)
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
  More...
 
RWMathVec< int > & reference (const RWMathVec< int > &v)
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
  More...
 
void reshape (size_t n)
 
void resize (size_t n)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
  More...
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
  More...
 
RWMathVec< int > slice (int start, size_t n, int stride=1) const
 
int stride () const
 
- Public Member Functions inherited from RWVecView
size_t length () const
 
int stride () const
 

Additional Inherited Members

- Public Types inherited from RWMathVec< int >
typedef RWMathVecConstIterator
< int > 
const_iterator
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef RWMathVecIterator< int > iterator
 
typedef rw_numeric_traits< int >
::mathFunType 
mathFunType
 
typedef rw_numeric_traits< int >
::mathFunType2 
mathFunType2
 
typedef rw_numeric_traits< int >
::norm_type 
norm_type
 
typedef rw_numeric_traits< int >
::promote_type 
promote_type
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 

Detailed Description

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:

.
.
.
int vZeros = numZeros(v);
int AZeros = numZeros(A);
int XZeros = numZeros(X)

Synopsis

#include <rw/math/mtharray.h> // Any array class will do
for(RWMultiIndex i(n); i; ++i) { ... } // n is an IntVec

Example

#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;
}

Constructor & Destructor Documentation

RWMultiIndex::RWMultiIndex ( const RWIntVec n)

Constructs an index to count from 0 to n.

Member Function Documentation

RWMultiIndex::operator void * ( )
inline

Returns 0 if the index is no longer valid. An index becomes invalid when it is incremented beyond its limit.

void RWMultiIndex::operator++ ( )

Increments the index.

Copyright © 2015 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.
Provide feedback to Rogue Wave about its documentation.