pygsti.modelmembers.operations.identitypluserrorgenop
The IdentityPlusErrorgenOp class and supporting functionality.
Module Contents
Classes
An operation consisting of the identity added to what would ordinarily be an error generator. |
Attributes
- pygsti.modelmembers.operations.identitypluserrorgenop.IMAG_TOL = '1e-07'
- pygsti.modelmembers.operations.identitypluserrorgenop.TODENSE_TRUNCATE = '1e-11'
- class pygsti.modelmembers.operations.identitypluserrorgenop.IdentityPlusErrorgenOp(errorgen)
Bases:
pygsti.modelmembers.operations.linearop.LinearOperator
,pygsti.modelmembers.errorgencontainer.ErrorGeneratorContainer
An operation consisting of the identity added to what would ordinarily be an error generator.
This is the first-order expansion, exp(L) = 1 + L, and yields a CPTP map whenever L is a valid Lindbladian.
Parameters
- errorgenLinearOperator
The error generator for this operator.
Initialize a new LinearOperator
- property parameter_labels
An array of labels (usually strings) describing this model member’s parameters.
- property num_params
Get the number of independent parameters which specify this operation.
Returns
- int
the number of independent parameters.
- property total_term_magnitude
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 absolute-coefficients 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
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
- set_gpindices(gpindices, parent, memo=None)
Set the parent and indices into the parent’s parameter vector that are used by this ModelMember object.
Parameters
- gpindicesslice or integer ndarray
The indices of this objects parameters in its parent’s array.
- parentModel or ModelMember
The parent whose parameter array gpindices references.
- memodict, optional
A memo dict used to avoid circular references.
Returns
None
- to_sparse(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 super-bra/super-ket 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(wrt_filter=None)
The element-wise 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_filterlist 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()
Whether this operation has a non-zero Hessian with respect to its parameters.
(i.e. whether it only depends linearly on its parameters or not)
Returns
bool
- hessian_wrt_params(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_filter1list 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_filter2list 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)
- to_vector()
Extract a vector of the underlying operation parameters from this operation.
Returns
- numpy array
a 1D numpy array with length == num_params().
- from_vector(v, close=False, dirty_value=True)
Initialize the operation using a vector of parameters.
Parameters
- vnumpy array
The 1D vector of operation parameters. Length must == num_params()
- closebool, 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_valuebool, 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(order, max_polynomial_vars=100, return_coeff_polys=False)
Get the order-th order Taylor-expansion terms of this operation.
This function either constructs or returns a cached list of the terms at the given order. Each term is “rank-1”, 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
- orderint
Which order terms (in a Taylor expansion of this
LindbladOp
) to retrieve.- max_polynomial_varsint, optional
maximum number of variables the created polynomials can have.
- return_coeff_polysbool
Whether a parallel list of locally-indexed (using variable indices corresponding to this object’s parameters rather than its parent’s) polynomial coefficients should be returned as well.
Returns
- termslist
A list of
RankOneTerm
objects.- coefficientslist
Only present when return_coeff_polys == True. A list of compact polynomial objects, meaning that each element is a (vtape,ctape) 2-tuple formed by concatenating together the output of
Polynomial.compact()
.
- taylor_order_terms_above_mag(order, max_polynomial_vars, min_term_mag)
Get the order-th order Taylor-expansion 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
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
- orderint
The order of terms to get (and filter).
- max_polynomial_varsint, optional
maximum number of variables the created polynomials can have.
- min_term_magfloat
the minimum term magnitude.
Returns
- list
A list of
Rank1Term
objects.
- set_dense(m)
Set the dense-matrix value of this operation.
Attempts to modify operation parameters so that the specified raw operation matrix becomes mx. Will raise ValueError if this operation is not possible.
Parameters
- marray_like or LinearOperator
An array of shape (dim, dim) or LinearOperator representing the operation action.
Returns
None
- abstract transform_inplace(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
- sGaugeGroupElement
A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.
Returns
None
- abstract spam_transform_inplace(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 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) (note that self is NOT self.dag here), and e.dag -> e.dag * s so that self -> self * s.
Parameters
- sGaugeGroupElement
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