帮助绘制量子电路

帮助绘制量子电路

我正在寻找一些帮助或指导,以获得更多使用 tikz 绘制量子电路的示例,类似于http://texample.net/tikz/examples/quantum-circuit/

从上面的链接开始我创建了以下内容:

\documentclass[10pt]{article}
\usepackage[hang,small,bf]{caption}    % fancy captions
\usepackage{tikz}
\usetikzlibrary{backgrounds,fit,decorations.pathreplacing}                  % TikZ libraries
\newcommand{\ket}[1]{\ensuremath{\left|#1\right\rangle}} % Dirac Kets
%%%
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{comment}
:Title: Quantum circuit
This code produces an image of a "quantum circuit" for addition modulus p of two n bit numbers using two ancillary qubits, one clean and set as zero, and one dirty. Both are returned to their initial state.
\end{comment}
\begin{document}
\begin{figure}
\centerline{
\begin{tikzpicture}[thick]
\tikzstyle{operator} = [draw,fill=white,minimum size=1.5em] 
\tikzstyle{phase} = [fill,shape=circle,minimum size=5pt,inner sep=0pt]
\tikzstyle{surround} = [fill=blue!10,thick,draw=black,rounded corners=2mm]
%
% Qubits
\node at (0,0) (q0)  {\ket{x^n}};
\node at (0,-1) (q1) {\ket{y^n}};
\node at (0,-2) (q2) {\ket{0}};
\node at (0,-3) (q3) {\ket{g}};
\node at (0,-4) (q4) {\ket{\tt ctrl}};
%
% Column 1
\node[operator] (op1-0) at (1,0) {$+$} edge [-] (q0);
\node[operator] (op1-1) at (1,-1) {$+$} edge [-] (q1);
\node[operator] (op1-2) at (1,-2) {$+$} edge [-] (q2);
\draw[-] (op1-1) -- (op1-2);
\draw[-] (op1-0) -- (op1-1);
%
% Column 2
\node[operator] (op2-1) at (2,-1) {$-p$} edge [-] (op1-1);
\node[operator] (op2-2) at (2,-2) {$-p$} edge [-] (op1-2);
\node[operator] (op2-3) at (2,-3) {$-p$} edge [-] (q3);
\draw[-] (op2-1) -- (op2-2);
\draw[-] (op2-2) -- (op2-3);
%
% Column 3
\node[operator] (op3-1) at (3,-1) {$+p$} edge [-] (op2-1);
\node[phase] (ph3-2) at (3,-2) {} edge [-] (op2-2);
\node[operator] (op3-3) at (3,-3) {$+p$} edge [-] (op2-3);
\draw[-] (op3-1) -- (ph3-2);
\draw[-] (ph3-2) -- (op3-3);
%
% Column 4
\node[operator] (op4-0) at (4,0) {$>$} edge [-] (op1-0);
\node[operator] (op4-1) at (4,-1) {$>$} edge [-] (op3-1);
\node[operator] (op4-2) at (4,-2) {$>$} edge [-] (ph3-2);
\draw[-] (op4-1) -- (op4-2);
\draw[-] (op4-0) -- (op4-1);
%
% Column 5
\node[operator] (op5-2) at (5,-2) {$\oplus$} edge [-] (op4-2);
%
% Column 6
\node (end1) at (6,0)  {\ket{x^n}} edge [-] (op4-0);
\node (end1) at (6,-1) {\ket{(x+y)^n}} edge [-] (op4-1);
\node (end1) at (6,-2) {\ket{0}} edge [-] (op5-2);
\node (end2) at (6,-3) {\ket{g}} edge [-] (op3-3);
\node (end3) at (6,-4) {\ket{{\tt ctrl}}} edge [-] (q4);
\end{tikzpicture}
 }
\caption{}
\end{figure}
\end{document}}

在此处输入图片描述 但我希望这些框能同时覆盖两个或三个量子位,而不是单独的框。这样第一列就是一个矩形,覆盖前三个量子位。这可能吗?如果您对此有建议,我也想删除 |0> 量子位周围的框。

相关内容