Storing Tomography Data and Calculating the Likelihood Function (tomographer.densedm)¶
Classes and utilities for handling a tomography setup in which quantum states are represented via their density operator stored as dense matrices in memory.
The DMTypes
class stores the quantum system dimension, and is used by the other types.
The IndepMeasLLH
class is capable of storing measurement data (resulting from independent measurement effects on each system) and calculating the corresponding loglikelihood function. (Note that this still allows for correlated measurements such as adaptive tomography, it just prohibits truly quantum joint measurements over the different copies.)
The ParamX
allows to calculate the Xparameterization of a Hermitian matrix (and back). See the definition of the X Parameterization for more info. The Xparameterization is used, e.g., by the IndepMeasLLH
class to store the POVM effects and to calculate inner products more efficiently.

class
tomographer.densedm.
DMTypes
¶ Bases:
pybind11_builtins.pybind11_object
Stores the dimension of the quantum system, the square of the dimension and the number of degrees of freedom.
All attributes of this class are readonly.
This class is
pickle
able.
DMTypes
(dim)¶ Construct a DMTypes object storing the given dimension for the quantum system.

dim
¶ The dimension of the quantum system.

dim2
¶ The square of the dimension.

ndof
¶ The number of degrees of freedom. This is dim21


class
tomographer.densedm.
IndepMeasLLH
¶ Bases:
pybind11_builtins.pybind11_object
Stores measurement data and calculates the loglikelihood function.
Measurements are specified as a list of observed POVM effects along with frequencies, i.e., how many times each POVM effect was observed.
POVM effects are stored internally in X parameterization. See here for more details.
This Python class is a wrapper for the C++ class Tomographer::DenseDM::IndepMeasLLH.
This class is
pickle
able.
IndepMeasLLH
(dmt)¶ Constructor. Specify the system dimension in the dmt argument. The latter must be an
DMTypes
instance.

numEffects
¶ The number of separate POVM effects recorded. See
resetMeas()
,addMeasEffect()
andsetMeas()
.

Exn
([k])¶ If k is not specified, then return the matrix of all POVM effects in Xparameterization. Each row of the returned matrix is a POVM effect in Xparameterization.
If k is specified, then only the given POVM effect indexed by k is returned. It is given in X parameterization, as a 1D array.
In any case, the returned value is a numpy.array object.

Nx
([k])¶ If k is not specified, then return a list of frequencies associated to each row of the matrix returned by
Exn()
. The return value is a 1D NumPy array.If k is specified, then return the frequency associated to the POVM effect indexed by k. The returned value is an integer.

addMeasEffect
(E, n[, check_validity=True])¶ Add an observed POVM effect and a corresponding frequency. The argument E may be a 1D NumPy array, in wihch case it is assumed to carry the X parameterization of the POVM effect. Otherwise, E should be a complex square matrix describing the POVM effect in its usual matrix form. In any case, n is an integer specifying how many times this POVM effect was observed (it may be set to 1).
If check_validity is True, then some consistency checks are performed on the POVM effect, such as verifying it for positive semidefiniteness.

logLikelihoodRho
(rho)¶ Calculate the loglikelihood function at the state rho, specified by its density matrix given as a NumPy array. This overload converts its argument to Xparameterization and calls
logLikelihoodX()
.

logLikelihoodX
(x)¶ Calculate the loglikelihood function. The argument is the X parameterization of the state at which the loglikelihood should be evaluated. The loglikelihood function is defined as \(\ln\Lambda(\rho) = \sum_k N_k \ln\operatorname{tr}(E_k\cdot\rho)\), where \(E_k\) is the POVM effect indexed by k and \(N_k\) is the corresponding frequency.

resetMeas
()¶ Forget any stored POVM effects. The internal Exn and Nx objects are cleared. You may start adding POVM effects with
setMeas()
oraddMeasEffect()
.

setMeas
(E, Nx[, check_validity=True])¶ Set all the measurement data in one go and clear any previously given measurement data.
The object E is iterated over (if it is a NumPy array, the iteration goes over the first dimension) and each element is interpreted as a POVM effect. Each element is understood as for
addMeasEffect()
either as the Xparameterization if a POVM effect, if a 1D array is specified, or as the matrix representation of the POVM effect. For example, E may be a list of complex 2D NumPy arrays, specifying the list of POVM effects in matrix representation;
 a 3D NumPy array, where the first index designates the POVM effect, and the second and third dimension are the matrix dimensions of each POVM effect;
 a matrix (NumPy array) of the same form as returned by
Exn()
, i.e., with each row being the the Xparameterization of a POVM effect;  a list of 1D NumPy arrays specifying the X parameterization of each POVM effect.
The argument Nx must be a list (or numpy.array) specifying the corresponding frequencies for each POVM effect. Nx must be of the same length as E (or, if E is a NumPy array, as the first dimension of E).
If check_validity is True, then some consistency checks are performed on the POVM effects, such as verifying them for positive semidefiniteness.


class
tomographer.densedm.
ParamX
¶ Bases:
pybind11_builtins.pybind11_object
Calculates the Xparameterization of hermitian matrices (and back).
This Python class is a wrapper for the C++ class Tomographer::DenseDM::ParamX.

ParamX
(dmt)¶ Constructor. Pass on a
DMTypes
instance specifying the dimension of the quantum system.

HermToX
(Herm)¶ Calculate the Xparameterization of the Hermitian matrix Herm. Returns a 1D numpy.array object. Only the lower triangluar portion of the matrix is accessed by this method.

XToHerm
(x)¶ Calculate the Hermitian matrix corresponding to the given Xparameterization vector. The vector is expected to be a numpy.array object. Returns a 2D numpy.array object containing the full Hermitian matrix.
