27 #ifndef TOMOGRAPHER_DENSEDM_PARAM_RHO_A_H 28 #define TOMOGRAPHER_DENSEDM_PARAM_RHO_A_H 38 #include <Eigen/StdVector> 44 #include <boost/math/constants/constants.hpp> 52 namespace tomo_internal
55 template<
typename DMTypes_,
typename Coeffs>
56 struct GenGellMannFunctor12
58 typedef DMTypes_ DMTypes;
59 typedef typename DMTypes::MatrixType::Index MatIndex;
60 GenGellMannFunctor12(DMTypes matq_, MatIndex j_, MatIndex k_)
65 tomographer_assert(j < k);
66 tomographer_assert(k <= (MatIndex)matq.dim());
72 template<
typename Index>
73 inline const typename DMTypes::ComplexScalar operator() (Index row, Index col)
const 75 if (row == j && col == k) {
76 return Coeffs::CoeffJK();
78 if (row == k && col == j) {
79 return Coeffs::CoeffKJ();
85 template<
typename DMTypes>
87 static inline typename DMTypes::ComplexScalar CoeffJK() {
return typename DMTypes::ComplexScalar(1, 0); }
88 static inline typename DMTypes::ComplexScalar CoeffKJ() {
return typename DMTypes::ComplexScalar(1, 0); }
90 template<
typename DMTypes>
92 static inline typename DMTypes::ComplexScalar CoeffJK() {
return typename DMTypes::ComplexScalar(0, -1); }
93 static inline typename DMTypes::ComplexScalar CoeffKJ() {
return typename DMTypes::ComplexScalar(0, +1); }
96 template<
typename DMTypes>
97 struct GenGellMannFunctor1
99 typedef GenGellMannFunctor12<DMTypes, coeffs1<DMTypes> > type;
101 template<
typename DMTypes>
102 struct GenGellMannFunctor2
104 typedef GenGellMannFunctor12<DMTypes, coeffs2<DMTypes> > type;
108 template<
typename DMTypes_>
109 struct GenGellMannFunctor3
111 typedef GenGellMannFunctor3<DMTypes_> type;
113 typedef DMTypes_ DMTypes;
114 typedef typename DMTypes::RealScalar RealScalar;
115 typedef typename DMTypes::MatrixType::Index MatIndex;
117 GenGellMannFunctor3(DMTypes matq_, MatIndex l_)
122 normalization =
std::sqrt( RealScalar(2) / ((l+1)*(l+2)) );
123 tomographer_assert(l < (MatIndex)matq.dim()-1);
127 RealScalar normalization;
129 template<
typename Index>
130 inline const typename DMTypes::ComplexScalar operator() (Index row, Index col)
const 134 }
else if (row <= l) {
135 return normalization;
136 }
else if (row == l+1) {
137 return - (l+1) * normalization;
151 template<
typename DMTypes,
typename coeffs>
152 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor12<DMTypes, coeffs> >
154 enum { Cost = 4*NumTraits<typename DMTypes::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true };
157 template<
typename DMTypes,
typename coeffs>
158 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor12<DMTypes, coeffs> >
159 {
enum { ret = 0 }; };
161 template<
typename DMTypes>
162 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor3<DMTypes> >
163 {
enum { Cost = 4*NumTraits<typename DMTypes::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true }; };
165 template<
typename DMTypes>
166 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor3<DMTypes> >
167 {
enum { ret = 0 }; };
184 template<
typename DMTypes_>
215 lambda.
resize(_dmt.ndof());
220 lambda[count] = MatrixType::NullaryExpr(
223 typename tomo_internal::GenGellMannFunctor1<DMTypes>::type(_dmt, j, k)
231 lambda[count] = MatrixType::NullaryExpr(
234 typename tomo_internal::GenGellMannFunctor2<DMTypes>::type(_dmt, j, k)
241 lambda[count] = MatrixType::NullaryExpr(
244 typename tomo_internal::GenGellMannFunctor3<DMTypes>::type(_dmt, l)
249 tomographer_assert(count == lambda.
size());
250 tomographer_assert(count == (
std::size_t)_dmt.ndof());
271 tomographer_assert(j < _dmt.ndof());
283 inline VectorParamNdofType
286 VectorParamNdofType a(_dmt.initVectorParamNdofType());
287 tomographer_assert((
std::size_t)a.size() == _dmt.ndof());
288 tomographer_assert((
std::size_t)rho.rows() == _dmt.dim());
289 tomographer_assert((
std::size_t)rho.cols() == _dmt.dim());
291 a(n) = (rho * lambda[n].template selfadjointView<Eigen::Lower>())
292 .real().trace() * boost::math::constants::half_root_two<RealScalar>();
305 MatrixType rho(_dmt.initMatrixType());
306 tomographer_assert((
std::size_t)a.size() == _dmt.ndof());
307 tomographer_assert((
std::size_t)rho.rows() == _dmt.dim());
308 tomographer_assert((
std::size_t)rho.cols() == _dmt.dim());
309 rho = trace * MatrixType::Identity(rho.rows(), rho.cols()) / _dmt.dim();
311 rho += a(n) * lambda[n].template selfadjointView<Eigen::Lower>()
312 * boost::math::constants::half_root_two<RealScalar>();
Base namespace for the Tomographer project.
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.
MatrixType aToRho(const Eigen::Ref< const VectorParamNdofType > &a, RealScalar trace=1.0) const
Reconstruct a hermitian traceless matrix from its A Parameterization.
Basic utilities for dealing with Eigen matrices and other types.
DMTypes::RealScalar RealScalar
The real scalar type. Usually this is double.
VectorParamNdofType rhoToA(const Eigen::Ref< const MatrixType > &rho) const
Compute the A Parameterization of a hermitian matrix.
Some C++ utilities, with a tad of C++11 tricks.
const MatrixType & getLambda(std::size_t j) const
Generalized Gell-Mann matrices.
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.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.