some reformatting of code & a little work
This commit is contained in:
parent
20ff5399e6
commit
89f6f5bec2
|
@ -273,39 +273,51 @@ always done in three steps:
|
||||||
|
|
||||||
\subsection{Utilities}
|
\subsection{Utilities}
|
||||||
|
|
||||||
To make both using the simulators more convenient and to help with using them in
|
To make both using the simulators more convenient and to help with using them
|
||||||
as scientific or educational context several utilities have been written. This chapter
|
in as scientific or educational context several utilities have been written.
|
||||||
explains some of them.
|
This chapter explains some of them.
|
||||||
|
|
||||||
\subsubsection{Sampling and Circuit Generation}
|
\subsubsection{Sampling and Circuit Generation}
|
||||||
|
|
||||||
The function \lstinline{pyqcs.sample} provides a simple way to sample from a state.
|
The function \lstinline{pyqcs.sample} provides a simple way to sample from
|
||||||
Copies of the state are made when necessary and the results are returned
|
a state. Copies of the state are made when necessary and the results are
|
||||||
in a \lstinline{collections.Counter} object. Several qbits can be sampled at once; they can be passed
|
returned in a \lstinline{collections.Counter} object. Several qbits can be
|
||||||
to the function either as an integer which will be interpreted as a bit mask and the
|
sampled at once; they can be passed to the function either as an integer which
|
||||||
least significant bit will be sampled first. When passing the qbits to sample as a list
|
will be interpreted as a bit mask and the least significant bit will be sampled
|
||||||
of integers the integers are interpreted as qbit indices and are measured in the order
|
first. When passing the qbits to sample as a list of integers the integers are
|
||||||
they appear.
|
interpreted as qbit indices and are measured in the order they appear.
|
||||||
|
|
||||||
If the keyword argument \lstinline{keep_states} is \lstinline{True} the sampling
|
If the keyword argument \lstinline{keep_states} is \lstinline{True} the
|
||||||
function will include the resulting states in the result. At the moment this works
|
sampling function will include the resulting states in the result. At the
|
||||||
for dense vectors only. Checking for equality on graphical states has yet to be implemented
|
moment this works for dense vectors only. Checking for equality on graphical
|
||||||
but can be done in polynomial time \cite{dahlberg_ea2019}.
|
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}
|
Writing circuits out by hand can be rather painful. The function
|
||||||
Converts a list of circuits to a circuit. This is particularely helpful in combination
|
\lstinline{pyqcs.list_to_circuit} Converts a list of circuits to a circuit.
|
||||||
with python's \lstinline{listcomp}:
|
This is particularely helpful in combination with python's
|
||||||
|
\lstinline{listcomp}:
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
circuit_H = list_to_circuit([H(i) for i in range(nqbits)])
|
circuit_H = list_to_circuit([H(i) for i in range(nqbits)])
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
The module \lstinline{pyqcs.util.random_circuits} provides the method described in \ref{ref:performance}
|
The module \lstinline{pyqcs.util.random_circuits} provides the method described
|
||||||
to generate random circuits for both graphical and dense vector simulation. Using the module
|
in \ref{ref:performance} to generate random circuits for both graphical and
|
||||||
\lstinline{pyqcs.util.random_graphs} one can generate random graphical states which is more performant
|
dense vector simulation. Using the module \lstinline{pyqcs.util.random_graphs}
|
||||||
than using random circuits.
|
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}
|
\subsection{Performance}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user