Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell

Stop multidimensional indexing recursion. More...

#include <MultiIndex.hpp>

Public Types

enum  

Public Member Functions

constexpr MultiIndex () noexcept
 Default constructor.
constexpr MultiIndex (const Index &I) noexcept
 Initialize highest index.
constexpr MultiIndex (const MultiIndex &Midx, const Index &I) noexcept
 Multidimensional index as product of subdimension and index.
constexpr MultiIndex (const Index &lin_idx, const MultiIndex &Dimens, const CreateFromLinear &)
 Multidimensional Index - a linear Index with Dimensions.
MultiIndexIterator< 1 > begin () const
 Begin a ranged loop.
MultiIndexIterator< 1 > end () const
 End a ranged loop.
constexpr int getSignedOrientation (const MultiIndex &B) const
constexpr const Index & operator[] (int) const noexcept
constexpr Index & operator[] (int) noexcept
constexpr const Index & maxidx () const noexcept
constexpr Index & maxidx () noexcept
constexpr Index size () const noexcept
constexpr MultiIndex & operator+= (const MultiIndex &D) noexcept
constexpr MultiIndex & operator-= (const MultiIndex &D) noexcept
constexpr MultiIndex operator+ (const MultiIndex &D) const noexcept
bool constexpr operator== (const MultiIndex &D) const noexcept
bool constexpr operator!= (const MultiIndex &D) const noexcept
 inequality comparision operator
bool inc (const MultiIndex &Dimens, const MultiIndex &Increment) noexcept
bool inc (const MultiIndex &Dimens) noexcept
Index constexpr linear (const MultiIndex &) const
bool constexpr isWithin (const MultiIndex &Range) const noexcept
index_t Orientation () const noexcept
 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.
constexpr const MultiIndex< Dims-1 > & subidx () const noexcept
 Return associated constant dimensionator of one dimension less.
Eagle::Assignment< MultiIndex, 0 > operator= (const index_t &i)
 Assignment via comma operator.
bool operator< (const MultiIndex &Range) const noexcept
 Check if the current multiindex is smaller than the range.
bool operator> (const MultiIndex &Range) const noexcept
 Check if the current multiindex is larger than the range.
MultiIndex operator- (const MultiIndex &D) const noexcept
 Subtract multidimensional indices.
MultiIndex operator& (int i) const
 Shortcut operator to compute the MultiIndex that is just one step aside in the direction as specified by the integer.

Static Public Member Functions

static int log2 (index_t N) noexcept
template<class Functor, Dims_t SuperDims>
static bool ForEachRecursion (Functor &F, const MultiIndex< SuperDims > &SuperIndex, const MultiIndex &Start, const MultiIndex &End, const MultiIndex &Increment)
static MultiIndex BitIndex (unsigned int bits) noexcept
 Multidimensional bit indices, that are zero or one in each of the directions as specified by the bits.
static MultiIndex Axis (unsigned int orientation) noexcept
 Return a MultiIndex that points just in the given orientation.
static bool ForEach (Functor &F, const MultiIndex &Start, const MultiIndex &End, const MultiIndex &Increment=MultiIndex(1))

Protected Types

using Index = index_t
using value_type = Index

Protected Member Functions

constexpr MultiIndex (const MultiIndex &M, const MultiIndex &D, const Add &) noexcept
constexpr MultiIndex (const MultiIndex &M, const MultiIndex &D, const Sub &) noexcept
constexpr MultiIndex (const MultiIndex &M, const MultiIndex &D, const Mult &) noexcept
constexpr MultiIndex (const MultiIndex &M, const MultiIndex &D, const Div &) noexcept
constexpr MultiIndex (unsigned int bits, const ::Eagle::BinaryAnd &) noexcept
constexpr MultiIndex (const MultiIndex &M, const MultiIndex &D, const ::Eagle::BinaryAnd &) noexcept
constexpr MultiIndex (const MultiIndex &M, const Power2Alignment &) noexcept
constexpr MultiIndex (const std::array< index_t, 1 > &A)

Friends

constexpr MultiIndex clamp (const MultiIndex &M, const MultiIndex &D) noexcept
constexpr MultiIndex clamp_m1 (const MultiIndex &M, const MultiIndex &D) noexcept
MultiIndex distance (const MultiIndex &M0, const MultiIndex &M1)
 Compute the distance between two multiindices, which is always positive in each index (in contrast to the subtraction operation).
MultiIndex bitalign (const MultiIndex &M) noexcept
MultiIndex operator| (const MultiIndex &M, int i)
 Axis index subtraction operator, similar to adding an integer to a multidimensional index, but opposite direction.

(Note that these are not member symbols.)

constexpr FixedArray< double, Dims > div (const MultiIndex< Dims > &Divisor, const MultiIndex< Dims > &Dividend)
 Compute the rational division of two MultiIndex es.
