jordan_wigner¶
- jordan_wigner(operator, num_qubits)¶
Map an operator to a
SparseObservableunder the Jordan-Wigner transformation.This is the type-agnostic entry point to the Jordan-Wigner transformation. It dispatches on the concrete type of
operatorto the appropriate direct implementation:fermion_jordan_wigner(),majorana_jordan_wigner(),edge_vertex_jordan_wigner()ortransfer_vertex_jordan_wigner(). Anything that is not one of the four operator types raises aTypeError.- Parameters:
operator (OperatorTrait) – the operator to map.
num_qubits (int) – the number of qubits for the resulting qubit operator. This must be strictly greater than the largest mode index in
operator(any additional qubits are padded with the identity). Note that for aMajoranaOperatorthe bound is counted in fermionic modes, i.e. in the largest Majorana index divided by two.
- Returns:
The mapped qubit operator.
- Raises:
TypeError – if
operatoris of a type for which no Jordan-Wigner implementation exists.ValueError – if
num_qubitsis too small to hold the operator’s support.
- Return type:
>>> from qiskit_fermions.mappers.library import jordan_wigner >>> from qiskit_fermions.operators import FermionOperator >>> fop = FermionOperator.from_dict({((True, 0), (False, 0)): 0.1}) >>> jordan_wigner(fop, 2).simplify() <SparseObservable with 2 terms on 2 qubits: (0.05+0j)() + (-0.05+0j)(Z_0)>
Every operator type has a direct implementation, so the dispatch is total over them. Anything else – an object that is not a fermionic operator at all – raises a
TypeError:>>> from qiskit.quantum_info import SparseObservable >>> jordan_wigner(SparseObservable.identity(2), 2) Traceback (most recent call last): ... TypeError: jordan_wigner does not support operator type 'SparseObservable'.