- abstract OperatorBase.eval(front=None)¶
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).
frontis None, the matrix-representation of the operator is returned.
None]) – The bitstring, dict of bitstrings (with values being coefficients), or StateFn to evaluated by the Operator’s underlying function, or None.
- 반환 형식
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. If
frontis None, the matrix-representation of the operator is returned, which is a
MatrixOpfor the operators and a
VectorStateFnfor state-functions. If either self or front contain proper
ListOps(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.