Tomographer  v5.3
Tomographer C++ Framework Documentation
Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ > Struct Template Reference

C++ types needed to store a quantum state as a dense matrix. More...

#include <tomographer/densedm/dmtypes.h>

Public Types

typedef RealScalar_ RealScalar
 Real scalar type, given in template parameter. Usually double is fine.
 
typedef std::complex< RealScalarComplexScalar
 The corresponding complex scalar type.
 
typedef Eigen::Matrix< ComplexScalar, FixedDim, FixedDim, Eigen::Matrix< ComplexScalar, FixedDim, FixedDim >::Options, MaxFixedDim_, MaxFixedDim_ > MatrixType
 Matrix type, to store the density operator as a dense matrix.
 
typedef const Eigen::Ref< const MatrixType > & MatrixTypeConstRef
 Shorthand for a const reference to a MatrixType-like Eigen object.
 
typedef Eigen::Matrix< RealScalar, FixedDim2, 1 > VectorParamType
 Real vector with dim*dim elements.
 
typedef const Eigen::Ref< const VectorParamType > & VectorParamTypeConstRef
 Shorthand for a const reference to a VectorParamType-like Eigen object.
 
typedef Eigen::Matrix< RealScalar, FixedNdof, 1 > VectorParamNdofType
 Real vector with dim*dim-1 elements. More...
 
typedef const Eigen::Ref< const VectorParamNdofType > & VectorParamNdofTypeConstRef
 Shorthand for a const reference to a VectorParamNdofType-like Eigen object.
 

Public Member Functions

template<ENABLED_IF( !IsDynamicDim) >
 DMTypes ()
 Constructor [only for statically-fixed dim]. More...
 
 DMTypes (Eigen::Index d)
 Constructor [works for both static or dynamic dim]. More...
 
Eigen::Index dim () const
 get the dimension of the quantum system (dimension of the Hilbert space) More...
 
Eigen::Index dim2 () const
 get the square of the dimension of the quantum system More...
 
Eigen::Index ndof () const
 get the square of the dimension of the quantum system, minus one More...
 
template<ENABLED_IF( !IsDynamicDim) >
MatrixType::ConstantReturnType initMatrixType () const
 Zero initializer for a MatrixType [implementation for static dimension]. More...
 
template<ENABLED_IF( IsDynamicDim) >
MatrixType::ConstantReturnType initMatrixType () const
 Zero initializer for MatrixType [implementation for dynamic dimension]. More...
 
template<ENABLED_IF( !IsDynamicDim) >
VectorParamType::ConstantReturnType initVectorParamType () const
 Zero initializer for a VectorParamType [implementation for static dimension]. More...
 
template<ENABLED_IF( IsDynamicDim) >
VectorParamType::ConstantReturnType initVectorParamType () const
 Zero initializer for VectorParamType [implementation for dynamic dimension]. More...
 
template<ENABLED_IF( !IsDynamicDim) >
VectorParamNdofType::ConstantReturnType initVectorParamNdofType () const
 Zero initializer for a VectorParamNdofType [implementation for static dimension]. More...
 
template<ENABLED_IF( IsDynamicDim) >
VectorParamNdofType::ConstantReturnType initVectorParamNdofType () const
 Zero initializer for VectorParamNdofType [implementation for dynamic dimension]. More...
 

Static Public Member Functions

static ComplexScalar cplx (RealScalar a, RealScalar b)
 Utility to initialize a complex number using the current scalar type.
 

Static Public Attributes

static constexpr bool IsDynamicDim = (FixedDim_ == Eigen::Dynamic)
 Whether the dimension is specified dynamically at run-time or statically at compile-time.
 
static constexpr int FixedDim = FixedDim_
 The fixed dimension of the quantum system, or Eigen::Dynamic.
 
static constexpr int FixedDim2 = ((FixedDim!=Eigen::Dynamic) ? FixedDim*FixedDim : Eigen::Dynamic)
 The square of the dimension of the quantum system, or Eigen::Dynamic.
 
static constexpr int FixedNdof = ((FixedDim2!=Eigen::Dynamic) ? FixedDim2-1 : Eigen::Dynamic)
 The square of the dimension of the quantum system minus one, or Eigen::Dynamic.
 

Detailed Description

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
struct Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >

C++ types needed to store a quantum state as a dense matrix.

