Tomographer
v4.0
Tomographer C++ Framework Documentation
|
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< RealScalar > | ComplexScalar |
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 (std::size_t d) | |
Constructor [works for both static or dynamic dim]. More... | |
std::size_t | dim () const |
get the dimension of the quantum system (dimension of the Hilbert space) More... | |
std::size_t | dim2 () const |
get the square of the dimension of the quantum system More... | |
std::size_t | 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. | |
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.
FixedDim | The 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. |
RealScalar | The 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
dim()*dim()
real entries, as needed for example to store the X Parameterization of a Hermitian matrix.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.
typedef Eigen::Matrix<RealScalar, FixedNdof, 1> Tomographer::DenseDM::DMTypes< FixedDim_, RealScalar_, MaxFixedDim_ >::VectorParamNdofType |
|
inline |
|
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).
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.