next up previous contents
Next: The Graphical User Application Up: The Bloch Sphere Previous: Applying the patch   Contents

Using the bloch sphere code inside the QCL

The Bloch Sphere code allows you to view the state of a single qubit inside the QCL. A windowing system such as XFree86 must be in use to allow the viewing of the bloch sphere, this code cannot be run from a console, unless the graphical output is being redirected to an x-server somewhere.

First of all, start up the Quantum Computing language. To use the test program detailed below, initialise the QCL like this;


\begin{lstlisting}[frame=trbl]{}
./qcl -i lib/bloch.qcl
\end{lstlisting}

A test program to show the usage of the bloch sphere code, is provided in the "bloch.qcl" file in the lib subdirectory.

\begin{lstlisting}[frame=trbl,caption=bloch.qcl, label=lst:blochqcl]{}
procedure...
...bility 0.2
bloch a; // Display the qubit on the bloch sphere
}
\end{lstlisting}


This procedure initialises a quantum register of size 1 qubit. The qubit is superposed with the Mix operation, ie. the Hadamard operation, with the qubit being in the resultant state of;

\begin{displaymath}
\vert\phi\rangle = \frac{1}{\sqrt(2)}\vert\rangle + \frac{1}{\sqrt(2)}\vert 1\rangle
\end{displaymath} (1)

The Rot operation is then applied to the qubit, so that when measured, the qubit is in state $\vert\rangle $ with probability 0.8 and state $\vert 1\rangle $ with probability 0.2 The bloch sphere of that qubit is then produced with the command bloch a. This produces the following screenshot using XFree86 4.3;

bloch_sphere.png


next up previous contents
Next: The Graphical User Application Up: The Bloch Sphere Previous: Applying the patch   Contents
Colm O hEigeartaigh 2003-05-30