Commutator Generators¶
The operator representations provide efficient functions for the computation of various commutators. Since these functions work with generic operator representations (a notion that does not exist in C) we explain them generically in the following three sections. The actual functions contained in the C API for the various operator representations are listed at the bottom of this page.
Commutator¶
-
OpType qf_op_type_commutator(const OpType *op_a, const OpType *op_b)¶
Caution
The function signature here is generic! A real one will replace
OpTypewith an actual operator representations andop_typewith its matching prefix (e.g.ferm_opforQfFermionOperator).The commutator is defined as:
\[[A, B] = AB - BA\]- Parameters:
op_a – A pointer to the operator \(A\).
op_b – A pointer to the operator \(B\).
- Returns:
A pointer to the constructed operator commutator.
Example¶
1QfFermionOperator *op1 = qf_ferm_op_zero();
2QkComplex64 coeff1 = {1.0, 0.0};
3bool action1[2] = {true, false};
4uint32_t modes1[2] = {0, 0};
5qf_ferm_op_add_term(op1, 2, action1, modes1, &coeff1);
6QfFermionOperator *op2 = qf_ferm_op_zero();
7QkComplex64 coeff2 = {2.0, 0.0};
8bool action2[2] = {false, true};
9uint32_t modes2[2] = {0, 0};
10qf_ferm_op_add_term(op2, 2, action2, modes2, &coeff2);
11
12QfFermionOperator *comm = qf_ferm_op_commutator(op1, op2);
Anti-Commutator¶
-
OpType qf_op_type_anti_commutator(const OpType *op_a, const OpType *op_b)¶
Caution
The function signature here is generic! A real one will replace
OpTypewith an actual operator representations andop_typewith its matching prefix (e.g.ferm_opforQfFermionOperator).The anti-commutator is defined as:
\[\{A, B\} = AB + BA\]- Parameters:
op_a – A pointer to the operator \(A\).
op_b – A pointer to the operator \(B\).
- Returns:
A pointer to the constructed operator anti-commutator.
Example¶
1QfFermionOperator *op1 = qf_ferm_op_zero();
2QkComplex64 coeff1 = {1.0, 0.0};
3bool action1[2] = {true, false};
4uint32_t modes1[2] = {0, 0};
5qf_ferm_op_add_term(op1, 2, action1, modes1, &coeff1);
6QfFermionOperator *op2 = qf_ferm_op_zero();
7QkComplex64 coeff2 = {2.0, 0.0};
8bool action2[2] = {false, true};
9uint32_t modes2[2] = {0, 0};
10qf_ferm_op_add_term(op2, 2, action2, modes2, &coeff2);
11
12QfFermionOperator *anti_comm = qf_ferm_op_anti_commutator(op1, op2);
Double-Commutator¶
-
OpType qf_op_type_double_commutator(const OpType *op_a, const OpType *op_b, const OpType *op_c, bool sign)¶
Caution
The function signature here is generic! A real one will replace
OpTypewith an actual operator representations andop_typewith its matching prefix (e.g.ferm_opforQfFermionOperator).The double-commutator is defined as follows (see also Equation (13.6.18) in [1]):
If
signisfalse, it returns\[[[A, B], C]/2 + [A, [B, C]]/2 = (2ABC + 2CBA - BAC - CAB - ACB - BCA)/2. \]If
signistrue, it returns\[\{[A, B], C\}/2 + \{A, [B, C]\}/2 = (2ABC - 2CBA - BAC + CAB - ACB + BCA)/2. \]- Parameters:
op_a – A pointer to the operator \(A\).
op_b – A pointer to the operator \(B\).
op_c – A pointer to the operator \(C\).
sign – the nature of the outer (anti-)commutator as per the definition above.
- Returns:
A pointer to the constructed operator anti-commutator.
Example¶
1QfFermionOperator *op1 = qf_ferm_op_zero();
2QkComplex64 coeff1 = {1.0, 0.0};
3bool action1[2] = {true, false};
4uint32_t modes1[2] = {0, 0};
5qf_ferm_op_add_term(op1, 2, action1, modes1, &coeff1);
6QfFermionOperator *op2 = qf_ferm_op_zero();
7QkComplex64 coeff2 = {2.0, 0.0};
8bool action2[2] = {false, true};
9uint32_t modes2[2] = {0, 0};
10qf_ferm_op_add_term(op2, 2, action2, modes2, &coeff2);
11QfFermionOperator *op3 = qf_ferm_op_zero();
12qf_ferm_op_add_term(op3, 2, action1, modes1, &coeff1);
13QkComplex64 coeff3 = {2.0, 0.5};
14qf_ferm_op_add_term(op3, 2, action2, modes2, &coeff3);
15
16QfFermionOperator *double_comm = qf_ferm_op_double_commutator(op1, op2, op3, false);
Functions¶
-
QfFermionOperator *qf_ferm_op_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b)¶
-
QfFermionOperator *qf_ferm_op_anti_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b)¶
-
QfFermionOperator *qf_ferm_op_double_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b, const QfFermionOperator *op_c, bool sign)¶
-
QfMajoranaOperator *qf_maj_op_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b)¶
-
QfMajoranaOperator *qf_maj_op_anti_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b)¶
-
QfMajoranaOperator *qf_maj_op_double_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b, const QfMajoranaOperator *op_c, bool sign)¶