DictStateFn¶
- class DictStateFn(primitive=None, coeff=1.0, is_measurement=False, from_operator=False)[source]¶
Bases:
qiskit.opflow.state_fns.state_fn.StateFn
A class for state functions and measurements which are defined by a lookup table, stored in a dict.
- Parameters
primitive (
Union
[str
,dict
,Result
,None
]) – The dict, single bitstring (if defining a basis sate), or Qiskit Result, which defines the behavior of the underlying function.coeff (
Union
[complex
,ParameterExpression
]) – A coefficient by which to multiply the state function.is_measurement (
bool
) – Whether the StateFn is a measurement operator.from_operator (
bool
) – if True the StateFn is derived from OperatorStateFn. (Default: False)
- Raises
TypeError – invalid parameters.
Methods Defined Here
Return Operator addition of self and other, overloaded by
+
.Return a new Operator equal to the Operator's adjoint (conjugate transpose), overloaded by
~
.Evaluate the Operator's underlying function, either on a binary string or another Operator.
Permute the qubits of the state function.
Return a set of strings describing the primitives contained in the Operator.
Sample the state function as a normalized probability distribution.
Return tensor product between self and other, overloaded by
^
.Convert this state function to a
CircuitStateFn
.Return matrix representing product of StateFn evaluated on pairs of basis states.
Return NumPy representation of the Operator.
Same as to_matrix, but returns csr sparse matrix.
Convert this state function to a
SparseVectorStateFn
.Attributes
- INDENTATION = ' '¶
- coeff¶
A coefficient by which the state function is multiplied.
- Return type
Union
[complex
,ParameterExpression
]
- instance_id¶
Return the unique instance id.
- Return type
int
- is_measurement¶
Whether the StateFn object is a measurement Operator.
- Return type
bool
- num_qubits¶
- Return type
int
- parameters¶
- primitive: Dict[str, complex]¶
The primitive which defines the behavior of the underlying State function.
- settings¶
Return settings.
- Return type
Dict