4 #ifndef CPPQEDCORE_QUANTUMDATA_DENSITYOPERATOR_H_INCLUDED
5 #define CPPQEDCORE_QUANTUMDATA_DENSITYOPERATOR_H_INCLUDED
7 #include "DensityOperatorFwd.h"
9 #include "StateVectorFwd.h"
24 const DensityOperator<RANK>
25 dyad(
const StateVector<RANK>&,
const StateVector<RANK>&);
28 template<
int RANK1,
int RANK2>
30 const DensityOperator<RANK1+RANK2>
31 operator*(
const DensityOperator<RANK1>&,
const DensityOperator<RANK2>&);
36 double frobeniusNorm(
const DensityOperator<RANK>& rho) {
return rho.frobeniusNorm();}
60 static const int N_RANK=RANK;
91 template<
typename OTHER>
98 IndexerProxy(
const DensityOperator* rho,
const Idx& firstIndex) : rho_(rho), firstIndex_(firstIndex) {}
100 template<
typename... SubscriptPack>
101 IndexerProxy(
const DensityOperator* rho,
int s0, SubscriptPack... subscriptPack) : IndexerProxy(rho,Idx(s0,subscriptPack...))
102 {static_assert( mpl::size<mpl::vector<SubscriptPack...> >::value==RANK-1 ,
"Incorrect number of subscripts for DensityOperator." );}
104 const dcomp& operator()(
const Idx& secondIndex)
const {
return rho_->indexWithTiny(firstIndex_,secondIndex);}
105 dcomp& operator()(
const Idx& secondIndex) {
return const_cast<dcomp&
>(
static_cast<const IndexerProxy&
>(*this)(secondIndex));}
107 template<
typename... SubscriptPack>
108 const dcomp& operator()(
int s0, SubscriptPack... subscriptPack)
const
110 static_assert( mpl::size<mpl::vector<SubscriptPack...> >::value==RANK-1 ,
"Incorrect number of subscripts for DensityOperator::IndexerProxy." );
111 return operator()(Idx(s0,subscriptPack...));
114 template<
typename... SubscriptPack>
115 dcomp& operator()(
int s0, SubscriptPack... subscriptPack) {
return const_cast<dcomp&
>(
static_cast<const IndexerProxy&
>(*this)(s0,subscriptPack...));}
119 const Idx firstIndex_;
123 friend class IndexerProxy;
128 const IndexerProxy operator()(
const Idx& firstIndex)
const {
return IndexerProxy(
this,firstIndex);}
129 IndexerProxy operator()(
const Idx& firstIndex) {
return IndexerProxy(
this,firstIndex);}
131 template<
typename... SubscriptPack>
132 const IndexerProxy operator()(
int s0, SubscriptPack... subscriptPack)
const {
return IndexerProxy(
this,s0,subscriptPack...);}
134 template<
typename... SubscriptPack>
135 IndexerProxy operator()(
int s0, SubscriptPack... subscriptPack) {
return IndexerProxy(
this,s0,subscriptPack...);}
158 template<
typename OTHER>
159 DensityOperator& operator*=(
const OTHER& dc) {ABase::operator*=(dc);
return *
this;}
161 template<
typename OTHER>
162 DensityOperator& operator/=(
const OTHER& dc) {ABase::operator/=(dc);
return *
this;}
166 const dcomp& indexWithTiny(
const Idx&,
const Idx&)
const;
168 const dcomp index(
const Idx& i,
const Idx& j)
const override {
return indexWithTiny(i,j);}
170 double trace_v()
const override {
return norm();}
182 const DensityOperator<RANK>
186 template<
int... SUBSYSTEM,
int RANK>
188 reduce(
const LazyDensityOperator<RANK>&);
194 #endif // CPPQEDCORE_QUANTUMDATA_DENSITYOPERATOR_H_INCLUDED
const DensityOperator< RANK > densityOperatorize(const LazyDensityOperator< RANK > &)
Creates a DensityOperator as the (deep) copy of the data of a LazyDensityOperator of the same arity...
Comprises the common functionalities of StateVector and DensityOperator.
Defines class of the same name.
ArrayBase & operator=(const ArrayLow &arrayLow)
Assignment with by-value semantics (like the assignment of a blitz::Array).
Comprises classes representing the state of composite quantum systems and providing various interface...
Density operator of arbitrary arity.
State vector of arbitrary arity.
const blitz::Array< T, 2 > binaryArray(const blitz::Array< T, TWO_TIMES_RANK > &array)
Returns a binary view of array. TWO_TIMES_RANK must be an even number.
IdxTiny< RANK > Idx
The type used for indexing the “rows” and the “columns”: a tiny vector of integers (multi-index) ...
blitz::Array< double, RANK > DArray
An array of doubles of arbitrary arity.
Defines class of the same name.
Defines class of the same name.
DensityOperator(const DensityOperatorLow &, ByReference)
Referencing constructor implemented in terms of blitzplusplus::halfCutTiny.
void inflate(const DArray< 1 > &, DensityOperator< RANK > &, bool offDiagonals)
Performs the opposite of quantumdata::deflate.
const CMatrix matrixView() const
returns a two-dimensional view of the underlying data, created on the fly via blitzplusplus::binaryAr...
DensityOperator & operator=(const DensityOperator &rho)
Default assignment doesn't work, because LazyDensityOperator is always purely constant (const Dimensi...
double frobeniusNorm() const
The entrywise array norm.
CArray< 2 > CMatrix
Complex matrix.
Defines class of the same name.
Common interface for calculating quantum averages.
Base::Dimensions Dimensions
Inherited from DimensionsBookkeeper.
const Dimensions & getDimensions() const
Get the Dimensions vector.
quantumdata::DensityOperator< 1 > DensityOperator
unary DensityOperator
double renorm()
” and also renormalises
std::complex< double > dcomp
Double-precision complex number.
Operator aggregate for a complex vector space built on top of Boost.Operator.
CArray< RANK > ArrayLow
The underlying storage.
double norm() const
returns the trace “norm”
Extensions built on top of Boost.Operator.