# PrimitiveOp¶

class PrimitiveOp(primitive=None, coeff=1.0)[source]

Bases : qiskit.aqua.operators.operator_base.OperatorBase

A class for representing basic Operators, backed by Operator primitives from Terra. This class (and inheritors) primarily serves to allow the underlying primitives to « flow » - i.e. interoperability and adherence to the Operator formalism - while the core computational logic mostly remains in the underlying primitives. For example, we would not produce an interface in Terra in which QuantumCircuit1 + QuantumCircuit2 equaled the Operator sum of the circuit unitaries, rather than simply appending the circuits. However, within the Operator flow summing the unitaries is the expected behavior.

Note that all mathematical methods are not in-place, meaning that they return a new object, but the underlying primitives are not copied.

Paramètres
• primitive (Union[Instruction, QuantumCircuit, List, ndarray, spmatrix, Operator, Pauli, None]) – The operator primitive being wrapped.

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

Methods

 add Return Operator addition of self and other, overloaded by +. adjoint Return a new Operator equal to the Operator’s adjoint (conjugate transpose), overloaded by ~. assign_parameters Binds scalar values to any Terra Parameters in the coefficients or primitives of the Operator, or substitutes one Parameter for another. bind_parameters Same as assign_parameters, but maintained for consistency with QuantumCircuit in Terra (which has both assign_parameters and bind_parameters). compose Return Operator Composition between self and other (linear algebra-style: A@B(x) = A(B(x))), overloaded by @. equals Evaluate Equality between Operators, overloaded by ==. eval Evaluate the Operator’s underlying function, either on a binary string or another Operator. exp_i Return Operator exponentiation, equaling e^(-i * op) log_i Return a MatrixOp equivalent to log(H)/-i for this operator H. mul 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). neg Return the Operator’s negation, effectively just multiplying by -1.0, overloaded by -. permute Permutes the qubits of the operator. power Return Operator composed with self multiple times, overloaded by **. primitive_strings Return a set of strings describing the primitives contained in the Operator. reduce Try collapsing the Operator structure, usually after some type of conversion, e.g. tensor Return tensor product between self and other, overloaded by ^. tensorpower Return tensor product with self multiple times, overloaded by ^. to_circuit Returns a QuantumCircuit equivalent to this Operator. to_circuit_op Returns a CircuitOp equivalent to this Operator. to_instruction Returns an Instruction equivalent to this Operator. to_legacy_op Attempt to return the Legacy Operator representation of the Operator. to_matrix Return NumPy representation of the Operator. to_matrix_op Returns a MatrixOp equivalent to this Operator. to_pauli_op Returns a sum of PauliOp s equivalent to this Operator.

Attributes

ENABLE_DEPRECATION = True
INDENTATION = ' '
coeff

The scalar coefficient multiplying the Operator.

Type renvoyé

Union[int, float, complex, ParameterExpression]

Renvoie

The coefficient.

num_qubits
Type renvoyé

int

parameters
primitive

The primitive defining the underlying function of the Operator.

Type renvoyé

Union[Instruction, QuantumCircuit, List, ndarray, spmatrix, Operator, Pauli]

Renvoie

The primitive object.