VectorStateFn

class VectorStateFn(primitive=None, coeff=1.0, is_measurement=False)[source]

A class for state functions and measurements which are defined in vector representation, and stored using Terra’s Statevector class.

Parameters
  • primitive (Union[list, ndarray, Statevector, None]) – The Statevector, NumPy array, or list, which defines the behavior of the underlying function.

  • coeff (Union[int, float, complex, ParameterExpression]) – A coefficient multiplying the state function.

  • is_measurement (bool) – Whether the StateFn is a measurement operator

Attributes

VectorStateFn.coeff

A coefficient by which the state function is multiplied.

VectorStateFn.is_measurement

Whether the StateFn object is a measurement Operator.

VectorStateFn.num_qubits

The number of qubits over which the Operator is defined.

VectorStateFn.primitive

The primitive which defines the behavior of the underlying State function.

Methods

VectorStateFn.__mul__(other)

Overload * for Operator scalar multiplication.

VectorStateFn.add(other)

Return Operator addition of self and other, overloaded by +.

VectorStateFn.adjoint()

Return a new Operator equal to the Operator’s adjoint (conjugate transpose), overloaded by ~.

VectorStateFn.assign_parameters(param_dict)

Binds scalar values to any Terra Parameters in the coefficients or primitives of the Operator, or substitutes one Parameter for another.

VectorStateFn.bind_parameters(param_dict)

Same as assign_parameters, but maintained for consistency with QuantumCircuit in Terra (which has both assign_parameters and bind_parameters).

VectorStateFn.compose(other)

Composition (Linear algebra-style: A@B(x) = A(B(x))) is not well defined for states in the binary function model, but is well defined for measurements.

VectorStateFn.equals(other)

Evaluate Equality between Operators, overloaded by ==.

VectorStateFn.eval([front])

Evaluate the Operator’s underlying function, either on a binary string or another Operator.

VectorStateFn.mul(scalar)

Returns the scalar multiplication of the Operator, overloaded by *, including support for Terra’s Parameters, which can be bound to values later (via bind_parameters).

VectorStateFn.neg()

Return the Operator’s negation, effectively just multiplying by -1.0, overloaded by -.

VectorStateFn.power(exponent)

Compose with Self Multiple Times, undefined for StateFns.

VectorStateFn.primitive_strings()

Return a set of strings describing the primitives contained in the Operator.

VectorStateFn.reduce()

Try collapsing the Operator structure, usually after some type of conversion, e.g.

VectorStateFn.sample([shots, massive, …])

Sample the state function as a normalized probability distribution.

VectorStateFn.tensor(other)

Return tensor product between self and other, overloaded by ^.

VectorStateFn.tensorpower(other)

Return tensor product with self multiple times, overloaded by ^.

VectorStateFn.to_circuit_op()

Return StateFnCircuit corresponding to this StateFn.

VectorStateFn.to_density_matrix([massive])

Return matrix representing product of StateFn evaluated on pairs of basis states.

VectorStateFn.to_legacy_op([massive])

Attempt to return the Legacy Operator representation of the Operator.

VectorStateFn.to_matrix([massive])

Return NumPy representation of the Operator.

VectorStateFn.to_matrix_op([massive])

Return a VectorStateFn for this StateFn.

VectorStateFn.traverse(convert_fn[, coeff])

Apply the convert_fn to the internal primitive if the primitive is an Operator (as in the case of OperatorStateFn).

VectorStateFn.__mul__(other)

Overload * for Operator scalar multiplication.