Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Friends | Related Functions

Fiber::MultiIndex< Dims > Class Template Reference
[Multidimensional Arrays with Flexible Data Layout and On-Demand Slice Creation]

A recursively defined multidimensional index. More...

#include <MultiIndex.hpp>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions

Static Protected Member Functions

Friends

Related Functions

(Note that these are not member functions.)


Detailed Description

template<int Dims>
class Fiber::MultiIndex< Dims >

A recursively defined multidimensional index.

The base class corresponds to the lowest dimension, each new child class adds a new dimension.

A MultiIndex ("multidimensional Index") can be: A Type Product between two Indices An Index with Dimensionator

Examples:

InterpolatedDerivative.cpp, and Interpolation.cpp.


Member Enumeration Documentation

template<int Dims>
anonymous enum
Enumerator:
dims 

The dimension of this multidimensional index.

SIZE 

Export an SIZE enum for treatment like an FixedArray.


Constructor & Destructor Documentation

template<int Dims>
Fiber::MultiIndex< Dims >::MultiIndex ( const MultiIndex< Dims-1 > &  m,
const index_t &  Slice,
int  SliceDirection 
) [inline]

Multidimensional index as product of subdimension and index for a given slice dimension (create global index from hyperslab index).

Todo:
Optimize this to peform recursive construction!
template<int Dims>
Fiber::MultiIndex< Dims >::MultiIndex ( const index_t &  lin_idx,
const MultiIndex< Dims > &  Dimens,
const CreateFromLinear  
) throw () [inline]

Create multidimensional index from one-dimensional index, given the multidimensional dimension on where this index shall count through.

This is the inverse operation to the linear() member function.

Test code:

        {
        MultiIndex<3> Number = MIndex(11, 17, 23); 

                for(index_t I = 11; I<331; I+=29)
                {
                MultiIndex<3> I3(I, Number); 
                index_t Irec = I3.linear( Number );

                        cout << "Index " << I << " with I[0]=" << I3[0] << " is " << I3 << " was " << Irec << endl;
                }
        }

Member Function Documentation

template<int Dims>
static MultiIndex Fiber::MultiIndex< Dims >::Axis ( unsigned int  orientation  )  throw () [inline, static]

Return a MultiIndex that points just in the given orientation.

It is given by

           BitIndex( 1<< orientation )

with orientation < Dims . The inverse operation is the Orientation() member function.

Referenced by Fiber::MultiIndex< 3 >::operator+().

template<int Dims>
index_t Fiber::MultiIndex< Dims >::BitIndex (  )  const throw () [inline]

From this given multiindex which is supposed to have index values of either 0 or 1 in each direction, return the corresponding binary pattern that creates this multiindex.

           cout << "Check bit indices, all corners of a cube: " << endl;
           for(unsigned i=0; i<8; i++)
           {
                cout << i << " --> " << MultiIndex<3>::BitIndex( i )  
                     << " --> " << MultiIndex<3>::BitIndex( i ).BitIndex()
                     << endl;
           }

Referenced by Fiber::MultiIndex< 3 >::Axis(), and Fiber::MultiIndex< 3 >::Orientation().

template<int Dims>
static MultiIndex Fiber::MultiIndex< Dims >::BitIndex ( unsigned int  bits  )  throw () [inline, static]

Multidimensional bit indices, that are zero or one in each of the directions as specified by the bits.

It can be computed to compute the corners of an n-dimensional hypercube or the direction of the n-th axis.

        cout << "Check bit indices, all corners of a cube: " << endl;
        for(unsigned i=0; i<8; i++)
        {
                cout << i << " --> " << MultiIndex<3>::BitIndex( i ) << endl;
        }

        cout << "Check bit indices, all axis of a cube: " << endl;
        for(unsigned i=0; i<3; i++)
        {
                cout << i << " --> " << MultiIndex<3>::BitIndex( 1<<i ) << endl;
        }
template<int Dims>
int Fiber::MultiIndex< Dims >::getSignedOrientation ( const MultiIndex< Dims > &  B  )  const [inline]

Returns the dimension, starting with 1, in which this multidimensional index is non-zero.

The result will be negative if the specified index is smaller than the current one, and zero, if both indices are identical. If there is more than one non-zero index, then it will return the highest dimension where an index difference is found.

template<int Dims>
bool Fiber::MultiIndex< Dims >::inc ( const MultiIndex< Dims > &  Dimens,
const MultiIndex< Dims > &  Increment 
) throw () [inline]

Increment the current index by a certain increment.

If it is larger than the extent a given in the Dimensions parameter, the certain index is reset to zero in this dimension and the next dimension is increased.

template<int Dims>
index_t Fiber::MultiIndex< Dims >::linear ( const MultiIndex< Dims > &  Dimens  )  const throw () [inline]

Compute the linear index from the given dimensionator.

Todo:
Optimize the implemented formula.

Referenced by Fiber::MultiIndex< 3 >::BitIndex().

template<int Dims>
MultiIndex Fiber::MultiIndex< Dims >::operator+ ( int  i  )  const [inline]

Shortcut operator to compute the MultiIndex that is just one step aside in the direction as specified by the integer.

Adding 0 yields the original vector, adding +1 moves one element forward in the first axis, adding -1 moves one element backward along the first axis, etc. . The idea stems from Massimo Pierro's FermiQCD package.

template<int Dims>
const index_t& Fiber::MultiIndex< Dims >::operator[] ( int  i  )  const [inline]

Indexing operator to access values for each dimension.

The current class member's index corresponds to the highest dimension, the base class to the lowest dimension.

template<int Dims>
index_t Fiber::MultiIndex< Dims >::Orientation (  )  const throw () [inline]

Given a MultiIndex that only contains one element of value 1, all others being zero (such as one created by the Axis() function), return the orientation that creates this.

        cout << "Check bit indices, all axis of a cube: " << endl;
        for(unsigned i=0; i<3; i++)
        {
                cout << i << " --> " << MultiIndex<3>::BitIndex( 1<<i )
                     << " --> " << MultiIndex<3>::BitIndex( 1<<i ).Orientation()
                     << endl;
        } 
Note:
If more than one index is defined, then the orientation of the highest one will be returned. If there are values other than one or zero, the result is undefined.