some work here

This commit is contained in:
Daniel Knüttel 2020-03-07 14:52:13 +01:00
parent 7225d1a98e
commit d3eda188c5

View File

@ -5,6 +5,12 @@ This chapter discusses how the concepts introduced before are implemented
into a simulator. Futher the infrastructure around the simulation and some
tools are explained.
The implementation is written as a \lstinline{python3} module. This allows
users to quickly construct circuit, apply them to a state and measure amplitudes.
Full access to the state (including intermediate) state has been priorized over
execution speed. To keep the simulation speed as high as possible under these
constraints some parts are implemented in \lstinline{C}
\subsection{Dense State Vector Simulation}
\subsubsection{Representation of Dense State Vectors}
@ -69,3 +75,78 @@ a unitary $2\times2$ matrix as a NumPy \lstinline{cdouble} array and builds a ga
\subsubsection{Circuits}
As mentioned in \ref{ref:quantum_circuits} quantum circuits are central in quantum programming.
In the implementation great care was taken to make writing circuits as convenient and readable as
possible. Users will almost never access the actual gates that perform the operation on a state;
instead they will handle circuits.\\
Circuits can be applied to a state by multiplying them from the left on a state object:
\begin{lstlisting}[language=Python]
new_state = circuit * state
\end{lstlisting}
The elementary gates such as $H, R_\phi, CX$ are implemented as single gate circuits and can be constructing using
the built-in generators. The generators take the act-qbit as first argument, parameters such as the control qbit
or an angle as second argument:
%\adjustbox{max width=\textwidth}{
\begin{lstlisting}[language=Python]
In [1]: from pyqcs import CX, CZ, H, R, Z, X
...: from pyqcs import State
...:
...: state = State.new_zero_state(2)
...: intermediate_state = H(0) * state
...:
...: bell_state = CX(1, 0) * intermediate_state
In [2]: bell_state
Out[2]: (0.7071067811865476+0j)*|0b0> + (0.7071067811865476+0j)*|0b11>
\end{lstlisting}
%}
Large circuits can be constructed using the binary OR operator \lstinline{|} in an analogy to the
pipeline operator on many *NIX systems. As usual circuits are read from left to right similar to pipelines on
*NIX systems:
%\adjustbox{max width=\textwidth}{
\begin{lstlisting}[language=Python]
In [1]: from pyqcs import CX, CZ, H, R, Z, X
...: from pyqcs import State
...:
...: state = State.new_zero_state(2)
...:
...: # This is the same as
...: # circuit = H(0) | CX(1, 0)
...: circuit = H(0) | H(1) | CZ(1, 0) | H(1)
...:
...: bell_state = circuit * state
In [2]: bell_state
Out[2]: (0.7071067811865477+0j)*|0b0> + (0.7071067811865477+0j)*|0b11>
\end{lstlisting}
%}
A quick way to generate circuits programatically is to use the \lstinline{list_to_circuit}
function:
%\adjustbox{max width=\textwidth}{
\begin{lstlisting}[language=Python]
In [1]: from pyqcs import CX, CZ, H, R, Z, X
...: from pyqcs import State, list_to_circuit
...:
...: circuit_CX = list_to_circuit([CX(i, i-1) for i in range(1, 5)])
...:
...: state = (H(0) | circuit_CX) * State.new_zero_state(5)
In [2]: state
Out[2]: (0.7071067811865476+0j)*|0b0> + (0.7071067811865476+0j)*|0b11111>
\end{lstlisting}
%}
\subsection{Graphical State Simulation}
\subsubsection{Graphical States}