The DMTypes template class stores compile-time and run-time information about the types used to represent density operators as dense Eigen objects (storing a matrix explicitly as a list of coefficients in memory, as you'd expect), as well as remembering the dimension of the corresponding Hilbert space. The latter may be fixed either at compile-time or set dynamically at run-time.

If a compile-time dimension is given, then the corresponding Eigen types (see Eigen::Matrix) will be allocated on the stack instead of the heap. For small matrix sizes, you should get a performance increase.

Template Parameters
FixedDimThe dimension of the Hilbert space, if known at compile-time, or Eigen::Dynamic. If Eigen::Dynamic is specified here, the dimension can be specified at run-time to the class's constructor.
RealScalarThe type to use as real scalar. The default, double, should be sufficient in most (if not all) cases, but you could try to speed up computations by using float, or be more precise by using long double.

This class provides several types which are to be used to store matrices acting on the Hilbert space, a vector of real coefficients which can store an X Parameterization of Hermitian such matrices, and a vector of real coefficients of length corresponding to the number of degrees of freedom of a density matrix (e.g. to store a A Parameterization). For each such type, there is an initialization method (e.g. initMatrixType()), which initializes the corresponding object to zero.

Whenever such a type is needed, one calls for example

int dim = ...;
DMTypes<Eigen::Dynamic> dmt(dim);
...
DMTypes<Eigen::Dynamic>::MatrixType matrix(dmt.initMatrixType());
... use `matrix' as a dim*dim complex matrix ...
  • MatrixType : type used to store a matrix acting on the Hilbert space of dimension dim(). This is simply a complex dim()-by-dim() matrix.
  • VectorParamType : a vector of dim()*dim() real entries, as needed for example to store the X Parameterization of a Hermitian matrix.
  • VectorParamNdofType : a vector of dim()*dim()-1 real entries, as needed for example to store the A Parameterization of a density matrix.

To each of these type corresponds a const-reference type, which is useful to specify function arguments.

Definition at line 100 of file dmtypes.h.

Member Typedef Documentation

§ VectorParamNdofType

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
typedef Eigen::Matrix<RealScalar, FixedNdof, 1> Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::VectorParamNdofType

Real vector with dim*dim-1 elements.

The number of elements ( \( \texttt{dim}^2-1\)) corresponds to the number of degrees of freedom of a density matrix of dimension \( \texttt{dim} \).

Definition at line 148 of file dmtypes.h.

Constructor & Destructor Documentation

§ DMTypes() [1/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( !IsDynamicDim) >
Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::DMTypes ( )
inline

Constructor [only for statically-fixed dim].

Definition at line 158 of file dmtypes.h.

§ DMTypes() [2/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::DMTypes ( Eigen::Index  d)
inline

Constructor [works for both static or dynamic dim].

The dimension fixed at run-time must be specified here, and cannot later be changed.

If the dimension was fixed at compile-time with FixedDim_, then d must equal FixedDim_ (or you'll get an assert failure).

Definition at line 171 of file dmtypes.h.

Member Function Documentation

§ dim()

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
Eigen::Index Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::dim ( ) const
inline

get the dimension of the quantum system (dimension of the Hilbert space)

If the dimension was fixed at compile-time, then that value is directly returned (and the compiler should be able to optimize this). If the dimension is dynamically set at run-time, then we return that stored value.

Definition at line 182 of file dmtypes.h.

§ dim2()

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
Eigen::Index Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::dim2 ( ) const
inline

get the square of the dimension of the quantum system

Equivalently, this is the number of complex matrix entries, or the number of real coefficients needed to specify a Hermitian matrix. It is the size of a VectorParamType.

Definition at line 190 of file dmtypes.h.

§ initMatrixType() [1/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( !IsDynamicDim) >
MatrixType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initMatrixType ( ) const
inline

Zero initializer for a MatrixType [implementation for static dimension].

This function returns an initializer, which when used as constructor argument to MatrixType, initializes it with a zero \( \texttt{dim}\times\texttt{dim} \) matrix.

Definition at line 206 of file dmtypes.h.

§ initMatrixType() [2/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( IsDynamicDim) >
MatrixType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initMatrixType ( ) const
inline

Zero initializer for MatrixType [implementation for dynamic dimension].

This function returns an initializer, which when used as constructor argument to MatrixType, initializes it with a zero \( \texttt{dim}\times\texttt{dim} \) matrix.

Definition at line 216 of file dmtypes.h.

§ initVectorParamNdofType() [1/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( !IsDynamicDim) >
VectorParamNdofType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initVectorParamNdofType ( ) const
inline

Zero initializer for a VectorParamNdofType [implementation for static dimension].

This function returns an initializer, which when used as constructor argument to VectorParamNdofType, initializes it to a zero vector of \( \texttt{dim}^2-1 \) entries.

Definition at line 249 of file dmtypes.h.

§ initVectorParamNdofType() [2/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( IsDynamicDim) >
VectorParamNdofType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initVectorParamNdofType ( ) const
inline

Zero initializer for VectorParamNdofType [implementation for dynamic dimension].

This function returns an initializer, which when used as constructor argument to VectorParamNdofType, initializes it to a zero vector of \( \texttt{dim}^2-1 \) entries.

Definition at line 260 of file dmtypes.h.

§ initVectorParamType() [1/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( !IsDynamicDim) >
VectorParamType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initVectorParamType ( ) const
inline

Zero initializer for a VectorParamType [implementation for static dimension].

This function returns an initializer, which when used as constructor argument to VectorParamType, initializes it to a zero vector of \( \texttt{dim}^2 \) entries.

Definition at line 227 of file dmtypes.h.

§ initVectorParamType() [2/2]

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
template<ENABLED_IF( IsDynamicDim) >
VectorParamType::ConstantReturnType Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::initVectorParamType ( ) const
inline

Zero initializer for VectorParamType [implementation for dynamic dimension].

This function returns an initializer, which when used as constructor argument to VectorParamType, initializes it to a zero vector of \( \texttt{dim}^2 \) entries.

Definition at line 237 of file dmtypes.h.

§ ndof()

template<int FixedDim_, typename RealScalar_ = double, int MaxFixedDim_ = FixedDim_>
Eigen::Index Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::ndof ( ) const
inline

get the square of the dimension of the quantum system, minus one

Equivalently, this is the number of degrees of freedom of a density matrix. It is the size of a VectorParamNdofType.

Definition at line 197 of file dmtypes.h.


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