C++QEDCore  2.100.2 (v2 Milestone 10 Development branch)
a framework for simulating open quantum dynamics – core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
blitzplusplus::basi::Iterator< RANK, V, IS_CONST > Class Template Reference

BlitzArraySliceIterator. More...

#include <BlitzArraySliceIterator.h>

+ Inheritance diagram for blitzplusplus::basi::Iterator< RANK, V, IS_CONST >:
+ Collaboration diagram for blitzplusplus::basi::Iterator< RANK, V, IS_CONST >:

Public Types

typedef boost::mpl::if_c< RANK==1, details::BaseTrivial< V, IS_CONST >, typename boost::mpl::if_c< RANK==Size< V >::value, details::BaseSpecial< V, IS_CONST >, details::Base< RANK, V, IS_CONST > >::type >::type Base
 
typedef Base::CcCA CcCA
 ttd::ConditionalConstCArray
 
typedef boost::iterator_range< IteratorRange
 Boost.Range-compliant range.
 

Public Member Functions

Iteratoroperator++ ()
 For the ForwardIterator concept.
 
template<bool IS_END>
 Iterator (CcCA &array, boost::mpl::bool_< IS_END > isEnd)
 Can be initialized either to the beginning or the end of the sequence of dummy-index combinations. More...
 

Related Functions

(Note that these are not member functions.)

template<typename V , typename A >
const Iterator< Rank< A >::value, V, false > begin (A &array)
 Iterator to the beginning of the (non-const) sequence. More...
 
template<typename V , typename A >
const Iterator< Rank< A >::value, V, false > end (A &array)
 ” for the end More...
 
template<typename V , typename A >
const Iterator< Rank< A >::value, V, true > begin (const A &array)
 Iterator to the beginning of the (const) sequence. More...
 
template<typename V , typename A >
const Iterator< Rank< A >::value, V, true > end (const A &array)
 “ for the end More...
 
template<typename V , typename A >
const boost::iterator_range< Iterator< Rank< A >::value, V, false > > fullRange (A &array)
 Boost.Range-compliant full range of slice iterators More...
 
template<typename V , typename A >
const boost::iterator_range< Iterator< Rank< A >::value, V, true > > fullRange (const A &array)
 ” const version More...
 

Detailed Description

template<int RANK, typename V, bool IS_CONST>
class blitzplusplus::basi::Iterator< RANK, V, IS_CONST >

BlitzArraySliceIterator.

Template Parameters
RANKpositive integer standing for the number of elementary Hilbert spaces
Vcompile-time vector holding the retained index positions like $\avr{3,6,1,9,7}$ here. (Cf. Specifying subsystems)
IS_CONSTgoverns the constness of the class

To understand the template parameters, cf. also The multi-array concept.

Model of ForwardIterator. Can be both const and non-const iterator depending on the last template argument.

This iterator is implemented in terms of a cpputils::MultiIndexIterator, and hence it can be initialized to either the beginning or the end of the “sequence”.

This class is at the absolute heart of the framework as it is indispensable to implement

This said, it is never really used directly in the framework, but rather through the maker functions blitzplusplus::basi::begin, blitzplusplus::basi::end, and blitzplusplus::basi::fullRange in standard or Boost.Range algorithms.

Quite generally, by iterating through all the combinations of indices not belonging to the given subsystem (dummy indices) and when dereferenced returning the corresponding slice, it can be used to implement the action of operators in extended (and/or permutated) Hilbert spaces.

Semantics

Sticking to the example here, assume that the function

void actWithA(CArray<5>&);

implements the action of the operator $A$ on a state vector of rank 5. Then the action on the extended Hilbert space can be calculated as

void actOnExtended(CArray<11>& psi)
{
boost::for_each(blitzplusplus::basi::fullRange<tmptools::Vector<3,6,1,9,7> >(psi),
actWithA);
}
See also
blitzplusplus::basi::fullRange and the for_each algorithm of Boost.Range.

For further basic examples of usage cf. utils/testsuite/BlitzArraySliceIterator.cc & utils/testsuite/BlitzArraySliceIteratorTMP.cc.

See also
Notes on the implementation of Iterator
Todo:
Implement a default version of Iterator for the case when neither slicing nor transposition is necessary, that is when V is equivalent to a range<0,RANK-1>. This will require further compile-time implementation selection.
Todo:
Refine the iterator category according to the New-Style Iterator concepts. The point is that a multi-array is not a container of slices, so Iterator is definitely not a standard iterator. It seems rather like a proxy iterator.

Definition at line 297 of file BlitzArraySliceIterator.h.

Constructor & Destructor Documentation

template<int RANK, typename V , bool IS_CONST>
template<bool IS_END>
blitzplusplus::basi::Iterator< RANK, V, IS_CONST >::Iterator ( CcCA array,
boost::mpl::bool_< IS_END >  isEnd 
)
inline

Can be initialized either to the beginning or the end of the sequence of dummy-index combinations.

Template Parameters
IS_ENDgoverns the end-ness

Definition at line 316 of file BlitzArraySliceIterator.h.

Friends And Related Function Documentation

template<typename V , typename A >
const Iterator< Rank< A >::value, V, false > begin ( A &  array)
related

Iterator to the beginning of the (non-const) sequence.

Template Parameters
Vthe retained index positions
Aarray type taken itself as a parameter to ease template-parameter inference
Returns
non-const Iterator
template<typename V , typename A >
const Iterator< Rank< A >::value, V, true > begin ( const A &  array)
related

Iterator to the beginning of the (const) sequence.

Template Parameters
Vthe retained index positions
Aarray type taken itself as a parameter to ease template-parameter inference
Returns
const Iterator
template<typename V , typename A >
const Iterator< Rank< A >::value, V, false > end ( A &  array)
related

” for the end

template<typename V , typename A >
const Iterator< Rank< A >::value, V, true > end ( const A &  array)
related

“ for the end

template<typename V , typename A >
const boost::iterator_range< Iterator< Rank< A >::value, V, false > > fullRange ( A &  array)
related

Boost.Range-compliant full range of slice iterators

It corresponds to all the possible combinations of dummy indices ( $\iota_0,\iota_2,\iota_4,\iota_5,\iota_8,\iota_{10},$…) here.

Template Parameters
Vthe retained index positions
Aarray type taken itself as a parameter to ease template-parameter inference
template<typename V , typename A >
const boost::iterator_range< Iterator< Rank< A >::value, V, true > > fullRange ( const A &  array)
related

” const version


The documentation for this class was generated from the following file: