The FullUnitaryOp class and supporting functionality.

Module Contents



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.DenseOperator

An operation matrix that is fully parameterized.

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

  • m (array_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.

  • basis (Basis or {'pp','gm','std'}, optional) – The basis used to construct the Hilbert-Schmidt space representation of this state as a super-operator.

  • evotype (Evotype or str, optional) – The evolution type. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype.

  • state_space (StateSpace, optional) – The state space for this operation. If None a default state space with the appropriate number of qubits is used.

set_dense(self, 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.


m (array_like or LinearOperator) – An array of shape (dim, dim) or LinearOperator representing the operation action.



property num_params(self)

Get the number of independent parameters which specify this operation.


int – the number of independent parameters.


Get the operation parameters as an array of values.


numpy array – The operation parameters as a 1D array with length num_params().

from_vector(self, v, close=False, dirty_value=True)

Initialize the operation using a vector of 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.



deriv_wrt_params(self, 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.


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.)


numpy array – Array of derivatives with shape (dimension^2, num_params)


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)