ArrayBase
template <int RANK> (cf. template parameters), inherits privately from boost::noncopyable.
This class comprises the common functionalities of StateVector and DensityOperator.
typedef TTD_CArray<RANK> ArrayLow;
typedef linalg::CVector CVector;
Equivalent to TTD_CArray<1>.
By-reference semantics (basically the copy of a blitz::Array). Otherwise, copying is not possible.
By-value semantics (like the assignment of a blitz::Array). The latter synthesised by the compiler.
(also in non-const version) Returns the underlying ArrayLow.
Naive vector-space operations.
template <typename OTHER>
Naive vector-space operations allowing also for mixed-mode arithmetic.
(also in non-constant version) Returns a one-dimensional view of the underlying data, created on the fly via blitzplusplus::unaryArray().
Note
This is meant to be used only if the underlying storage is contiguous, which may not be the case since the object may reference ArrayLows of any layout. In debug mode, a non-contiguous storage is detected by the implementing function blitzplusplus::unaryArray(), and an exception of type blitzplusplus::NonContiguousStorageException is thrown.
calculates the “entrywise” norm
with running through all the multi-indices.
template <int RANK> (cf. template parameters); inherits publicly from LazyDensityOperator<RANK>, and privately from ArrayBase<RANK>, and also from linalg::VectorSpace<StateVector<RANK> > which adds a lot of free-standing arithmetic functions.
Types
(inherited from DimensionsBookkeeper)
(inherited from LazyDensityOperator)
Constructors, assignment
Constructs the class in such a way that the underlying data will reference the same data as psi.
Note
Since everywhere else the class represents by-value semantics, some care is needed with this constructor’s use. For this reason, the tagging dummy class ByReference is introduced, to make the user conscious of what the semantics is.
Constructs the class with a newly allocated chunk of memory, which is initialized only if init is true.
Copy constructor using by value semantics, that is, deep copy.
template <int RANK2>
Constructs the class as the direct product of psi1 and psi2, whose arities add up to RANK.
See also
The implementation relies on blitzplusplus::concatenateTinies() and blitzplusplus::doDirect().
template <typename OTHER>
template<typename OTHER> StateVector& operator=(const OTHER& other) {operator()()=other; return *this;}
The standard assignment and the templated assignment together cover a lot of possibilities, including also assignment from a StateVectorLow, but for example also from a TTD_DArray<RANK>, or just a const c-number.
By-value semantics.
Class-specific functionality
(inherited from ArrayBase; also in non-constant version) Returns a one-dimensional view of the underlying data.
Note
The same note applies as for quantumdata::ArrayBase::vectorView(), and here especially because of the presence of the referencing constructor. Errors are detected at runtime in debug mode.
(inherited from ArrayBase; also in non-constant version) Returns the underlying blitz::Array storage.
Both functions return the norm , but the latter one also renormalizes. Implemented in terms of quantumdata::ArrayBase::frobeniusNorm().
Both functions form a dyad, the second one with the same object:
const DensityOperatorLow dyad() const {return dyad(*this);}
This is a rather expensive operation, implemented in terms of blitzplusplus::doDirect().
This function adds a dyad of the present object to densityOperator, without actually forming the dyad in memory (so that this is not implemented in terms of dyad()). This is important in situations when an average density operator is needed from an ensemble of state vectors, an example being quantumtrajectory::EnsembleMCWF.
Linear algebra
template <typename OTHER>
These are vector-space operations implemented in a naive way (as opposed to e.g. the expression-template mechanism of Blitz), the last two being templated to allow for mixed-mode arithmetics.
Implementing the LazyDensityOperator interface
This function implements the virtual indexing function quantumdata::LazyDensityOperator::operator() in a dyadic-product way:
const dcomp operator()(const Idx& i, const Idx& j) const
{
return operator()()(i)*conj(operator()()(j));
}
Free-standing helpers
The inheritance of StateVector from linalg::VectorSpace provides for a lot of free-standing helpers describing vector-space algebra. These are all naively based on the arithmetic member functions like operator+=(), operator*=(), etc.
There are two further free-standing helpers:
template <int RANK1, int RANK2> (cf. template parameters)
This function creates the direct product, relying on the direct-product constructor.
template <int RANK> (cf. template parameters)
Calculates the inner product, relying on vectorView().
DensityOperators interface is similar to StateVectors with obvious differences. Here only the most important will be tackled:
template <int RANK> (cf. template parameters); inherits publicly from LazyDensityOperator<RANK>, and privately from ArrayBase<2*RANK>, and also from linalg::VectorSpace<DensityOperator<RANK> > which adds a lot of free-standing arithmetic functions.
Note
A DensityOperator<RANK> represents a density operator on a Hilbert space of arity RANK. This makes that the number of its indeces is actually 2*RANK. This is the reason why it inherits from ArrayBase<2*RANK>.
Constructs the class as a dyadic product of psi.
Both functions return the trace “norm”, but the latter one also renormalizes.
(also in non-constant version) Returns a two-dimensional view of the underlying data, created on the fly via blitzplusplus::binaryArray().
This function implements the virtual indexing function quantumdata::LazyDensityOperator::operator() in a trivial way, simply by accessing the necessary element in memory (it must rely on blitzplusplus::concatenateTinies(), though):
const dcomp operator()(const Idx& i, const Idx& j) const
{
return operator()()(blitzplusplus::concatenateTinies<int,int,RANK,RANK>(i,j));
}