Table Of Contents

Previous topic

DimensionsBookkeeper

Next topic

Defining metrical transformations

ArrayBase

class quantumdata::ArrayBase

template <int RANK> (cf. template parameters), inherits privately from boost::noncopyable.

This class comprises the common functionalities of StateVector and DensityOperator.

type ArrayLow
typedef TTD_CArray<RANK> ArrayLow;
type CVector
typedef linalg::CVector CVector;

Equivalent to TTD_CArray<1>.

explicit ArrayBase(const ArrayLow& arrayLow)

By-reference semantics (basically the copy of a blitz::Array). Otherwise, copying is not possible.

ArrayBase& operator=(const ArrayLow& arrayLow)
ArrayBase& operator=(const ArrayBase& arrayBase)

By-value semantics (like the assignment of a blitz::Array). The latter synthesised by the compiler.

const ArrayLow& operator()() const

(also in non-const version) Returns the underlying ArrayLow.

void operator+=(const ArrayBase& arrayBase)
void operator-=(const ArrayBase& arrayBase)

Naive vector-space operations.

void operator*=(const OTHER& dc)
void operator/=(const OTHER& dc)

template <typename OTHER>

Naive vector-space operations allowing also for mixed-mode arithmetic.

const CVector vectorView() const

(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.

double frobeniusNorm() const

calculates the “entrywise” norm

\norm{A}=\sqrt{\sum_i \abs{A_i}^2}

with i running through all the multi-indices.

State vector

class quantumdata::StateVector

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

type Dimensions

(inherited from DimensionsBookkeeper)

type StateVectorLow

same as quantumdata::Types::StateVectorLow

type DensityOperatorLow

same as quantumdata::Types::DensityOperatorLow

type Idx

(inherited from LazyDensityOperator)

Constructors, assignment

StateVector(const StateVectorLow& psi, ByReference)

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.

explicit StateVector(const Dimensions& dim, bool init=true)

Constructs the class with a newly allocated chunk of memory, which is initialized only if init is true.

StateVector(const StateVector& psi)

Copy constructor using by value semantics, that is, deep copy.

StateVector(const StateVector<RANK2>& psi1, const StateVector<RANK-RANK2>& psi2)

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().

StateVector& operator=(const StateVector& sv)
StateVector& operator=(const OTHER& other)

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

const linalg::CVector vectorView() const

(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.

const StateVectorLow& operator()() const

(inherited from ArrayBase; also in non-constant version) Returns the underlying blitz::Array storage.

double norm() const
double renorm()

Both functions return the norm \norm{\Psi}, but the latter one also renormalizes. Implemented in terms of quantumdata::ArrayBase::frobeniusNorm().

const DensityOperatorLow dyad(const StateVector& psi) const
const DensityOperatorLow dyad() const

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().

void addTo(DensityOperator<RANK>& densityOperator)

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

StateVector& operator+=(const StateVector& psi)
StateVector& operator-=(const StateVector& psi)
const StateVector operator-() const
const StateVector operator+() const
StateVector& operator*=(const OTHER& dc)
StateVector& operator/=(const OTHER& dc)

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

const dcomp operator()(const Idx& i, const Idx& j)

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:

const StateVector<RANK1+RANK2> quantumdata::operator*(const StateVector<RANK1>& psi1, const StateVector<RANK2>& psi2)

template <int RANK1, int RANK2> (cf. template parameters)

This function creates the direct product, relying on the direct-product constructor.

const dcomp quantumdata::braket(const StateVector<RANK>& psi1, const StateVector<RANK>& psi2)

template <int RANK> (cf. template parameters)

Calculates the inner product, relying on vectorView().

Density operator

DensityOperators interface is similar to StateVectors with obvious differences. Here only the most important will be tackled:

class quantumdata::DensityOperator

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>.

explicit DensityOperator(const StateVector<RANK>& psi)

Constructs the class as a dyadic product of psi.

double norm() const
double renorm()

Both functions return the trace “norm”, but the latter one also renormalizes.

const linalg::CMatrix matrixView() const

(also in non-constant version) Returns a two-dimensional view of the underlying data, created on the fly via blitzplusplus::binaryArray().

const dcomp operator()(const Idx& i, const Idx& j)

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));
}