pygsti.modelmembers.states.tensorprodstate
The TensorProductState class and supporting functionality.
Module Contents
Classes
A state vector that is a tensor-product of other state vectors. |
- class pygsti.modelmembers.states.tensorprodstate.TensorProductState(factors, state_space)
Bases:
pygsti.modelmembers.states.state.State
A state vector that is a tensor-product of other state vectors.
Parameters
- factorslist of States
a list of the component states to take the tensor product of.
- state_spaceStateSpace, optional
The state space for this operation.
Initialize a new state Vector
- 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 state vector.
Returns
- int
the number of independent parameters.
- to_dense(on_space='minimal', scratch=None)
Return this state vector as a (dense) numpy array.
The memory in scratch maybe used when it is not-None.
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.
- scratchnumpy.ndarray, optional
scratch space available for use.
Returns
numpy.ndarray
- taylor_order_terms(order, max_polynomial_vars=100, return_coeff_polys=False)
Get the order-th order Taylor-expansion terms of this state vector.
This function either constructs or returns a cached list of the terms at the given order. Each term is “rank-1”, meaning that it is a state preparation followed by or POVM effect preceded by actions on a density matrix rho of the form:
rho -> A rho B
The coefficients of these terms are typically polynomials of the State’s parameters, where the polynomial’s variable indices index the global parameters of the State’s parent (usually a
Model
) , not the State’s local parameter array (i.e. that returned from to_vector).Parameters
- orderint
The order of terms to get.
- max_polynomial_varsint, optional
maximum number of variables the created polynomials can have.
- return_coeff_polysbool
Whether a parallel list of locally-indexed (using variable indices corresponding to this object’s parameters rather than its parent’s) polynomial coefficients should be returned as well.
Returns
- termslist
A list of
RankOneTerm
objects.- coefficientslist
Only present when return_coeff_polys == True. A list of compact polynomial objects, meaning that each element is a (vtape,ctape) 2-tuple formed by concatenating together the output of
Polynomial.compact()
.
- 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().
- from_vector(v, close=False, dirty_value=True)
Initialize the state vector using a 1D array of parameters.
Parameters
- vnumpy array
The 1D vector of state vector parameters. Length must == num_params()
- closebool, 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_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 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_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)