pygsti.algorithms.contract

pygsti.algorithms.contract(gateset, toWhat, dataset=None, maxiter=1000000, tol=0.01, useDirectCP=True, method='Nelder-Mead', verbosity=0)

Contract a GateSet to a specified space.

All contraction operations except ‘vSPAM’ operate entirely on the gate matrices and leave state preparations and measurments alone, while ‘vSPAM’ operations only on SPAM.

Parameters:
  • gateset (GateSet) – The gateset to contract
  • toWhat (string) –

    Specifies which space is the gateset is contracted to. Allowed values are:

    • ‘TP’ – All gates are manifestly trace-preserving maps.
    • ‘CP’ – All gates are manifestly completely-positive maps.
    • ‘CPTP’ – All gates are manifestly completely-positive and trace-preserving maps.
    • ‘XP’ – All gates are manifestly “experimentally-positive” maps.
    • ‘XPTP’ – All gates are manifestly “experimentally-positive” and trace-preserving maps.
    • ‘vSPAM’ – state preparation and measurement operations are valid.
    • ‘nothing’ – no contraction is performed.
  • dataset (DataSet, optional) – Dataset to use to determine whether a gateset is in the “experimentally-positive” (XP) space. Required only when contracting to XP or XPTP.
  • maxiter (int, optional) – Maximum number of iterations for iterative contraction routines.
  • tol (float, optional) – Tolerance for iterative contraction routines.
  • useDirectCP (bool, optional) – Whether to use a faster direct-contraction method for CP contraction. This method essentially transforms to the Choi matrix, truncates any negative eigenvalues to zero, then transforms back to a gate matrix.
  • method (string, optional) – The method used when contracting to XP and non-directly to CP (i.e. useDirectCP == False).
  • verbosity (int, optional) – How much detail to send to stdout.
Returns:

The contracted gateset

Return type:

GateSet