pygsti.modelmembers.operations.experrorgenop
¶
The ExpErrorgenOp class and supporting functionality.
Module Contents¶
Classes¶
An operation parameterized by the coefficients of an exponentiated sum of Lindbladlike terms. 
Functions¶





Computes the derivative of the exponential of x(t) using 
Attributes¶
 pygsti.modelmembers.operations.experrorgenop.IMAG_TOL = 1e07¶
 pygsti.modelmembers.operations.experrorgenop.MAX_EXPONENT¶
 pygsti.modelmembers.operations.experrorgenop.SPAM_TRANSFORM_TRUNCATE = 0.0001¶
 class pygsti.modelmembers.operations.experrorgenop.ExpErrorgenOp(errorgen)¶
Bases:
pygsti.modelmembers.operations.linearop.LinearOperator
,pygsti.modelmembers.errorgencontainer.ErrorGeneratorContainer
An operation parameterized by the coefficients of an exponentiated sum of Lindbladlike terms. TODO: update docstring!
The exponentiated terms give the operation’s action.
 Parameters
errorgen (LinearOperator) – The error generator for this operator. That is, the L if this operator is exp(L).
 classmethod _from_memoized_dict(cls, mm_dict, serial_memo)¶
For subclasses to implement. Submemberexistence checks are performed, and the gpindices of the return value is set, by the nonunderscored :method:`from_memoized_dict` implemented in this class.
 submembers(self)¶
Get the ModelMemberderived objects contained in this one.
 Returns
list
 _update_rep(self, close=False)¶
Updates self._rep as needed after parameters have changed.
 set_gpindices(self, gpindices, parent, memo=None)¶
Set the parent and indices into the parent’s parameter vector that are used by this ModelMember object.
 Parameters
gpindices (slice or integer ndarray) – The indices of this objects parameters in its parent’s array.
parent (Model or ModelMember) – The parent whose parameter array gpindices references.
memo (dict, optional) – A memo dict used to avoid circular references.
 Returns
None
 to_dense(self, on_space='minimal')¶
Return this operation as a dense matrix.
 Returns
numpy.ndarray
 to_sparse(self, on_space='minimal')¶
Return the operation as a sparse matrix.
 Parameters
on_space ({'minimal', 'Hilbert', 'HilbertSchmidt'}) – The space that the returned dense operation acts upon. For unitary matrices and bra/ket vectors, use ‘Hilbert’. For superoperator matrices and superbra/superket vectors use ‘HilbertSchmidt’. ‘minimal’ means that ‘Hilbert’ is used if possible given this operator’s evolution type, and otherwise ‘HilbertSchmidt’ is used.
 Returns
scipy.sparse.csr_matrix
 deriv_wrt_params(self, wrt_filter=None)¶
The elementwise derivative this operation.
Construct a matrix whose columns are the vectorized derivatives of the flattened operation matrix with respect to a single operation parameter. Thus, each column is of length op_dim^2 and there is one column per operation parameter.
 Parameters
wrt_filter (list or numpy.ndarray) – List of parameter indices to take derivative with respect to. (None means to use all the this operation’s parameters.)
 Returns
numpy array – Array of derivatives, shape == (dimension^2, num_params)
 has_nonzero_hessian(self)¶
Whether this operation has a nonzero Hessian with respect to its parameters.
(i.e. whether it only depends linearly on its parameters or not)
 Returns
bool
 hessian_wrt_params(self, wrt_filter1=None, wrt_filter2=None)¶
Construct the Hessian of this operation with respect to its parameters.
This function returns a tensor whose first axis corresponds to the flattened operation matrix and whose 2nd and 3rd axes correspond to the parameters that are differentiated with respect to.
 Parameters
wrt_filter1 (list or numpy.ndarray) – List of parameter indices to take 1st derivatives with respect to. (None means to use all the this operation’s parameters.)
wrt_filter2 (list or numpy.ndarray) – List of parameter indices to take 2nd derivatives with respect to. (None means to use all the this operation’s parameters.)
 Returns
numpy array – Hessian with shape (dimension^2, num_params1, num_params2)
 property parameter_labels(self)¶
An array of labels (usually strings) describing this model member’s parameters.
 property num_params(self)¶
Get the number of independent parameters which specify this operation.
 Returns
int – the number of independent parameters.
 to_vector(self)¶
Extract a vector of the underlying operation parameters from this operation.
 Returns
numpy array – a 1D numpy array with length == num_params().
 from_vector(self, v, close=False, dirty_value=True)¶
Initialize the operation using a vector of parameters.
 Parameters
v (numpy array) – The 1D vector of operation parameters. Length must == num_params()
close (bool, optional) – Whether v is close to this operation’s current set of parameters. Under some circumstances, when this is true this call can be completed more quickly.
dirty_value (bool, optional) – The value to set this object’s “dirty flag” to before exiting this call. This is passed as an argument so it can be updated recursively. Leave this set to True unless you know what you’re doing.
 Returns
