pygsti.modelmembers.term
Defines classes which represent terms in gate expansions
Module Contents
Classes
An operation, like a gate, that maps a density matrix to another density matrix but in a restricted way. |
|
A state preparation term. |
|
A POVM effect term. |
|
An operation term. |
|
A state preparation term with magnitude tracking. |
|
A POVM effect term with magnitude tracking. |
|
An operation term with magnitude tracking. |
|
A state preparation term with polynomial coefficient. |
|
A POVM effect term with polynomial coefficient. |
|
An operation term with polynomial coefficient. |
|
A state preparation term with polynomial coefficient and magnitude tracking. |
|
A POVM effect term with polynomial coefficient and magnitude tracking. |
|
An operation term with polynomial coefficient and magnitude tracking. |
|
A state preparation term with numerical coefficient (and no magnitude tracking). |
|
A POVM effect term with numerical coefficient (and no magnitude tracking). |
|
An operation term with numerical coefficient (and no magnitude tracking). |
Functions
|
Compose multiple terms and set the resulting term's magnitude. |
|
Compose a sequence of terms. |
|
Exponentiate a list of terms. |
|
Exponentiate a list of terms with magnitude above min_term_mag. |
- pygsti.modelmembers.term.compose_terms_with_mag(terms, magnitude)
Compose multiple terms and set the resulting term’s magnitude.
Usually, for performance reasons, the magnitude of a composed term is not set. This function explicitly does so.
Parameters
- termssequence
A sequence of
RankOneTerm
objects.- magnitudefloat
The magnitude of the compsed term.
Returns
RankOneTerm
- pygsti.modelmembers.term.compose_terms(terms)
Compose a sequence of terms.
Composition is done with time ordered left-to-right. Thus composition order is NOT the same as usual matrix order. E.g. if there are three terms: terms[0] = T0: rho -> A*rho*A terms[1] = T1: rho -> B*rho*B terms[2] = T2: rho -> C*rho*C Then the resulting term T = T0*T1*T2 : rho -> CBA*rho*ABC, so that term[0] is applied first not last to a state.
Parameters
- termslist
A list of
RankOneTerm
objects to compose.
Returns
RankOneTerm
- pygsti.modelmembers.term.exponentiate_terms(terms, order, postterm, cache=None, order_base=None)
Exponentiate a list of terms.
This function collects those terms of the orders given in orders. Optionally post-multiplies the single term postterm (so this term actually acts before the exponential-derived terms).
Parameters
- termslist
The list of terms to exponentiate. All these terms are considered “first order” terms.
- orderint
An integers specifying the order of the terms to collect.
- posttermRankOneTerm
A term that is composed first (so “post” in the sense of matrix multiplication, not composition). May be the identity (no-op) term.
- cachedict, optional
A dictionary used to cache results for speeding up repeated calls to this function. Usually an empty dictionary is supplied to the first call.
- order_basefloat, optional
What constitutes 1 order of magnitude. If None, then polynomial coefficients are used.
Returns
- list
A list of
RankOneTerm
objects giving the terms at order.
- pygsti.modelmembers.term.exponentiate_terms_above_mag(terms, order, postterm, cache=None, min_term_mag=None)
Exponentiate a list of terms with magnitude above min_term_mag.
This function collects those terms of the orders given in orders. Optionally post-multiplies the single term postterm (so this term actually acts before the exponential-derived terms).
Parameters
- termslist
The list of terms to exponentiate. All these terms are considered “first order” terms.
- orderint
Integer specifying the order to compute.
- posttermRankOneTerm
A term that is composed first (so “post” in the sense of matrix multiplication, not composition).
- cachedict, optional
A cache to speedup repeated calls. Currently unused because min_term_mag is likely to be different on every call.
- min_term_magfloat, optional
The minimum term magnitude.
Returns
list
- class pygsti.modelmembers.term.RankOneTerm(rep, evotype)
Bases:
object
An operation, like a gate, that maps a density matrix to another density matrix but in a restricted way.
While a RankOneTerm doesn’t have to map pure states to pure states, its action can be written:
rho -> A*rho*B
Where A and B are unitary state operations. This means that if rho can be written rho = |psi1><psi2| then the action of a RankOneTerm preserves the separable nature or rho (which need not always be a valid density matrix since it can be just a portion of one).
A RankOneTerm anticipates its application to “separable” (as defined above) states, and can even be used to represent such a separable state or an analagous POVM effect. This occurs when the first element of pre_ops and post_ops is a preparation or POVM effect vector instead of a gate operation.
Note that operations are stored in composition (time) order rather than matrix order, and that adjoint operations are stored in post_ops so that they can be applied directly to the adjoint of the “bra” part of the state (which is a “ket” - a usual state).
Finally, a coefficient (usually a number or a
Polynomial
) is held, representing the prefactor for this term as a part of a larger density matrix evolution.Parameters
- repSVTermRep or SBTermRep
The term representation object the acts as the core of this term.
- torep()
Access to the underlying representation object.
- class pygsti.modelmembers.term.RankOnePrepTerm(rep, evotype)
Bases:
RankOneTerm
,_NoMagnitude
A state preparation term.
- classmethod create_from(coeff, pre_state, post_state, evotype, state_space)
Creates a
RankOnePrepTerm
using natural arguments.Parameters
- coeffPolynomial or complex
The term’s coefficient.
- pre_stateState or StateRep or numpy.ndarray
The ‘ket’ (left-side) state of the operator.
- post_stateState or StateRep or numpy.ndarray
The ‘bra’ (right-side) state of the operator
- evotypeEvotype or str
The evolution type
- state_spaceStateSpace or str
The state space of this term.
Returns
RankOnePrepTerm
- class pygsti.modelmembers.term.RankOneEffectTerm(rep, evotype)
Bases:
RankOneTerm
,_NoMagnitude
A POVM effect term.
- classmethod create_from(coeff, pre_effect, post_effect, evotype, state_space)
Creates a
RankOneEffectTerm
using natural arguments.Parameters
- coeffPolynomial or complex
The term’s coefficient.
- pre_effectPOVMEffect or EffectRep or numpy.ndarray
The ‘bra’ (left-side) effect of the operator.
- post_effectPOVMEffect or EffectRep or numpy.ndarray
The ‘ket’ (right-side) effect of the operator
- evotypeEvotype or str
The evolution type
- state_spaceStateSpace or str
The state space of this term.
Returns
RankOneEffectTerm
- class pygsti.modelmembers.term.RankOneOpTerm(rep, evotype)
Bases:
RankOneTerm
,_NoMagnitude
An operation term.
- classmethod create_from(coeff, pre_op, post_op, evotype, state_space)
Creates a
RankOneOpTerm
using natural arguments.Parameters
- coeffPolynomial or complex
The term’s coefficient.
- pre_opLinearOperator or OpRep or numpy.ndarray
The left-side operator, i.e. A in rho => A rho B^dag.
- post_opLinearOperator or OpRep or numpy.ndarray
The right-side operator, i.e. B in rho => A rho B^dag.
- evotypeEvotype or str
The evolution type
- state_spaceStateSpace or str
The state space of this term.
Returns
RankOneOpTerm
- class pygsti.modelmembers.term.RankOnePrepTermWithMagnitude(rep, evotype)
Bases:
RankOneTerm
,_HasMagnitude
A state preparation term with magnitude tracking.
- class pygsti.modelmembers.term.RankOneEffectTermWithMagnitude(rep, evotype)
Bases:
RankOneTerm
,_HasMagnitude
A POVM effect term with magnitude tracking.
- class pygsti.modelmembers.term.RankOneOpTermWithMagnitude(rep, evotype)
Bases:
RankOneTerm
,_HasMagnitude
An operation term with magnitude tracking.
- class pygsti.modelmembers.term.RankOnePolynomialPrepTerm(rep, evotype)
Bases:
RankOnePrepTerm
,_HasPolynomialCoefficient
A state preparation term with polynomial coefficient.
- class pygsti.modelmembers.term.RankOnePolynomialEffectTerm(rep, evotype)
Bases:
RankOneEffectTerm
,_HasPolynomialCoefficient
A POVM effect term with polynomial coefficient.
- class pygsti.modelmembers.term.RankOnePolynomialOpTerm(rep, evotype)
Bases:
RankOneOpTerm
,_HasPolynomialCoefficient
An operation term with polynomial coefficient.
- class pygsti.modelmembers.term.RankOnePolynomialPrepTermWithMagnitude(rep, evotype)
Bases:
RankOnePrepTermWithMagnitude
,_HasPolynomialCoefficient
A state preparation term with polynomial coefficient and magnitude tracking.
- class pygsti.modelmembers.term.RankOnePolynomialEffectTermWithMagnitude(rep, evotype)
Bases:
RankOneEffectTermWithMagnitude
,_HasPolynomialCoefficient
A POVM effect term with polynomial coefficient and magnitude tracking.
- class pygsti.modelmembers.term.RankOnePolynomialOpTermWithMagnitude(rep, evotype)
Bases:
RankOneOpTermWithMagnitude
,_HasPolynomialCoefficient
An operation term with polynomial coefficient and magnitude tracking.
- class pygsti.modelmembers.term.RankOneDirectPrepTerm(rep, evotype)
Bases:
RankOnePrepTerm
,_HasNumericalCoefficient
A state preparation term with numerical coefficient (and no magnitude tracking).
- class pygsti.modelmembers.term.RankOneDirectEffectTerm(rep, evotype)
Bases:
RankOneEffectTerm
,_HasNumericalCoefficient
A POVM effect term with numerical coefficient (and no magnitude tracking).
- class pygsti.modelmembers.term.RankOneDirectOpTerm(rep, evotype)
Bases:
RankOneOpTerm
,_HasNumericalCoefficient
An operation term with numerical coefficient (and no magnitude tracking).