pygsti.modelmembers.operations.repeatedop

Defines the RepeatedOp class

Module Contents

Classes

RepeatedOp

An operation map that is the composition of a number of map-like factors (possibly other LinearOperator)

class pygsti.modelmembers.operations.repeatedop.RepeatedOp(op_to_repeat, num_repetitions, evotype='auto')

Bases: pygsti.modelmembers.operations.linearop.LinearOperator

An operation map that is the composition of a number of map-like factors (possibly other LinearOperator)

Parameters

op_to_repeatlist

A LinearOperator-derived object that is repeated some integer number of times to produce this operator.

num_repetitionsint

the power to exponentiate op_to_exponentiate to.

evotypeEvotype or str, optional

The evolution type. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype. The special value “auto” uses the evolutio ntype of op_to_repeat.

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.

repeated_op
num_repetitions
submembers()

Get the ModelMember-derived objects contained in this one.

Returns

list

set_time(t)

Sets the current time for a time-dependent operator.

For time-independent operators (the default), this function does nothing.

Parameters
tfloat

The current time.

Returns

None

to_sparse(on_space='minimal')

Return the operation as a sparse matrix

Returns

scipy.sparse.csr_matrix

to_dense(on_space='minimal')

Return this operation as a dense 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

numpy.ndarray

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.

Constructs 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. An empty 2D array in the StaticArbitraryOp case (num_params == 0).

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)

to_memoized_dict(mmg_memo)

Create a serializable dict with references to other objects in the memo.

Parameters
mmg_memo: dict

Memo dict from a ModelMemberGraph, i.e. keys are object ids and values are ModelMemberGraphNodes (which contain the serialize_id). This is NOT the same as other memos in ModelMember (e.g. copy, allocate_gpindices, etc.).

Returns
mm_dict: dict

A dict representation of this ModelMember ready for serialization This must have at least the following fields: module, class, submembers, params, state_space, evotype Additional fields may be added by derived classes.