Eagle::DomainVector< VectorType, Domain, scalar_t > CellSize (const Eagle::DomainVector< VectorType, Domain, scalar_t > &V, const MultiIndex< VectorType::SIZE > &Dividend, const MultiIndex< VectorType::SIZE > &Stride=MultiIndex< VectorType::SIZE >(1))
 Compute the size of a "cell" given a distance between a set of points.
Eagle::DomainVector< VectorType, Domain, scalar_t > CellSize0 (const Eagle::DomainVector< VectorType, Domain, scalar_t > &V, const MultiIndex< VectorType::SIZE > &Dividend, const MultiIndex< VectorType::SIZE > &Stride=MultiIndex< VectorType::SIZE >(1))
 Compute the size of a "cell" given a distance between a set of points.
MultiIndex< Dims > operator+ (index_t C, const MultiIndex< Dims > &I)
 Add constant plus multi-index.
MultiIndex< Dims > operator+ (const MultiIndex< Dims > &I, index_t C)
 Add multi-index plus constant.
FixedArray< double, Dims > operator* (const FixedArray< double, Dims > &a, const MultiIndex< Dims > &I)
 Component-wise multiplication.
FixedArray< double, Dims > operator* (const MultiIndex< Dims > &I, const FixedArray< double, Dims > &a)
 Component-wise multiplication.
FixedArray< double, Dims > operator/ (const FixedArray< double, Dims > &a, const MultiIndex< Dims > &I)
 Component-wise division.
FixedArray< double, Dims > & operator/= (FixedArray< double, Dims > &a, const MultiIndex< Dims > &I)
 Component-wise division.
FixedArray< double, Dims > & operator*= (FixedArray< double, Dims > &a, const MultiIndex< Dims > &I)
 Component-wise multiplication.
FixedArray< int, Dims > MultiIndexToFixedArray (const MultiIndex< Dims > &Value)
MultiIndex< Dims > FixedArrayToMultiIndex (const FixedArray< int, Dims > &Value)
MultiIndex< Dims > minMultiIndex (const MultiIndex< Dims > &A, const MultiIndex< Dims > &B)
MultiIndex< Dims > maxMultiIndex (const MultiIndex< Dims > &A, const MultiIndex< Dims > &B)

Detailed Description

Stop multidimensional indexing recursion.

Constructor & Destructor Documentation

◆ MultiIndex()

Fiber::MultiIndex< 1 >::MultiIndex ( const Index & lin_idx,
const MultiIndex< 1 > & Dimens,
const CreateFromLinear &  )
inlineconstexpr

Multidimensional Index - a linear Index with Dimensions.

It is ensured that the resulting index resides in the range of the dimensions.

Member Function Documentation

◆ Axis()

MultiIndex Fiber::MultiIndex< Dims >::Axis ( unsigned int orientation)
inlinestaticnoexcept

Return a MultiIndex that points just in the given orientation.

It is given by

BitIndex( 1<< orientation )
static MultiIndex BitIndex(unsigned int bits) noexcept
Definition MultiIndex.hpp:572

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

◆ BitIndex()

MultiIndex Fiber::MultiIndex< Dims >::BitIndex ( unsigned int bits)
inlinestaticnoexcept

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

They can be used 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;
}
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
ostream cout
index_t BitIndex() const
From this given multiindex which is supposed to have index values of either 0 or 1 in each direction,...
Definition MultiIndex.hpp:607

◆ operator&()

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.

◆ Orientation()

index_t Fiber::MultiIndex< Dims >::Orientation ( ) const
inlinenoexcept

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.

◆ CellSize()

Eagle::DomainVector< VectorType, Domain, scalar_t > CellSize ( const Eagle::DomainVector< VectorType, Domain, scalar_t > & V,
const MultiIndex< VectorType::SIZE > & Dividend,
const MultiIndex< VectorType::SIZE > & Stride = MultiIndex<VectorType::SIZE>(1) )
related

Compute the size of a "cell" given a distance between a set of points.

Result = V / (Dividend - 1)

This size is the given distance vector divided by the number of points minus one, because there is one cell less than there are points. In case there is only one point, then the resulting "cell size" is just the vector itself, though "zero" would also be a valid answer here. This alternative answer is provided by the CellSize0() function.

The Stride parameter allows to generalize this function to compute the size of gaps spanning more than one point.

◆ CellSize0()

Eagle::DomainVector< VectorType, Domain, scalar_t > CellSize0 ( const Eagle::DomainVector< VectorType, Domain, scalar_t > & V,
const MultiIndex< VectorType::SIZE > & Dividend,
const MultiIndex< VectorType::SIZE > & Stride = MultiIndex<VectorType::SIZE>(1) )
related

Compute the size of a "cell" given a distance between a set of points.

This size is the given distance vector divided by the number of points minus one, because there is one cell less than there are points. In case there is only one point, then the resulting "cell size" is zero, but "the input value" may also be a valid answer allowing to avoid divisions by zero in calling code. This alternative answer is provided by the CellSize() function.

The Stride parameter allows to generalize this function to compute the size of gaps spanning more than one point.