Skip to content

Commit

Permalink
Gates in qutip-v5 User Guide (qutip#2441)
Browse files Browse the repository at this point in the history
Co-authored-by: alan-nala <[email protected]>
  • Loading branch information
alan-nala and cuanticalp authored Jun 12, 2024
1 parent c874c4a commit 167c30b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/apidoc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Quantum Operators
:members: charge, commutator, create, destroy, displace, fcreate, fdestroy, jmat, num, qeye, identity, momentum, phase, position, qdiags, qutrit_ops, qzero, sigmam, sigmap, sigmax, sigmay, sigmaz, spin_Jx, spin_Jy, spin_Jz, spin_Jm, spin_Jp, squeeze, squeezing, tunneling, qeye_like, qzero_like


Quantum Gates
-----------------

.. automodule:: qutip.core.gates
:members: rx, ry, rz, sqrtnot, snot, phasegate, qrot, cy_gate, cz_gate, s_gate, t_gate, cs_gate, ct_gate, cphase, cnot, csign, berkeley, swapalpha, swap, iswap, sqrtswap, sqrtiswap, fredkin, molmer_sorensen, toffoli, hadamard_transform, qubit_clifford_group, globalphase


Energy Restricted Operators
---------------------------

Expand Down
1 change: 1 addition & 0 deletions doc/changes/2441.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added `qutip.core.gates` to apidoc/functions.rst and a Gates section to guide-states.rst.
1 change: 1 addition & 0 deletions doc/guide/guide-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ Of course, like matrices, multiplying two objects of incompatible shape throws a

In addition, the logic operators "is equal" `==` and "is not equal" `!=` are also supported.


.. _basics-functions:

Functions operating on Qobj class
Expand Down
96 changes: 96 additions & 0 deletions doc/guide/guide-states.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,101 @@ the non-zero component is the zeroth-element of the underlying matrix (remember

If one wants to create spin operators for higher spin systems, then the :func:`.jmat` function comes in handy.

.. _quantum_gates:

Gates
=====

The pre-defined gates are shown in the table below:


.. cssclass:: table-striped

+------------------------------------------------+-------------------------------------------------------+
| Gate function | Description |
+================================================+=======================================================+
| :func:`~qutip.core.gates.rx` | Rotation around x axis |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.ry` | Rotation around y axis |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.rz` | Rotation around z axis |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.sqrtnot` | Square root of not gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.sqrtnot` | Square root of not gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.snot` | Hardmard gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.phasegate` | Phase shift gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.qrot` | A qubit rotation under a Rabi pulse |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.cy_gate` | Controlled y gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.cz_gate` | Controlled z gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.s_gate` | Single-qubit rotation |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.t_gate` | Square root of s gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.cs_gate` | Controlled s gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.ct_gate` | Controlled t gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.cphase` | Controlled phase gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.cnot` | Controlled not gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.csign` | Same as cphase |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.berkeley` | Berkeley gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.swapalpha` | Swapalpha gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.swap` | Swap the states of two qubits |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.iswap` | Swap gate with additional phase for 01 and 10 states |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.sqrtswap` | Square root of the swap gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.sqrtiswap` | Square root of the iswap gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.fredkin` | Fredkin gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.molmer_sorensen` | Molmer Sorensen gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.toffoli` | Toffoli gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.hadamard_transform` | Hadamard gate |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.qubit_clifford_group` | Generates the Clifford group on a single qubit |
+------------------------------------------------+-------------------------------------------------------+
| :func:`~qutip.core.gates.globalphase` | Global phase gate |
+------------------------------------------------+-------------------------------------------------------+

To load this qutip module, first you have to import gates:

.. code-block:: Python
from qutip import gates
For example to use the Hadamard Gate:

.. testcode:: [basics]

H = gates.hadamard_transform()
print(H)

**Output**:

.. testoutput:: [basics]
:options: +NORMALIZE_WHITESPACE

Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=Dense, isherm=True
Qobj data =
[[ 0.70710678 0.70710678]
[0.70710678 -0.70710678]]

.. _states-expect:

Expectation values
Expand Down Expand Up @@ -788,6 +883,7 @@ as well as the composite objects discussed in the next section :ref:`tensor`:

np.testing.assert_almost_equal(expect(sz2, two_spins), -1)


.. _states-super:

Superoperators and Vectorized Operators
Expand Down

0 comments on commit 167c30b

Please sign in to comment.