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 log-likelihood 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 X-parameterization of a Hermitian matrix (and back). See the definition of the X Parameterization for more info. The X-parameterization 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 read-only.

This class is pickleable.

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 dim2-1

class tomographer.densedm.IndepMeasLLH

Bases: pybind11_builtins.pybind11_object

Stores measurement data and calculates the log-likelihood 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 pickleable.

IndepMeasLLH(dmt)

Constructor. Specify the system dimension in the dmt argument. The latter must be an DMTypes instance.

dmt

The DMTypes instance storing the dimension of the system. This is a read-only attribute.

numEffects

The number of separate POVM effects recorded. See resetMeas(), addMeasEffect() and setMeas().

Exn([k])

If k is not specified, then return the matrix of all POVM effects in X-parameterization. Each row of the returned matrix is a POVM effect in X-parameterization.

If k is specified, then only the given POVM effect indexed by k is returned. It is given in X parameterization, as a 1-D 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 1-D 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 1-D 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 log-likelihood function at the state rho, specified by its density matrix given as a NumPy array. This overload converts its argument to X-parameterization and calls logLikelihoodX().

logLikelihoodX(x)

Calculate the log-likelihood function. The argument is the X parameterization of the state at which the log-likelihood should be evaluated. The log-likelihood 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() or addMeasEffect().

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 X-parameterization if a POVM effect, if a 1-D array is specified, or as the matrix representation of the POVM effect. For example, E may be

  • a list of complex 2-D NumPy arrays, specifying the list of POVM effects in matrix representation;
  • a 3-D 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 X-parameterization of a POVM effect;
  • a list of 1-D 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 X-parameterization 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 X-parameterization of the Hermitian matrix Herm. Returns a 1-D 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 X-parameterization vector. The vector is expected to be a numpy.array object. Returns a 2-D numpy.array object containing the full Hermitian matrix.