WeightedPauliOperator

class WeightedPauliOperator(paulis, basis=None, z2_symmetries=None, atol=1e-12, name=None)[source]

Weighted Pauli Operator

Parameters
  • paulis (list[[complex, Pauli]]) – the list of weighted Paulis, where a weighted pauli is composed of a length-2 list and the first item is the weight and the second item is the Pauli object.

  • basis (list[tuple(object, [int])], optional) – the grouping basis, each element is a tuple composed of the basis and the indices to paulis which are belonged to that group. e.g., if tpb basis is used, the object will be a pauli. By default, the group is equal to non-grouping, each pauli is its own basis.

  • z2_symmetries (Z2Symmetries) – recording the z2 symmetries info

  • atol (float, optional) – the threshold used in truncating paulis

  • name (str, optional) – the name of operator.

Attributes

WeightedPauliOperator.atol

get atol

WeightedPauliOperator.basis

returns basis

WeightedPauliOperator.name

returns name

WeightedPauliOperator.num_qubits

Number of qubits required for the operator.

WeightedPauliOperator.paulis

get paulis

WeightedPauliOperator.z2_symmetries

returns z2 symmetries

Methods

WeightedPauliOperator.__mul__(other)

Overload self * other

WeightedPauliOperator.add(other[, copy])

Perform self + other.

WeightedPauliOperator.anticommute_with(other)

Anti commutes with

WeightedPauliOperator.chop([threshold, copy])

Eliminate the real and imagine part of weight in each pauli by threshold.

WeightedPauliOperator.commute_with(other)

Commutes with

WeightedPauliOperator.construct_evaluation_circuit(…)

Construct the circuits for evaluation, which calculating the expectation <psi|H|psi>.

WeightedPauliOperator.copy()

Get a copy of self

WeightedPauliOperator.evaluate_with_result(…)

This method can be only used with the circuits generated by the construct_evaluation_circuit() method with the same circuit_name_prefix name since the circuit names are tied to some meanings.

WeightedPauliOperator.evaluate_with_statevector(…)

param quantum_state

a quantum state.

WeightedPauliOperator.evaluation_instruction(…)

param statevector_mode

will it be run on statevector simulator or not

WeightedPauliOperator.evolve([state_in, …])

Carry out the eoh evolution for the operator under supplied specifications.

WeightedPauliOperator.evolve_instruction([…])

Carry out the eoh evolution for the operator under supplied specifications.

WeightedPauliOperator.from_dict(dictionary)

Load paulis from a dictionary to construct an Operator.

WeightedPauliOperator.from_file(file_name[, …])

Load paulis in a file to construct an Operator.

WeightedPauliOperator.from_list(paulis[, …])

Create a WeightedPauliOperator via a pair of list.

WeightedPauliOperator.is_empty()

Check Operator is empty or not.

WeightedPauliOperator.multiply(other)

Perform self * other, and the phases are tracked.

WeightedPauliOperator.print_details()

Print out the operator in details.

WeightedPauliOperator.reorder_paulis()

Reorder the paulis based on the basis and return the reordered paulis.

WeightedPauliOperator.rounding(decimals[, copy])

Rounding the weight.

WeightedPauliOperator.simplify([copy])

Merge the paulis whose bases are identical and the pauli with zero coefficient would be removed.

WeightedPauliOperator.sub(other[, copy])

Perform self - other.

WeightedPauliOperator.to_dict()

Save operator to a dict in pauli representation.

WeightedPauliOperator.to_file(file_name)

Save operator to a file in pauli representation.

WeightedPauliOperator.to_opflow([…])

to op flow