% vim: ft=tex
\section{The naive Simulator}

A quite big part of the simulations interesting for students and researchers is not
covered by stabilizer states and stabilizer circuits. In particular the 
phase estimation algorithm is essential for many applications. Being able to simulate
such an algorithm is essential for education.

\subsection{Simulator Core}

Recalling \ref{ref:nqbitsystems} an arbitrary $N$ qbit state $\ket{\psi}$ can be written as such:

\begin{equation}
    \ket{\psi} = \sum\limits_{i = 0}^{2^N - 1} c_i \ket{i} 
\end{equation}

Which yields $2^N$ coefficients $c_i = \braket{\psi}{i}$. These coefficients are used to
store the quantum mechanical state of the simulator and are stored in NumPy arrays \cite{numpy_array}.
They can be modified and viewed without overhead 
using python and allow fast modification using so-called NumPy ufuncs\cite{numpy_ufunc}.
A simulator state also contains a classical state which is a length $N$ integer array containing
the measured classical bits with a default value of $-1$.

The gates are implemented as NumPy ufuncs which allows an efficient
manipulation of NumPy arrays using C code. Every gate maps a length $2^N$
\lstinline[basicstyle=\ttfamily, language=Python]{numpy.cdouble} and a length
$N$ \lstinline[basicstyle=\ttfamily, language=Python]{numpy.int8} array to
a length $2^N$ \lstinline[basicstyle=\ttfamily,
language=Python]{numpy.cdouble}, a length $N$ \lstinline[basicstyle=\ttfamily,
language=Python]{numpy.int8} and a \lstinline[basicstyle=\ttfamily,
language=Python]{numpy.uint64} scalar.  The \lstinline[basicstyle=\ttfamily,
language=Python]{numpy.cdouble} arrays are the quantum mechanical state before
and after the gate; the \lstinline[basicstyle=\ttfamily,
language=Python]{numpy.int8} arrays are the respective classical states and the
\lstinline[basicstyle=\ttfamily, language=Python]{numpy.uint64} scalar has
a logical one at every bit that has been measured. 

\subsection{Implemented Gates}

As stated in \ref{ref:singleqbitsystems} and \ref{ref:nqbitsystems} a just a small set of gates is required to 
approximate an arbitrary unitary matrix arbitrarily good. In principle just the $X$, $R_\phi$, $H$ and $CNOT$ gate
would be sufficient for a simulator. As however both $X$ and $Z$ are often used in practice FIXME: CITATION NEEDED
$X$, $Z$, $R_\phi$, $H$ and $CNOT$ are implemented. They can be accessed using 
\lstinline[basicstyle=\ttfamily]{pyqcs.X}, \lstinline[basicstyle=\ttfamily]{pyqcs.Z}, \lstinline[basicstyle=\ttfamily]{pyqcs.R},
\lstinline[basicstyle=\ttfamily]{pyqcs.H} and \lstinline[basicstyle=\ttfamily]{pyqcs.C}.

\subsection{Usage}

FIXME

\subsection{Performance}

FIXME
