You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples.rst
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
Examples
4
4
========
5
5
6
-
All of these example codes (and many more!) can be found on `GitHub <https://github.com/ProjectQ-Framework/FermiLib/tree/master/examples/>`_.
6
+
All of these examples (and more!) are explained in detail in the ipython notebook
7
+
fermilib_demo.ipynb located at `GitHub <https://github.com/ProjectQ-Framework/FermiLib/tree/master/examples/>`_.
7
8
8
9
.. toctree::
9
10
:maxdepth:2
@@ -60,7 +61,14 @@ FermionOperator supports a wide range of builtins including str(), repr(), =, ,
60
61
Qubit Operators
61
62
---------------
62
63
63
-
The QubitOperator data structure is another essential part of FermiLib. While the QubitOperator was originally developed for FermiLib, it is now part of the core ProjectQ library so that it can be interpreted by the ProjectQ compiler using the TimeEvolution gate. As the name suggests, QubitOperator is used to store qubit operators in almost exactly the same way that FermionOperator is used to store fermion operators. For instance :math:`X_0 Z_3 Y_4` is a QubitOperator. The internal representation of this as a terms tuple would be :math:`((0,"X"),(3,"Z"),(4,"Y"))((0,"X"),(3,"Z"),(4,"Y"))`. Note that one important difference between QubitOperator and FermionOperator is that the terms in QubitOperator are always sorted in order of tensor factor. In some cases, this enables faster manipulation. We initialize some QubitOperators below.
64
+
The QubitOperator data structure is another essential part of FermiLib. While
65
+
the QubitOperator was originally developed for FermiLib, it is now part of the
66
+
core ProjectQ library so that it can be interpreted by the ProjectQ compiler
67
+
using the TimeEvolution gate. As the name suggests, QubitOperator is used to
68
+
store qubit operators in almost exactly the same way that FermionOperator is
69
+
used to store fermion operators. For instance :math:`X_0 Z_3 Y_4` is a
70
+
QubitOperator. The internal representation of this as a terms tuple would be
71
+
:math:`((0, X),(3, Z),(4, Y))`. Note that one important difference between QubitOperator and FermionOperator is that the terms in QubitOperator are always sorted in order of tensor factor. In some cases, this enables faster manipulation. We initialize some QubitOperators below.
64
72
65
73
.. code-block:: python
66
74
@@ -72,7 +80,6 @@ The QubitOperator data structure is another essential part of FermiLib. While th
72
80
73
81
operator_2 = QubitOperator('X3 Z4', 3.17)
74
82
operator_2 -=77. * my_first_qubit_operator
75
-
print('')
76
83
print(operator_2)
77
84
78
85
Transformations
@@ -93,16 +100,14 @@ FermiLib also provides functions for mapping FermionOperators to QubitOperators,
93
100
94
101
# Transform to qubits under the Jordan-Wigner transformation and print its spectrum.
95
102
jw_operator = jordan_wigner(fermion_operator)
96
-
print('')
97
-
print(jw_operator)
98
103
jw_spectrum = eigenspectrum(jw_operator)
104
+
print(jw_operator)
99
105
print(jw_spectrum)
100
106
101
107
# Transform to qubits under the Bravyi-Kitaev transformation and print its spectrum.
102
108
bk_operator = bravyi_kitaev(fermion_operator)
103
-
print('')
104
-
print(bk_operator)
105
109
bk_spectrum = eigenspectrum(bk_operator)
110
+
print(bk_operator)
106
111
print(bk_spectrum)
107
112
108
113
We see that despite the different representation, these operators are iso-spectral. We can also apply the Jordan-Wigner transform in reverse to map arbitrary QubitOperators to FermionOperators. Note that we also demonstrate the .compress() method (a method on both FermionOperators and QubitOperators) which removes zero entries.
@@ -119,13 +124,11 @@ We see that despite the different representation, these operators are iso-spectr
0 commit comments