:py:mod:`pygsti.modelmembers.states.cptpstate` ============================================== .. py:module:: pygsti.modelmembers.states.cptpstate .. autoapi-nested-parse:: The CPTPState class and supporting functionality. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.modelmembers.states.cptpstate.CPTPState Attributes ~~~~~~~~~~ .. autoapisummary:: pygsti.modelmembers.states.cptpstate.IMAG_TOL .. py:data:: IMAG_TOL :value: '1e-07' .. py:class:: CPTPState(vec, basis, truncate=False, evotype='default', state_space=None) Bases: :py:obj:`pygsti.modelmembers.states.densestate.DenseState` TODO: update docstring A state vector constrained to correspond ot a positive density matrix. This state vector that is parameterized through the Cholesky decomposition of it's standard-basis representation as a density matrix (not a Liouville vector). The resulting state vector thus represents a positive density matrix, and additional constraints on the parameters also guarantee that the trace == 1. This state vector is meant for use with CPTP processes, hence the name. Parameters ---------- vec : array_like or State a 1D numpy array representing the state operation. The shape of this array sets the dimension of the state. basis : {"std", "gm", "pp", "qt"} or Basis The basis `vec` is in. Needed because this parameterization requires we construct the density matrix corresponding to the Lioville vector `vec`. trunctate : bool, optional Whether or not a non-positive, trace=1 `vec` should be truncated to force a successful construction. 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. Initialize a new state Vector .. py:property:: num_params Get the number of independent parameters which specify this state vector. Returns ------- int the number of independent parameters. .. py:attribute:: basis .. py:attribute:: basis_mxs .. py:attribute:: Lmx .. py:method:: 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. .. py:method:: set_dense(vec) Set the dense-vector value of this state vector. Attempts to modify this state vector's parameters so that the raw state vector becomes `vec`. Will raise ValueError if this operation is not possible. Parameters ---------- vec : array_like or State A numpy array representing a state vector, or a State object. Returns ------- None .. py:method:: to_vector() Get the state vector parameters as an array of values. Returns ------- numpy array The parameters as a 1D array with length num_params(). .. py:method:: from_vector(v, close=False, dirty_value=True) Initialize the state vector using a 1D array of parameters. Parameters ---------- v : numpy array The 1D vector of state vector parameters. Length must == num_params() close : bool, optional Whether `v` is close to this state vector'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. Returns ------- None .. py:method:: deriv_wrt_params(wrt_filter=None) The element-wise derivative this state vector. Construct a matrix whose columns are the derivatives of the state vector with respect to a single param. Thus, each column is of length dimension and there is one column per state vector parameter. Parameters ---------- 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.) Returns ------- numpy array Array of derivatives, shape == (dimension, num_params) .. py:method:: has_nonzero_hessian() Whether this state vector has a non-zero Hessian with respect to its parameters. Returns ------- bool .. py:method:: hessian_wrt_params(wrt_filter1=None, wrt_filter2=None) :abstractmethod: Construct the Hessian of this state vector 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_filter1 : list 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_filter2 : list 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, num_params1, num_params2)