jordan_wigner
jordan_wigner(operator, num_qubits)
Map an operator to a SparseObservable under the Jordan-Wigner transformation.
This is the type-agnostic entry point to the Jordan-Wigner transformation. It dispatches on the concrete type of operator to the matching direct implementation, listed under Library implementations in the library documentation. An operator type without one raises a TypeError.
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. - OverflowError – if
num_qubitsis negative or does not fit in 32 bits.
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'.
Questa pagina è stata utile?
Segnala un bug, un errore di battitura o richiedi contenuti su GitHub.