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), they are explained 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
qf_op_type_commutator
OpType qf_op_type_commutator(const OpType *op_a, const OpType *op_b)
The function signature here is generic! A real one will replace OpType with an actual operator representations and op_type with its matching prefix (for example, ferm_op for QfFermionOperator).
The commutator is defined as:
Parameters
- op_a – A pointer to the operator .
- op_b – A pointer to the operator .
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
qf_op_type_anti_commutator
OpType qf_op_type_anti_commutator(const OpType *op_a, const OpType *op_b)
The function signature here is generic! A real one will replace OpType with an actual operator representations and op_type with its matching prefix (for example, ferm_op for QfFermionOperator).
The anti-commutator is defined as:
Parameters
- op_a – A pointer to the operator .
- op_b – A pointer to the operator .
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
qf_op_type_double_commutator
OpType qf_op_type_double_commutator(const OpType *op_a, const OpType *op_b, const OpType *op_c, bool sign)
The function signature here is generic! A real one will replace OpType with an actual operator representations and op_type with its matching prefix (for example, ferm_op for QfFermionOperator).
The double-commutator is defined as follows (see also Chapter 13.6, Equation of motion methods, page 479 of [1]; the sign=false case is the symmetric double commutator appearing in Equation (2) of [2]):
If sign is false, it returns
If sign is true, it returns
[1]
R. McWeeny. Methods of Molecular Quantum Mechanics. 2nd Edition, Academic Press, 1992. ISBN 0-12-486552-6.
[2]
P. J. Ollitrault, A. Miessen, I. Tavernelli. Molecular Quantum Dynamics: A Quantum Computing Perspective. Acc. Chem. Res. 54, 4229-4238 (2021). https://doi.org/10.1021/acs.accounts.1c00514
Parameters
- op_a – A pointer to the operator .
- op_b – A pointer to the operator .
- op_c – A pointer to the operator .
- 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
qf_ferm_op_commutator
QfFermionOperator *qf_ferm_op_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b)
qf_ferm_op_anti_commutator
QfFermionOperator *qf_ferm_op_anti_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b)
qf_ferm_op_double_commutator
QfFermionOperator *qf_ferm_op_double_commutator(const QfFermionOperator *op_a, const QfFermionOperator *op_b, const QfFermionOperator *op_c, bool sign)
qf_maj_op_commutator
QfMajoranaOperator *qf_maj_op_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b)
qf_maj_op_anti_commutator
QfMajoranaOperator *qf_maj_op_anti_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b)
qf_maj_op_double_commutator
QfMajoranaOperator *qf_maj_op_double_commutator(const QfMajoranaOperator *op_a, const QfMajoranaOperator *op_b, const QfMajoranaOperator *op_c, bool sign)