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. Today onlyFermionOperatoris supported, delegating tofermion_jordan_wigner(); any other operator type raises aTypeErroruntil a direct implementation exists for it.- 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).
- 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)>
An operator type without a direct implementation raises a
TypeError:>>> from qiskit_fermions.operators import MajoranaOperator >>> mop = MajoranaOperator.from_dict({(0, 1): 1.0}) >>> jordan_wigner(mop, 2) Traceback (most recent call last): ... TypeError: jordan_wigner does not support operator type 'MajoranaOperator'; only FermionOperator is supported today.