pygsti.modelmembers.states.fullstate
The FullState class and supporting functionality.
Module Contents
Classes
A "fully parameterized" state vector where each element is an independent parameter. |
- class pygsti.modelmembers.states.fullstate.FullState(vec, basis=None, evotype='default', state_space=None)
Bases:
pygsti.modelmembers.states.densestate.DenseState
A “fully parameterized” state vector where each element is an independent parameter.
Parameters
- vecarray_like or SPAMVec
a 1D numpy array representing the SPAM operation. The shape of this array sets the dimension of the SPAM op.
- basisBasis or str
The basis that vec is in.
- 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 state. If None a default state space with the appropriate number of qubits is used.
Initialize a new state Vector
- property num_params
Get the number of independent parameters which specify this SPAM vector.
Returns
- int
the number of independent parameters.
- set_dense(vec)
Set the dense-vector value of this SPAM vector.
Attempts to modify this SPAM vector’s parameters so that the raw SPAM vector becomes vec. Will raise ValueError if this operation is not possible.
Parameters
- vecarray_like or SPAMVec
A numpy array representing a SPAM vector, or a SPAMVec object.
Returns
None
- to_vector()
Get the SPAM vector parameters as an array of values.
Returns
- numpy array
The parameters as a 1D array with length num_params().
- from_vector(v, close=False, dirty_value=True)
Initialize the SPAM vector using a 1D array of parameters.
Parameters
- vnumpy array
The 1D vector of SPAM vector parameters. Length must == num_params()
- closebool, optional
Whether v is close to this SPAM vector’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 SPAM vector.
Construct a matrix whose columns are the derivatives of the SPAM vector with respect to a single param. Thus, each column is of length dimension and there is one column per SPAM vector 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, num_params)