SparseVectorStateFn¶
-
class
SparseVectorStateFn
(primitive, coeff=1.0, is_measurement=False)[source]¶ Bases:
qiskit.opflow.state_fns.state_fn.StateFn
A class for sparse state functions and measurements in vector representation.
This class uses
scipy.sparse.spmatrix
for the internal representation.- Parameters
primitive (
spmatrix
) – The underlying sparse vector.coeff (
Union
[complex
,ParameterExpression
]) – A coefficient multiplying the state function.is_measurement (
bool
) – Whether the StateFn is a measurement operator
- Raises
ValueError – If the primitive is not a column vector.
ValueError – If the number of elements in the primitive is not a power of 2.
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 Equality between Operators, overloaded by
==
.Evaluate the Operator’s underlying function, either on a binary string or another Operator.
Return a set of strings describing the primitives contained in the Operator.
Sample the state function as a normalized probability distribution.
Convert this state function to a
CircuitStateFn
.Convert this state function to a
DictStateFn
.Return NumPy representation of the Operator.
Return a
VectorStateFn
for thisStateFn
.Return SciPy sparse matrix representation of the Operator.
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
: scipy.sparse.base.spmatrix¶ The primitive which defines the behavior of the underlying State function.
-
settings
¶ Return settings.
- Return type
Dict