None
 taylor_order_terms(self, order, max_polynomial_vars=100, return_coeff_polys=False)¶
Get the orderth order Taylorexpansion terms of this operation.
This function either constructs or returns a cached list of the terms at the given order. Each term is “rank1”, meaning that its action on a density matrix rho can be written:
rho > A rho B
The coefficients of these terms are typically polynomials of the operation’s parameters, where the polynomial’s variable indices index the global parameters of the operation’s parent (usually a
Model
), not the operation’s local parameter array (i.e. that returned from to_vector). Parameters
order (int) – Which order terms (in a Taylor expansion of this
LindbladOp
) to retrieve.max_polynomial_vars (int, optional) – maximum number of variables the created polynomials can have.
return_coeff_polys (bool) – Whether a parallel list of locallyindexed (using variable indices corresponding to this object’s parameters rather than its parent’s) polynomial coefficients should be returned as well.
 Returns
terms (list) – A list of
RankOneTerm
objects.coefficients (list) – Only present when return_coeff_polys == True. A list of compact polynomial objects, meaning that each element is a (vtape,ctape) 2tuple formed by concatenating together the output of :method:`Polynomial.compact`.
 _compute_taylor_order_terms(self, order, max_polynomial_vars)¶
 taylor_order_terms_above_mag(self, order, max_polynomial_vars, min_term_mag)¶
Get the orderth order Taylorexpansion terms of this operation that have magnitude above min_term_mag.
This function constructs the terms at the given order which have a magnitude (given by the absolute value of their coefficient) that is greater than or equal to min_term_mag. It calls :method:`taylor_order_terms` internally, so that all the terms at order order are typically cached for future calls.
The coefficients of these terms are typically polynomials of the operation’s parameters, where the polynomial’s variable indices index the global parameters of the operation’s parent (usually a
Model
), not the operation’s local parameter array (i.e. that returned from to_vector). Parameters
order (int) – The order of terms to get (and filter).
max_polynomial_vars (int, optional) – maximum number of variables the created polynomials can have.
min_term_mag (float) – the minimum term magnitude.
 Returns
list – A list of
Rank1Term
objects.
 property total_term_magnitude(self)¶
Get the total (sum) of the magnitudes of all this operator’s terms.
The magnitude of a term is the absolute value of its coefficient, so this function returns the number you’d get from summing up the absolutecoefficients of all the Taylor terms (at all orders!) you get from expanding this operator in a Taylor series.
 Returns
float
 property total_term_magnitude_deriv(self)¶
The derivative of the sum of all this operator’s terms.
Computes the derivative of the total (sum) of the magnitudes of all this operator’s terms with respect to the operators (local) parameters.
 Returns
numpy array – An array of length self.num_params
 transform_inplace(self, s)¶
Update operation matrix O with inv(s) * O * s.
Generally, the transform function updates the parameters of the operation such that the resulting operation matrix is altered as described above. If such an update cannot be done (because the operation parameters do not allow for it), ValueError is raised.
 Parameters
s (GaugeGroupElement) – A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.
 Returns
None
 spam_transform_inplace(self, s, typ)¶
Update operation matrix O with inv(s) * O OR O * s, depending on the value of typ.
This functions as transform_inplace(…) but is used when this Lindbladparameterized operation is used as a part of a SPAM vector. When typ == “prep”, the spam vector is assumed to be rho = dot(self, <spamvec>), which transforms as rho > inv(s) * rho, so self > inv(s) * self. When typ == “effect”, e.dag = dot(e.dag, self) (not that self is NOT self.dag here), and e.dag > e.dag * s so that self > self * s.
 Parameters
s (GaugeGroupElement) – A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.
typ ({ 'prep', 'effect' }) – Which type of SPAM vector is being transformed (see above).
 Returns
None
 __str__(self)¶
Return str(self).
 _oneline_contents(self)¶
Summarizes the contents of this object in a single line. Does not summarize submembers.
 pygsti.modelmembers.operations.experrorgenop._d_exp_series(x, dx)¶
 pygsti.modelmembers.operations.experrorgenop._d2_exp_series(x, dx, d2x)¶
 pygsti.modelmembers.operations.experrorgenop._d_exp_x(x, dx, exp_x=None)¶
Computes the derivative of the exponential of x(t) using the Haddamard lemma series expansion.
 Parameters
x (ndarray) – The 2tensor being exponentiated
dx (ndarray) – The derivative of x; can be either a 3 or 4tensor where the 3rd+ dimensions are for (multi)indexing the parameters which are differentiated w.r.t. For example, in the simplest case dx is a 3tensor s.t. dx[i,j,p] == d(x[i,j])/dp.
exp_x (ndarray, optional) – The value of exp(x), which can be specified in order to save a call to scipy.linalg.expm. If None, then the value is computed internally.
 Returns
ndarray – The derivative of exp(x) given as a tensor with the same shape and axes as dx.