pygsti.modelmembers.operations.fullunitaryop

The FullUnitaryOp class and supporting functionality.

Module Contents

Classes

FullUnitaryOp

An operation matrix that is fully parameterized.

class pygsti.modelmembers.operations.fullunitaryop.FullUnitaryOp(m, basis='pp', evotype='default', state_space=None)

Bases: pygsti.modelmembers.operations.denseop.DenseUnitaryOperator

An operation matrix that is fully parameterized.

That is, each element of the operation matrix is an independent parameter.

Parameters

marray_like or LinearOperator

a square 2D array-like or LinearOperator object representing the operation action. The shape of m sets the dimension of the operation.

basisBasis or {‘pp’,’gm’,’std’}, optional

The basis used to construct the Hilbert-Schmidt space representation of this state as a super-operator.

evotypeEvotype or str, optional

The evolution type. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype.

state_spaceStateSpace, optional

The state space for this operation. If None a default state space with the appropriate number of qubits is used.

Initialize a new LinearOperator

property num_params

Get the number of independent parameters which specify this operation.

Returns
int

the number of independent parameters.

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

to_vector()

Get the operation parameters as an array of values.

Returns
numpy array

The operation parameters as a 1D 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

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 with 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

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

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 Lindblad-parameterized 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
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