% 
% File:	  test4.qasm
% Date:	  22-Mar-04
% Author: I. Chuang <ichuang@mit.edu>
%
% Sample qasm input file - quantum
% fourier transform on three qubits
% 
% 	def	c-S,1,'S'
% 	def	c-T,1,'T'
% 
% 	qubit	j0
% 	qubit	j1
% 	qubit	j2
% 
% 	h	j0	
% 	c-S	j1,j0
% 	c-T	j2,j0
% 	nop	j1
% 	h	j1
% 	c-S	j2,j1
% 	h	j2
% 	swap	j0,j2

%  Time 01:
%    Gate 00 h(j0)
%  Time 02:
%    Gate 01 c-S(j1,j0)
%  Time 03:
%    Gate 02 c-T(j2,j0)
%    Gate 03 nop(j1)
%  Time 04:
%    Gate 04 h(j1)
%  Time 05:
%    Gate 05 c-S(j2,j1)
%  Time 06:
%    Gate 06 h(j2)
%  Time 07:
%    Gate 07 swap(j0,j2)

% Qubit circuit matrix:
%
% j0: gAA, gBA, gCA, n  , n  , n  , gGA, n  
% j1: n  , gBB, gCB, gDB, gEB, n  , n  , n  
% j2: n  , n  , gCC, n  , gEC, gFC, gGC, n  

\documentclass[11pt]{article}
\input{xyqcirc.tex}

% definitions for the circuit elements

\def\gAA{\op{H}\w\A{gAA}}
\def\gBB{\b\w\A{gBB}}
\def\gBA{\op{S}\w\A{gBA}}
\def\gCC{\b\w\A{gCC}}
\def\gCA{\op{T}\w\A{gCA}}
\def\gCB{*-{}\w\A{gCB}}
\def\gDB{\op{H}\w\A{gDB}}
\def\gEC{\b\w\A{gEC}}
\def\gEB{\op{S}\w\A{gEB}}
\def\gFC{\op{H}\w\A{gFC}}
\def\gGA{\t\w\A{gGA}}
\def\gGC{\t\w\A{gGC}}

% definitions for bit labels and initial states

\def\bA{ \q{j_{0}}}
\def\bB{ \q{j_{1}}}
\def\bC{ \q{j_{2}}}

% The quantum circuit as an xymatrix

\xymatrix@R=5pt@C=10pt{
    \bA & \gAA &\gBA &\gCA &\n   &\n   &\n   &\gGA &\n  
\\  \bB & \n   &\gBB &\gCB &\gDB &\gEB &\n   &\n   &\n  
\\  \bC & \n   &\n   &\gCC &\n   &\gEC &\gFC &\gGC &\n  
%
% Vertical lines and other post-xymatrix latex
%
\ar@{-}"gBA";"gBB"
\ar@{-}"gCA";"gCC"
\ar@{-}"gEB";"gEC"
\ar@{-}"gGA";"gGC"
}

\end{document}
