28 #ifndef TOMOGRAPHER_DENSEDM_DMTYPES_H 29 #define TOMOGRAPHER_DENSEDM_DMTYPES_H 34 #include <Eigen/Eigen> 99 template<
int FixedDim_,
typename RealScalar_ =
double,
int MaxFixedDim_ = FixedDim_>
107 (FixedDim_ <= MaxFixedDim_)) ;
110 static constexpr
bool IsDynamicDim = (FixedDim_ == Eigen::Dynamic);
112 static constexpr
int FixedDim = FixedDim_;
114 static constexpr
int FixedDim2 = ((FixedDim!=Eigen::Dynamic) ? FixedDim*FixedDim : Eigen::Dynamic);
118 static constexpr
int FixedNdof = ((FixedDim2!=Eigen::Dynamic) ? FixedDim2-1 : Eigen::Dynamic);
126 static inline ComplexScalar
cplx(RealScalar a, RealScalar b)
128 return ComplexScalar(a, b);
157 TOMOGRAPHER_ENABLED_IF(!IsDynamicDim)
182 inline Eigen::Index
dim()
const {
return _dim.value(); }
190 inline Eigen::Index
dim2()
const {
return _dim.value()*_dim.value(); }
197 inline Eigen::Index
ndof()
const {
return dim2()-1; }
205 TOMOGRAPHER_ENABLED_IF(!IsDynamicDim)
206 inline typename MatrixType::ConstantReturnType initMatrixType()
const 208 return MatrixType::Zero();
215 TOMOGRAPHER_ENABLED_IF(IsDynamicDim)
216 inline typename
MatrixType::ConstantReturnType initMatrixType()
const 218 return MatrixType::Zero(_dim.value(), _dim.value());
226 TOMOGRAPHER_ENABLED_IF(!IsDynamicDim)
229 return VectorParamType::Zero();
236 TOMOGRAPHER_ENABLED_IF(IsDynamicDim)
239 return VectorParamType::Zero(dim2());
248 TOMOGRAPHER_ENABLED_IF(!IsDynamicDim)
251 return VectorParamNdofType::Zero();
259 TOMOGRAPHER_ENABLED_IF(IsDynamicDim)
262 return VectorParamNdofType::Zero(ndof());
Eigen::Matrix< RealScalar, FixedDim2, 1 > VectorParamType
Real vector with dim*dim elements.
Base namespace for the Tomographer project.
std::complex< RealScalar > ComplexScalar
The corresponding complex scalar type.
const Eigen::Ref< const MatrixType > & MatrixTypeConstRef
Shorthand for a const reference to a MatrixType-like Eigen object.
Eigen::Matrix< RealScalar, FixedNdof, 1 > VectorParamNdofType
Real vector with dim*dim-1 elements.
static ComplexScalar cplx(RealScalar a, RealScalar b)
Utility to initialize a complex number using the current scalar type.
#define TOMO_STATIC_ASSERT_EXPR(...)
Tool for static assertions without message.
Eigen::Index dim() const
get the dimension of the quantum system (dimension of the Hilbert space)
Eigen::Index dim2() const
get the square of the dimension of the quantum system
Some C++ utilities, with a tad of C++11 tricks.
DMTypes(Eigen::Index d)
Constructor [works for both static or dynamic dim].
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.
const Eigen::Ref< const VectorParamType > & VectorParamTypeConstRef
Shorthand for a const reference to a VectorParamType-like Eigen object.
C++ types needed to store a quantum state as a dense matrix.
const Eigen::Ref< const VectorParamNdofType > & VectorParamNdofTypeConstRef
Shorthand for a const reference to a VectorParamNdofType-like Eigen object.
Eigen::Index ndof() const
get the square of the dimension of the quantum system, minus one
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.