Previous topic

Non-orthogonal state vector

Next topic

The quantumoperator namespace

DiagonalIterator—Notes on implementation

Difficulty: LazyDensityOperator is an abstract interface, and the organization of its data varies by implementation.

Implemented using a classical inheritance-based strategy idiom, together with both compile-time and run-time implementation selection (similarly to blitz array slice iterator, a special implementation (DI_ImplSpecial) is needed when the size of the compile-time vector V equals RANK).

_images/ldoDiagonalIterator.png

The run-time polymorphy of LazyDensityOperator necessitates run-time implementation selection. This happens when the actual implementation (DI_SV_Impl or DI_DO_Impl, or their non-orthogonal counterparts) is chosen depending on whether the given LazyDensityOperator is a StateVector or a DensityOperator (or their non-orthogonal counterparts).

class quantumdata::ldo::DiagonalIterator

template <int RANK, typename V> (cf. template parameters)

Model of InputIterator, implemented with the help of boost::input_iterator_helper from Boost.Operator.

type value_type

equivalent to const LazyDensityOperator<mpl::size<V>::value>

type Impl

pointer to implementation:

typedef boost::shared_ptr<typename mpl::eval_if_c<RANK==mpl::size<V>::value,
                                                  mpl::identity<details::DI_ImplSpecial<V> >,
                                                  mpl::identity<details::DI_Impl<RANK,V> > >::type> Impl;