majorana_ternary_tree¶
- majorana_ternary_tree(op, encoding, num_qubits)¶
Map a
MajoranaOperatorto aSparseObservableunder a ternary-tree encoding.Each Majorana operator’s image is a single Pauli string, whatever the tree, so a term that is a product of several of them composes those strings rather than inflating into a sum.
- Parameters:
op – the Majorana operator to map.
encoding – the compiled encoding to map through.
num_qubits – the number of qubits for the resulting qubit operator. Must be at least the encoding’s mode count; a larger value pads with the identity.
- Returns:
The mapped qubit operator, subject to the same simplification and grouping caveats as
fermion_ternary_tree().- Raises:
ValueError – if
opacts on a mode the encoding does not cover. Note that Majorana index \(m\) acts on mode \(\lfloor m/2 \rfloor\).
Usage¶
>>> from qiskit_fermions.mappers import TernaryTree, TernaryTreeEncoding >>> from qiskit_fermions.mappers.library import majorana_ternary_tree >>> from qiskit_fermions.operators import MajoranaOperator >>> mop = MajoranaOperator.from_dict({(0, 1): 1.0}) >>> enc = TernaryTreeEncoding(TernaryTree.breadth_first(2, 3)) >>> majorana_ternary_tree(mop, enc, 2).simplify() <SparseObservable with 1 term on 2 qubits: (0+1j)(Z_1 Z_0)>
Note that the product of two Majorana strings carries a phase that depends on how their paths overlap, and so on the tree.