28 #ifndef TOMOGRAPHER_DENSEDM_PARAM_RHO_A_H 29 #define TOMOGRAPHER_DENSEDM_PARAM_RHO_A_H 39 #include <Eigen/StdVector> 45 #include <boost/math/constants/constants.hpp> 53 namespace tomo_internal
56 template<
typename DMTypes_,
typename Coeffs>
57 struct GenGellMannFunctor12
60 typedef typename DMTypes::MatrixType::Index MatIndex;
61 GenGellMannFunctor12(DMTypes matq_, MatIndex j_, MatIndex k_)
73 template<
typename Index>
74 inline const typename DMTypes::ComplexScalar operator() (Index row, Index col)
const 76 if (row == j && col == k) {
77 return Coeffs::CoeffJK();
79 if (row == k && col == j) {
80 return Coeffs::CoeffKJ();
86 template<
typename DMTypes>
88 static inline typename DMTypes::ComplexScalar CoeffJK() {
return typename DMTypes::ComplexScalar(1, 0); }
89 static inline typename DMTypes::ComplexScalar CoeffKJ() {
return typename DMTypes::ComplexScalar(1, 0); }
91 template<
typename DMTypes>
93 static inline typename DMTypes::ComplexScalar CoeffJK() {
return typename DMTypes::ComplexScalar(0, -1); }
94 static inline typename DMTypes::ComplexScalar CoeffKJ() {
return typename DMTypes::ComplexScalar(0, +1); }
97 template<
typename DMTypes>
98 struct GenGellMannFunctor1
100 typedef GenGellMannFunctor12<DMTypes, coeffs1<DMTypes> > type;
102 template<
typename DMTypes>
103 struct GenGellMannFunctor2
105 typedef GenGellMannFunctor12<DMTypes, coeffs2<DMTypes> > type;
109 template<
typename DMTypes_>
110 struct GenGellMannFunctor3
112 typedef GenGellMannFunctor3<DMTypes_> type;
114 typedef DMTypes_ DMTypes;
115 typedef typename DMTypes::RealScalar
RealScalar;
116 typedef typename DMTypes::MatrixType::Index MatIndex;
118 GenGellMannFunctor3(DMTypes matq_, MatIndex l_)
123 normalization =
std::sqrt( RealScalar(2) / ((l+1)*(l+2)) );
128 RealScalar normalization;
130 template<
typename Index>
131 inline const typename DMTypes::ComplexScalar operator() (Index row, Index col)
const 135 }
else if (row <= l) {
136 return normalization;
137 }
else if (row == l+1) {
138 return - (l+1) * normalization;
152 template<
typename DMTypes,
typename coeffs>
153 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor12<DMTypes, coeffs> >
155 enum { Cost = 4*NumTraits<typename DMTypes::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true };
158 template<
typename DMTypes,
typename coeffs>
159 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor12<DMTypes, coeffs> >
160 {
enum { ret = 0 }; };
162 template<
typename DMTypes>
163 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor3<DMTypes> >
164 {
enum { Cost = 4*NumTraits<typename DMTypes::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true }; };
166 template<
typename DMTypes>
167 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor3<DMTypes> >
168 {
enum { ret = 0 }; };
185 template<
typename DMTypes_>
219 for (Eigen::Index j = 0; j < _dmt.dim(); ++j) {
220 for (Eigen::Index k = j+1; k < _dmt.dim(); ++k) {
221 lambda[count] = MatrixType::NullaryExpr(
224 typename tomo_internal::GenGellMannFunctor1<DMTypes>::type(_dmt, j, k)
230 for (Eigen::Index j = 0; j < _dmt.dim(); ++j) {
231 for (Eigen::Index k = j+1; k < _dmt.dim(); ++k) {
232 lambda[count] = MatrixType::NullaryExpr(
235 typename tomo_internal::GenGellMannFunctor2<DMTypes>::type(_dmt, j, k)
241 for (Eigen::Index l = 0; l < _dmt.dim()-1; ++l) {
242 lambda[count] = MatrixType::NullaryExpr(
245 typename tomo_internal::GenGellMannFunctor3<DMTypes>::type(_dmt, l)
284 inline VectorParamNdofType
287 VectorParamNdofType a(_dmt.initVectorParamNdofType());
292 a((Eigen::Index)n) = (rho * lambda[n].template selfadjointView<Eigen::Lower>())
293 .real().trace() * boost::math::constants::half_root_two<RealScalar>();
306 MatrixType rho(_dmt.initMatrixType());
310 rho = trace * MatrixType::Identity(rho.rows(), rho.cols()) / _dmt.dim();
312 rho += a((Eigen::Index)n) * boost::math::constants::half_root_two<RealScalar>() * lambda[n];
Tomographer::DenseDM::DMTypes< Eigen::Dynamic, RealScalar > DMTypes
The Tomographer::DenseDM::DMTypes we should use by default, with dynamic sized matrices.
Base namespace for the Tomographer project.
MatrixType aToRho(const Eigen::Ref< const VectorParamNdofType > &a, RealScalar trace=1.0) const
Reconstruct a hermitian traceless matrix from its A Parameterization.
DMTypes::MatrixType MatrixType
The Matrix type to use to describe hermitian matrices.
C++ types for describing dense density matrices in various parameterizations.
DMTypes_ DMTypes
The C++ types for quantum objects and parameterizations.
VectorParamNdofType rhoToA(const Eigen::Ref< const MatrixType > &rho) const
Compute the A Parameterization of a hermitian matrix.
Basic utilities for dealing with Eigen matrices and other types.
DMTypes::RealScalar RealScalar
The real scalar type. Usually this is double.
const MatrixType & getLambda(std::size_t j) const
Generalized Gell-Mann matrices.
Some C++ utilities, with a tad of C++11 tricks.
double RealScalar
Real type for general calculation precisions (density matrix elements, log-likelihood value calculati...
Parameterization of density matrices in su(N) generators.
ParamA(DMTypes dmt_)
Construct an object which can perform A parameterization transformations.
DMTypes::VectorParamNdofType VectorParamNdofType
The Matrix type to use to describe the A Parameterization of a hermitian matrix.
#define tomographer_assert(...)
Assertion test macro.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.