27 #ifndef DMLLHINTEGRATOR_H
28 #define DMLLHINTEGRATOR_H
41 #include <boost/math/constants/constants.hpp>
69 template<
typename TomoProblem,
typename Rng,
typename Log>
74 typedef typename TomoProblem::MatrQ
MatrQ;
99 const TomoProblem & _tomo;
118 _normal_distr_rnd(0.0, 1.0),
135 _log.debug(
"DMStateSpaceLLHMHWalker",
"Starting random walk");
141 if (_startpt.norm() > 1e-3) {
147 MatrixType T = _tomo.matq.initMatrixType();
148 T = dense_random<MatrixType>(
149 _rng, _normal_distr_rnd, _tomo.matq.dim(), _tomo.matq.dim()
151 _startpt = T/T.norm();
153 _log.debug(
"DMStateSpaceLLHMHWalker", [&T](
std::ostream & str) {
154 str <<
"Chosen random start point T = \n" << T;
179 MatrixType rho = _tomo.matq.initMatrixType();
180 rho.noalias() = T*T.adjoint();
182 VectorParamType x = _tomo.matq.initVectorParamType();
185 LLHValueType llhval = -boost::math::constants::half<RealScalar>() * _tomo.calc_llh(x);
191 inline MatrixType
jump_fn(
const MatrixType& cur_T, RealScalar step_size)
193 MatrixType DeltaT = dense_random<MatrixType>(
194 _rng, _normal_distr_rnd, _tomo.matq.dim(), _tomo.matq.dim()
197 MatrixType new_T = _tomo.matq.initMatrixType();
199 new_T.noalias() = cur_T + step_size * DeltaT;
202 new_T /= new_T.norm();
221 template<
typename TomoProblem_,
typename F
idValueType_ =
double>
225 typedef TomoProblem_ TomoProblem;
226 typedef typename TomoProblem::MatrQ MatrQ;
238 : _ref_T(tomo.matq.initMatrixType())
244 : _ref_T(tomo.matq.initMatrixType())
249 inline ValueType getValue(
const MatrixType & T)
const
251 return fidelity_T<ValueType>(T, _ref_T);
262 template<
typename TomoProblem_,
typename ValueType_ =
double>
266 typedef TomoProblem_ TomoProblem;
267 typedef typename TomoProblem::MatrQ MatrQ;
279 : _ref_T(tomo.matq.initMatrixType())
285 : _ref_T(tomo.matq.initMatrixType())
290 inline ValueType getValue(
const MatrixType & T)
const
292 auto F = fidelity_T<ValueType>(T, _ref_T);
300 template<
typename TomoProblem_,
typename TrDistValueType_ =
double>
304 typedef TomoProblem_ TomoProblem;
305 typedef typename TomoProblem::MatrQ MatrQ;
317 : _ref_rho(tomo.matq.initMatrixType())
319 _ref_rho = tomo.rho_MLE;
323 : _ref_rho(tomo.matq.initMatrixType())
328 inline ValueType getValue(
const MatrixType & T)
const
330 return boost::math::constants::half<ValueType>() *
331 (T*T.adjoint() - _ref_rho).
template selfadjointView<Eigen::Lower>()
332 .eigenvalues().cwiseAbs().sum();
339 template<
typename TomoProblem_>
343 typedef TomoProblem_ TomoProblem;
344 typedef typename TomoProblem::MatrQ MatrQ;
352 const TomoProblem & _tomo;
355 VectorParamType _A_x;
363 _A_x(tomo.matq.initVectorParamType())
371 _A_x(tomo.matq.initVectorParamType())
376 inline ValueType getValue(
const MatrixType & T)
const
378 MatrixType rho = _tomo.matq.initMatrixType();
380 VectorParamType x = _tomo.matq.initVectorParamType();
382 return _A_x.transpose() * x;
PurifDistToRefCalculator(const TomoProblem &tomo, const MatrixType &T_ref)
Constructor, the reference state is T_ref (in T Parameterization)
TrDistValueType_ ValueType
For ValueCalculator interface : value type.
Eigen::Matrix< std::complex< RealScalar >, FixedDim, FixedDim > MatrixType
Complex dim x dim Matrix.
LLHValueType fnlogval(const MatrixType &T)
Calculate the logarithm of the Metropolis-Hastings function value.
Base namespace for the Tomographer project.
FidelityToRefCalculator(const TomoProblem &tomo)
Constructor, take the reference state to be the MLE.
Calculate the trace distance to a reference state for each sample.
MatrixType PointType
Provided for MHRandomWalk. A point in our random walk = a density matrix.
LLHValueType FnValueType
Provided for MHRandomWalk. The function value type is the loglikelihood value type.
TomoProblem::LLHValueType LLHValueType
The loglikelihood function value type (see IndepMeasTomoProblem)
TrDistToRefCalculator(const TomoProblem &tomo)
Constructor, take the reference state to be the MLE.
FidValueType_ ValueType
For ValueCalculator interface : value type.
void init()
Provided for MHRandomWalk. Initializes some fields and prepares for a random walk.
MatrixType jump_fn(const MatrixType &cur_T, RealScalar step_size)
Decides of a new point to jump to for the random walk.
PurifDistToRefCalculator(const TomoProblem &tomo)
Constructor, take the reference state to be the MLE.
MatrQ::RealScalar ValueType
For ValueCalculator interface : value type.
TrDistToRefCalculator(const TomoProblem &tomo, const MatrixType &rho_ref)
Constructor, the reference state is rho_ref.
TomoProblem::MatrQ MatrQ
The data types of our problem.
MatrQ::ComplexScalar ComplexScalar
The complex real scalar corresponding to our data types. Usually a std::complex.
Data corresponding to a quantum tomography setting.
MatrQ::MatrixType MatrixType
The matrix type for a density operator on our quantum system.
Calculate the "purified distance" to a reference state for each sample.
tomo_internal::matrq_traits< MatrQ< FixedDim_, FixedMaxParamList_, RealScalar_, IntFreqType_ > >::RealScalar RealScalar
Real scalar type (usually double)
MatrQ::RealScalar RealScalar
The real scalar corresponding to our data types. Usually a double.
Calculate the fidelity to a reference state for each sample.
Distance measures in Quantum Information Theory – e.g. fidelity.
tomo_internal::matrq_traits< MatrQ< FixedDim_, FixedMaxParamList_, RealScalar_, IntFreqType_ > >::ComplexScalar ComplexScalar
Complex scalar type (usually std::complex)
Provides the logarithm MH function value at each point (see Role of UseFnSyntaxType) ...
void done()
Callback for after random walk is finished. No-op.
A random walk in the density matrix space of a Hilbert state space of a quantum system.
void thermalizing_done()
Callback for after thermalizing is done. No-op.
FidelityToRefCalculator(const TomoProblem &tomo, const MatrixType &T_ref)
Constructor, the reference state is T_ref (in T Parameterization)
ObservableValueCalculator(const TomoProblem &tomo, const VectorParamType &A_x)
Constructor directly accepting the X parameterization of A.
Routines for performing a Metropolis-Hastings random walk.
ObservableValueCalculator(const TomoProblem &tomo, const MatrixType &A)
Constructor directly accepting A as a hermitian matrix.
DMStateSpaceLLHMHWalker(const MatrixType &startpt, const TomoProblem &tomo, Rng &rng, Log &log_)
Constructor which just initializes the given fields.
Basic utilities for dealing with Eigen matrices and other types.
const MatrixType & startpoint()
Return the starting point given in the constructor, or a random start point.
Calculate expectation value of an observable for each sample.
Utilities for logging messages.
ValueType_ ValueType
For ValueCalculator interface : value type.
MatrQ::VectorParamType VectorParamType
Type of an X-parameterization of a density operator (see param_x_to_herm())
We will calculate the log-likelihood function, which is the logarithm of the Metropolis-Hastings func...
void param_herm_to_x(Eigen::DenseBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &Herm)
Get the X-parameterization corresponding to a given hermitian matrix.