some reformatting of code & a little work

This commit is contained in:
Daniel Knüttel 2020-03-14 15:16:55 +01:00
parent 20ff5399e6
commit 89f6f5bec2
1 changed files with 34 additions and 22 deletions

View File

@ -273,39 +273,51 @@ always done in three steps:
\subsection{Utilities}
To make both using the simulators more convenient and to help with using them in
as scientific or educational context several utilities have been written. This chapter
explains some of them.
To make both using the simulators more convenient and to help with using them
in as scientific or educational context several utilities have been written.
This chapter explains some of them.
\subsubsection{Sampling and Circuit Generation}
The function \lstinline{pyqcs.sample} provides a simple way to sample from a state.
Copies of the state are made when necessary and the results are returned
in a \lstinline{collections.Counter} object. Several qbits can be sampled at once; they can be passed
to the function either as an integer which will be interpreted as a bit mask and the
least significant bit will be sampled first. When passing the qbits to sample as a list
of integers the integers are interpreted as qbit indices and are measured in the order
they appear.
The function \lstinline{pyqcs.sample} provides a simple way to sample from
a state. Copies of the state are made when necessary and the results are
returned in a \lstinline{collections.Counter} object. Several qbits can be
sampled at once; they can be passed to the function either as an integer which
will be interpreted as a bit mask and the least significant bit will be sampled
first. When passing the qbits to sample as a list of integers the integers are
interpreted as qbit indices and are measured in the order they appear.
If the keyword argument \lstinline{keep_states} is \lstinline{True} the sampling
function will include the resulting states in the result. At the moment this works
for dense vectors only. Checking for equality on graphical states has yet to be implemented
but can be done in polynomial time \cite{dahlberg_ea2019}.
If the keyword argument \lstinline{keep_states} is \lstinline{True} the
sampling function will include the resulting states in the result. At the
moment this works for dense vectors only. Checking for equality on graphical
states has yet to be implemented but can be done in polynomial time
\cite{dahlberg_ea2019}.
Writing circuits out by hand can be rather painful. The function \lstinline{pyqcs.list_to_circuit}
Converts a list of circuits to a circuit. This is particularely helpful in combination
with python's \lstinline{listcomp}:
Writing circuits out by hand can be rather painful. The function
\lstinline{pyqcs.list_to_circuit} Converts a list of circuits to a circuit.
This is particularely helpful in combination with python's
\lstinline{listcomp}:
\begin{lstlisting}
circuit_H = list_to_circuit([H(i) for i in range(nqbits)])
\end{lstlisting}
The module \lstinline{pyqcs.util.random_circuits} provides the method described in \ref{ref:performance}
to generate random circuits for both graphical and dense vector simulation. Using the module
\lstinline{pyqcs.util.random_graphs} one can generate random graphical states which is more performant
than using random circuits.
The module \lstinline{pyqcs.util.random_circuits} provides the method described
in \ref{ref:performance} to generate random circuits for both graphical and
dense vector simulation. Using the module \lstinline{pyqcs.util.random_graphs}
one can generate random graphical states which is more performant than using
random circuits.
\subsubsection{Exporting Circuits, Graphical States}
\subsubsection{Exporting Circuits and Graphical States}
Circuits can be drawn using the \LaTeX package \lstinline{qcircuit}; all
circuits in this documents use \lstinline{qcircuit}. To visualize the circuits
built using \lstinline{pyqcs} the function
\lstinline{pyqcs.util.to_diagram.circuit_to_diagram} can be used to generate
\lstinline{qcircuit} code that can be used in \LaTeX documents or exported to
PDFs directly. The diagrams produced by this function is not optimized and the
diagrams can be unnecessary long. Usually this can be fixed easily by editing
the produced code manually.
\subsection{Performance}