ModeBasedMapper

class ModeBasedMapper[source]

Bases: QubitMapper

Mapper from SparseLabelOp to a qubit operator using a Pauli table.

Methods

map(second_q_ops, *, register_length=None)

Maps a second quantized operator or a list, dict of second quantized operators based on the current mapper.

Parameters:
  • second_q_ops (SparseLabelOp | List[SparseLabelOp | None] | Dict[str, SparseLabelOp]) – A second quantized operator, or list thereof.

  • register_length (int | None) – when provided, this will be used to overwrite the register_length attribute of the SparseLabelOp being mapped. This is possible because the register_length is considered a lower bound in a SparseLabelOp.

Returns:

A qubit operator in the form of a SparsePauliOp, or list (resp. dict) thereof if a list (resp. dict) of second quantized operators was supplied.

Return type:

SparsePauliOp | List[SparsePauliOp | None] | Dict[str, SparsePauliOp]

mode_based_mapping(second_q_op, register_length=None)[source]

Utility method to map a SparseLabelOp to a qubit operator using a pauli table.

Parameters:
  • second_q_op (SparseLabelOp) – the SparseLabelOp to be mapped.

  • register_length (int | None) – when provided, this will be used to overwrite the register_length attribute of the operator being mapped. This is possible because the register_length is considered a lower bound.

Returns:

The qubit operator corresponding to the problem-Hamiltonian in the qubit space.

Raises:

QiskitNatureError – If number length of pauli table does not match the number of operator modes, or if the operator has unexpected label content

Return type:

SparsePauliOp

abstract pauli_table(register_length)[source]

Generates a Pauli-lookup table mapping from modes to Pauli operators or pairs of Pauli operators.

This table is a list of tuples \((P, Q)\) of two Pauli operators, corresponding to the real part \(P\) and imaginary part \(Q\) for the respective mode index. These Pauli operators are used to construct the creation and annihilation operators \((P \pm i Q)/2\).

The generated table is processed by sparse_pauli_operators().

Parameters:

register_length (int) – the register length for which to generate the table.

Returns:

A list of tuples of two Pauli string operators.

Return type:

list[tuple[PauliList | SparsePauliOp | Pauli | list | str, PauliList | SparsePauliOp | Pauli | list | str]]

sparse_pauli_operators(register_length)[source]

Generates the SparsePauliOp terms.

This uses pauli_table() to construct a list of operators used to translate the second-quantization symbols into qubit operators.

Parameters:

register_length (int) – the register length for which to generate the operators.

Returns:

Two lists stored in a tuple, consisting of the creation and annihilation operators, applied on the individual modes.

Return type:

tuple[list[SparsePauliOp], list[SparsePauliOp]]