27 #ifndef QIT_PARAM_RHO_A_H
28 #define QIT_PARAM_RHO_A_H
38 #include <Eigen/StdVector>
43 #include <boost/math/constants/constants.hpp>
51 namespace tomo_internal
54 template<
typename MatrQ_,
typename Coeffs>
55 struct GenGellMannFunctor12
59 GenGellMannFunctor12(MatrQ matq_, MatIndex j_, MatIndex k_)
65 eigen_assert(k <= (MatIndex)matq.dim());
71 template<
typename Index>
74 if (row == j && col == k) {
75 return Coeffs::CoeffJK();
77 if (row == k && col == j) {
78 return Coeffs::CoeffKJ();
84 template<
typename MatrQ>
89 template<
typename MatrQ>
95 template<
typename MatrQ>
96 struct GenGellMannFunctor1
98 typedef GenGellMannFunctor12<MatrQ, coeffs1<MatrQ> > type;
100 template<
typename MatrQ>
101 struct GenGellMannFunctor2
103 typedef GenGellMannFunctor12<MatrQ, coeffs2<MatrQ> > type;
107 template<
typename MatrQ_>
108 struct GenGellMannFunctor3
110 typedef GenGellMannFunctor3<MatrQ_> type;
112 typedef MatrQ_ MatrQ;
116 GenGellMannFunctor3(MatrQ matq_, MatIndex l_)
121 normalization =
std::sqrt( RealScalar(2) / ((l+1)*(l+2)) );
122 eigen_assert(l < (MatIndex)matq.dim()-1);
126 RealScalar normalization;
128 template<
typename Index>
133 }
else if (row <= l) {
134 return normalization;
135 }
else if (row == l+1) {
136 return - (l+1) * normalization;
151 template<
typename MatrQ,
typename coeffs>
152 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor12<MatrQ, coeffs> >
154 enum { Cost = 4*NumTraits<typename MatrQ::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true };
157 template<
typename MatrQ,
typename coeffs>
158 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor12<MatrQ, coeffs> >
159 {
enum { ret = 0 }; };
161 template<
typename MatrQ>
162 struct functor_traits<
Tomographer::tomo_internal::GenGellMannFunctor3<MatrQ> >
163 {
enum { Cost = 4*NumTraits<typename MatrQ::ComplexScalar>::AddCost, PacketAccess =
false, IsRepeatable =
true }; };
165 template<
typename MatrQ>
166 struct functor_has_linear_access<
Tomographer::tomo_internal::GenGellMannFunctor3<MatrQ> >
167 {
enum { ret = 0 }; };
182 template<
typename MatrQ_>
213 lambda.
resize(matq.ndof());
218 lambda[count] = MatrixType::NullaryExpr(
221 typename tomo_internal::GenGellMannFunctor1<MatrQ>::type(matq, j, k)
229 lambda[count] = MatrixType::NullaryExpr(
232 typename tomo_internal::GenGellMannFunctor2<MatrQ>::type(matq, j, k)
239 lambda[count] = MatrixType::NullaryExpr(
242 typename tomo_internal::GenGellMannFunctor3<MatrQ>::type(matq, l)
247 eigen_assert(count == lambda.
size());
269 eigen_assert(j < matq.ndof());
283 eigen_assert((
std::size_t)a.size() == matq.ndof());
284 eigen_assert((
std::size_t)rho.rows() == matq.dim());
285 eigen_assert((
std::size_t)rho.cols() == matq.dim());
287 a(n) = (rho * lambda[n].template selfadjointView<Eigen::Lower>())
288 .real().trace() * boost::math::constants::half_root_two<RealScalar>();
298 RealScalar trace = 1.0)
const
300 eigen_assert((
std::size_t)a.size() == matq.ndof());
301 eigen_assert((
std::size_t)rho.rows() == matq.dim());
302 eigen_assert((
std::size_t)rho.cols() == matq.dim());
303 rho = trace * MatrixType::Identity(rho.rows(), rho.cols()) / matq.dim();
305 rho += a(n) * lambda[n].template selfadjointView<Eigen::Lower>()
306 * boost::math::constants::half_root_two<RealScalar>();
Base namespace for the Tomographer project.
void aToRho(Eigen::Ref< MatrixType > rho, const Eigen::Ref< const VectorParamNdofType > &a, RealScalar trace=1.0) const
Reconstruct a hermitian traceless matrix from its A Parameterization.
Parameterization of density matrices in su(N) generators.
internal::traits< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::Index Index
void rhoToA(Eigen::Ref< VectorParamNdofType > a, const Eigen::Ref< const MatrixType > &rho) const
Compute the A Parameterization of a hermitian matrix.
MatrQ::RealScalar RealScalar
The real scalar type. Usually this is double.
MatrQ_ MatrQ
The C++ types for quantum objects and parameterizations.
Define types for quantum objects. See Tomographer::MatrQ.
MatrQ::VectorParamNdofType VectorParamNdofType
The Matrix type to use to describe the A Parameterization of a hermitian matrix.
const MatrixType & getLambda(std::size_t j) const
Generalized Gell-Mann matrices.
tomo_internal::matrq_traits< MatrQ< FixedDim_, FixedMaxParamList_, RealScalar_, IntFreqType_ > >::RealScalar RealScalar
Real scalar type (usually double)
tomo_internal::matrq_traits< MatrQ< FixedDim_, FixedMaxParamList_, RealScalar_, IntFreqType_ > >::ComplexScalar ComplexScalar
Complex scalar type (usually std::complex)
ParamRhoA(MatrQ matq_)
Construct an object which can perform A parameterization transformations.
MatrQ::MatrixType MatrixType
The Matrix type to use to describe hermitian matrices.
Basic utilities for dealing with Eigen matrices and other types.