qiskit.opflow.state_fns.OperatorStateFn.eval¶
- OperatorStateFn.eval(front=None)[código fonte]¶
Evaluate the Operator’s underlying function, either on a binary string or another Operator. A square binary Operator can be defined as a function taking a binary function to another binary function. This method returns the value of that function for a given StateFn or binary string. For example,
op.eval('0110').eval('1110')
can be seen as querying the Operator’s matrix representation by row 6 and column 14, and will return the complex value at those «indices.» Similarly for a StateFn,op.eval('1011')
will return the complex value at row 11 of the vector representation of the StateFn, as all StateFns are defined to be evaluated from Zero implicitly (i.e. it is as if.eval('0000')
is already called implicitly to always «indexing» from column 0).If
front
is None, the matrix-representation of the operator is returned.- Parâmetros
front (
Union
[str
,dict
,ndarray
,OperatorBase
,Statevector
,None
]) – The bitstring, dict of bitstrings (with values being coefficients), or StateFn to evaluated by the Operator’s underlying function, or None.- Tipo de retorno
Union
[OperatorBase
,complex
]- Retorno
The output of the Operator’s evaluation function. If self is a
StateFn
, the result is a float or complex. If self is an Operator (PrimitiveOp, ComposedOp, SummedOp, EvolvedOp,
etc.), the result is a StateFn. Iffront
is None, the matrix-representation of the operator is returned, which is aMatrixOp
for the operators and aVectorStateFn
for state-functions. If either self or front contain properListOps
(not ListOp subclasses), the result is an n-dimensional list of complex or StateFn results, resulting from the recursive evaluation by each OperatorBase in the ListOps.