27 #ifndef TOMOGRAPHER_DENSEDM_TSPACELLHWALKER_H 28 #define TOMOGRAPHER_DENSEDM_TSPACELLHWALKER_H 35 #include <boost/math/constants/constants.hpp> 70 template<
typename DenseLLH_,
typename Rng,
typename LoggerType>
78 typedef typename DenseLLH::DMTypes
DMTypes;
109 const DenseLLH & _llh;
130 LLHMHWalker(
const MatrixType & startpt,
const DenseLLH & llh, Rng & rng,
134 _normal_distr_rnd(0.0, 1.0),
146 : _llh(
std::move(moveother._llh)),
147 _rng(moveother._rng),
148 _normal_distr_rnd(moveother._normal_distr_rnd),
149 _px(
std::move(moveother._px)),
150 _log(moveother._log),
151 _startpt(moveother._startpt)
167 _log.debug(
"TSpace::LLHMHWalker",
"Starting random walk");
174 if (_startpt.norm() > 1e-3) {
180 MatrixType T(_llh.dmt.initMatrixType());
181 T = Tools::denseRandom<MatrixType>(
182 _rng, _normal_distr_rnd, _llh.dmt.dim(), _llh.dmt.dim()
184 _startpt = T/T.norm();
186 _log.debug(
"TSpace::LLHMHWalker", [&T](
std::ostream & str) {
187 str <<
"Chosen random start point T = \n" << T;
211 TOMOGRAPHER_ENABLED_IF(DenseLLH::LLHCalcType ==
LLHCalcTypeX)
212 inline LLHValueType
fnLogVal(const MatrixType & T)
const 214 MatrixType rho(T*T.adjoint());
215 VectorParamType x = _px.
HermToX(rho);
216 LLHValueType llhval = _llh.logLikelihoodX(x);
231 LLHValueType llhval = _llh.logLikelihoodRho(T*T.adjoint());
240 MatrixType DeltaT(Tools::denseRandom<MatrixType>(
241 _rng, _normal_distr_rnd, _llh.dmt.dim(), _llh.dmt.dim()
247 new_T /= new_T.norm();
VectorParamType HermToX(MatrixTypeConstRef Herm) const
Get the X-parameterization corresponding to a given hermitian matrix.
void init()
Provided for MHRandomWalk. Initializes some fields and prepares for a random walk.
Base namespace for the Tomographer project.
const MatrixType & startPoint()
Return the starting point given in the constructor, or a random start point.
DMTypes::VectorParamType VectorParamType
Type of an X-parameterization of a density operator (see X Parameterization)
C++ types for describing dense density matrices in various parameterizations.
DenseLLH::DMTypes DMTypes
The data types of our problem.
LLHMHWalker(LLHMHWalker &&moveother)
A MHWalker Interface needs to have a move constructor.
LLHMHWalker(const MatrixType &startpt, const DenseLLH &llh, Rng &rng, LoggerType &log_)
Constructor which just initializes the given fields.
DMTypes::RealScalar RealScalar
The real scalar corresponding to our data types. Usually a double.
DenseLLH::LLHValueType LLHValueType
The loglikelihood function value type (see DenseLLH Interface e.g. IndepMeasLLH)
RealScalar StepRealType
The real scalar type for the step size — this is our scalar type (see MHWalker Interface) ...
MatrixType PointType
Provided for MHRandomWalk. A point in our random walk = a density matrix.
Tools for parameterizing hermitian matrices with the X Parameterization.
Some declarations for the DenseLLH type interface.
A random walk in the density matrix space of a Hilbert state space of a quantum system.
Provides the logarithm MH function value at each point (see Role of UseFnSyntaxType) ...
void done()
Callback for after random walk is finished. No-op.
LLHValueType fnLogVal(const MatrixType &T) const
Calculate the logarithm of the Metropolis-Hastings function value.
DenseLLH_ DenseLLH
The DenseLLH interface object type.
Managing the need for specific overrides to operator new() for some types (especially Eigen types) ...
void thermalizingDone()
Callback for after thermalizing is done. No-op.
LLHValueType FnValueType
Provided for MHRandomWalk. The function value type is the loglikelihood value type.
The DenseLLH-compatible object exposes a method logLikelihoodRho(), taking as argument a (const ref t...
MatrixType jumpFn(const MatrixType &cur_T, RealScalar step_size)
Decides of a new point to jump to for the random walk.
We will calculate the log-likelihood function, which is the logarithm of the Metropolis-Hastings func...
Routines for performing a Metropolis-Hastings random walk.
DMTypes::MatrixType MatrixType
The matrix type for a density operator on our quantum system.
DMTypes::ComplexScalar ComplexScalar
The complex real scalar corresponding to our data types. Usually a std::complex<double>.
The DenseLLH-compatible object exposes a method logLikelihoodX(), taking as argument a (const ref to ...
Utilities for logging messages.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.