ComposedOp

class ComposedOp(oplist, coeff=1.0, abelian=False)[source]

A class for lazily representing compositions of Operators. Often Operators cannot be efficiently composed with one another, but may be manipulated further so that they can be composed later. This class holds logic to indicate that the Operators in oplist are meant to be composed, and therefore if they reach a point in which they can be, such as after conversion to QuantumCircuits or matrices, they can be reduced by composition.

Parameters
  • oplist (List[OperatorBase]) – The Operators being composed.

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

  • abelian (bool) – Indicates whether the Operators in oplist are known to mutually commute.

Attributes

ComposedOp.abelian

Whether the Operators in oplist are known to commute with one another.

ComposedOp.coeff

The scalar coefficient multiplying the Operator.

ComposedOp.combo_fn

The function defining how to combine oplist (or Numbers, or NumPy arrays) to produce the Operator’s underlying function.

ComposedOp.distributive

Indicates whether the ListOp or subclass is distributive under composition.

ComposedOp.num_qubits

The number of qubits over which the Operator is defined.

ComposedOp.oplist

The list of OperatorBases defining the underlying function of this Operator.

Methods

ComposedOp.__getitem__(offset)

Allows array-indexing style access to the Operators in oplist.

ComposedOp.__len__()

Length of oplist.

ComposedOp.__mul__(other)

Overload * for Operator scalar multiplication.

ComposedOp.add(other)

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

ComposedOp.adjoint()

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

ComposedOp.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.

ComposedOp.bind_parameters(param_dict)

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

ComposedOp.compose(other)

Return Operator Composition between self and other (linear algebra-style: A@B(x) = A(B(x))), overloaded by @.

ComposedOp.equals(other)

Evaluate Equality between Operators, overloaded by ==.

ComposedOp.eval([front])

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

ComposedOp.exp_i()

Return an OperatorBase equivalent to an exponentiation of self * -i, e^(-i*op).

ComposedOp.log_i([massive])

Return a MatrixOp equivalent to log(H)/-i for this operator H.

ComposedOp.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).

ComposedOp.neg()

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

ComposedOp.non_distributive_reduce()

Reduce without attempting to expand all distributive compositions.

ComposedOp.power(exponent)

Return Operator composed with self multiple times, overloaded by **.

ComposedOp.primitive_strings()

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

ComposedOp.reduce()

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

ComposedOp.tensor(other)

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

ComposedOp.tensorpower(other)

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

ComposedOp.to_circuit_op()

Returns an equivalent Operator composed of only QuantumCircuit-based primitives, such as CircuitOp and CircuitStateFn.

ComposedOp.to_legacy_op([massive])

Attempt to return the Legacy Operator representation of the Operator.

ComposedOp.to_matrix([massive])

Return NumPy representation of the Operator.

ComposedOp.to_matrix_op([massive])

Returns an equivalent Operator composed of only NumPy-based primitives, such as MatrixOp and VectorStateFn.

ComposedOp.to_pauli_op([massive])

Returns an equivalent Operator composed of only Pauli-based primitives, such as PauliOp.

ComposedOp.to_spmatrix()

Returns SciPy sparse matrix representation of the Operator.

ComposedOp.traverse(convert_fn[, coeff])

Apply the convert_fn to each node in the oplist.

ComposedOp.__len__()

Length of oplist.

ComposedOp.__mul__(other)

Overload * for Operator scalar multiplication.

ComposedOp.__getitem__(offset)

Allows array-indexing style access to the Operators in oplist.