Skip to main contentIBM Quantum Documentation Mirror

Mapper Library

The C API provides efficient implementations of commonly used operator representation mapper routines.


qf_ferm_op_jordan_wigner

QfExitCode qf_ferm_op_jordan_wigner(const QfFermionOperator *op, uint32_t num_qubits, QkObs **out)

Applies the Jordan-Wigner transformation to an operator.

Map a QfFermionOperator to a QkObs under the Jordan-Wigner transformation. [1]

Definition

The Jordan-Wigner transformation maps fermionic creation and annihilation operators to spin (or in this case, qubit) operators:

ajk<jσkZσj  and  ajk<jσkZσj+,a^\dagger_j \rightarrow \bigotimes_{k\lt j} \sigma^Z_k \otimes \sigma^-_j ~~\text{and}~~ a_j \rightarrow \bigotimes_{k\lt j} \sigma^Z_k \otimes \sigma^+_j \, ,

where aja^\dagger_j (aja_j) is the fermionic creation (annihilation) operator acting on the jj-th spin-less fermionic mode, σP\sigma^P with P{X,Y,Z}P \in \{X,Y,Z\} are the spin-12\frac{1}{2} Pauli operators and σ±=(σX±iσY)/2\sigma^\pm = (\sigma^X \pm \mathrm{i} \sigma^Y) / 2.

This mapping preserves the fermionic anti-commutation relations by introducing a chain of σZ\sigma^Z operators on all qubits preceding the acted-upon index jj.

[1]

P. Jordan and E. Wigner, Über das Paulische Äquivalenzverbot, Zeitschrift für Physik 47, No. 9. (1928), pp. 631–651, doi:10.1007/BF01331938.

Example

1// define some kind of fermionic operator
2QfFermionOperator *hamil = qf_ferm_op_one();
3
4// and map it to a qubit operator
5QkObs *result;
6QfExitCode exit = qf_ferm_op_jordan_wigner(hamil, 4, &result);
7
8assert(exit == QfExitCode_Success);

Parameters

  • op – A pointer to the fermionic operator to be mapped.
  • num_qubits – The number of qubits of the resulting operator. This must be strictly greater than the largest mode index acted upon by op.
  • out – A pointer to where the created qubit operator will be written on success. It is left untouched if the transformation fails.

Returns

An exit code. This is >0 if an error occurred. In particular, a QfExitCode_ValueError is returned if num_qubits is too small to hold the operator’s support.

qf_fermion_to_majorana

QfMajoranaOperator *qf_fermion_to_majorana(const QfFermionOperator *fer_op)

Map a QfFermionOperator to a QfMajoranaOperator.

Definition

This function implements the simple transformation:

aj12(γjiγj)  and  aj12(γj+iγj)a^\dagger_j \rightarrow \frac{1}{2} (\gamma_j - i \gamma'_j) ~~\text{and}~~ a_j \rightarrow \frac{1}{2} (\gamma_j + i \gamma'_j)

where aja^\dagger_j (aja_j) is the fermionic creation (annihilation) operator acting on the jj-th spin-less fermionic mode, and γj\gamma_j/γj\gamma'_j are the two Majorana fermion operators. In the case of the QfMajoranaOperator these will be stored on the even and odd Majorana modes, respectively.

Example

1// define some kind of fermionic operator
2QfFermionOperator *fer_op = qf_ferm_op_one();
3
4// and map it to a majorana operator
5QfMajoranaOperator *maj_op = qf_fermion_to_majorana(fer_op);

Parameters

  • fer_op – A pointer to the fermionic operator to be mapped.

Returns

A pointer to the mapped majorana operator.

qf_majorana_to_fermion

QfFermionOperator *qf_majorana_to_fermion(const QfMajoranaOperator *maj_op)

Map a QfMajoranaOperator to a QfFermionOperator.

Definition

This function implements the simple transformation:

γjaj+aj  and  γji(ajaj)\gamma_j \rightarrow a^\dagger_j + a_j ~~\text{and}~~ \gamma'_j \rightarrow i (a^\dagger_j - a_j)

where γj\gamma_j/γj\gamma'_j are the two Majorana fermion operators (stored on the even and odd modes, respectively), and aja^\dagger_j (aja_j) is the fermionic creation (annihilation) operator acting on the jj-th spin-less fermionic mode.

Example

1// define some kind of majorana operator
2QfMajoranaOperator *maj_op = qf_maj_op_one();
3
4// and map it to a fermion operator
5QfFermionOperator *fer_op = qf_majorana_to_fermion(maj_op);

Parameters

  • maj_op – A pointer to the majorana operator to be mapped.

Returns

A pointer to the mapped fermion operator.