next up previous contents
Next: Composed Operators Up: Operators and Algorithms Previous: Operators and Algorithms   Contents

Subsections


Elementary Operators

This section introduces the possible elementary operators, that can be used with the current implementation of QCL. Since QCL as a language doesn't enforce a specific set of elementary operators, they have to be declared as external (see section 2.5.1.3), to make them available to programs.

This is usually done within the default include file default.qcl (see appendix A.1), which is loaded at startup.


General Unitary Operators


Unitary Matrices

The most general form for specifying a unitary operator (or any other linear transformation) is by defining it's matrix elements: An $n$ qubit unitary operator $U$ describes a transformation $U:{\bf C}^{2^n}\to{\bf C}^{2^n}$ and therefore corresponds to a $2^n \times 2^n$ matrix in ${\bf C}$

\begin{displaymath}
U=\sum_{i,j=0}^{2^n} {\vert i \rangle} u_{ij} {\langle j\ve...
...\
u_{2^n-1,0} & \cdots & u_{2^n-1,2^n-1} \end{array}\right)}
\end{displaymath} (3.1)

Since for a unitary transformation $U^\dagger U={(U^*)}^\mathrm{T}U=I(n)$, the Matrix $U$ unitary if and only if
\begin{displaymath}
\bigwedge_{i,j=0}^{2^n-1}\:
\sum_{k=0}^{2^n-1}\,u^*_{ik} u_{kj}=1
\end{displaymath} (3.2)

QCL provides external operators for general unitary $2\times 2$, $4\times 4$ and $8\times 8$ matrices, which the programmer can use to directly implement a custom set of 1, 2 and 3 qubit gates.
extern operator Matrix2x2(
  complex u00,complex u01,
  complex u10,complex u11,
qureg q);
extern operator Matrix4x4(...,qureg q);
extern operator Matrix8x8(...,qureg q);
Matrix operators are checked for unitarity before they are applied:
qcl> const i=(0,1);       
qcl> qureg q[1];
qcl> Matrix2x2(i*cos(pi/6),i*sin(pi/6),(0,0),(1,0),q);
! external error: matrix operator is not unitary


Qubit Rotation

The rotation of a single qubit is defined by the transformation matrix $U(\theta)$

\begin{displaymath}
U(\theta)={\left(\begin{array}{cc}
\cos\frac{\theta}{2} & ...
...sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{array}\right)}
\end{displaymath} (3.3)

The factor $-\frac{1}{2}$ to $\theta$ is set in analogy to spin rotations, which can be shown to be of the form $\mathcal{D}=e^{-\frac{i}{2}\delta_j \sigma_j}$ and thus have a period of $4\pi$.
extern operator Rot(real theta,qureg q);
In contrast to most other external Operators, Rot is not generalised to work with arbitrary register sizes.
qcl> Rot(pi/2,q);
! external error: Only single qubits can be rotated


Hadamard Gate

The Hadamard Gate is a special case of a generalised qubit Rotation and defined by the transformation matrix $H$

\begin{displaymath}
H=\frac{1}{\sqrt 2}{\left(\begin{array}{cc}1 & 1 \\ 1 & -1\end{array}\right)}
\end{displaymath} (3.4)

For the case of $n$ qubit registers, $H$ can be generalised to
\begin{displaymath}
H:{\vert i \rangle}\to 2^{-\frac{n}{2}}
\sum_{j\in\mathbf{B}^n} (-1)^{(i,j)}\, {\vert j \rangle}
\end{displaymath} (3.5)

The vectors $\mathcal{B'}=\{i\in\mathbf{B}^n\,\vert\,{\vert i' \rangle}=H\,{\vert i \rangle}\}$ form the Hadamard base or dual base or parity base to $\mathcal{B}=\{i\in\mathbf{B}^n\,\vert\,{\vert i \rangle}\}$.

The Hadamard Transformation is self adjoint (i.e. $H^\dagger =H$), which, for unitary operators, implies that $H^2=I$.

Since $\mathcal{B'}$ only contains uniform superpositions that just differ by the signs of the base-vectors, the external implementation of $H$ id called ${\tt Mix}$.

extern operator Mix(qureg q);


Conditional Phase Gate

The conditional phase gate is a pathological case of a conditional operator (see section 1.3.5), for the zero-qubit phase operator $e^{i\phi}$.

\begin{displaymath}
V(\phi):{\vert\epsilon \rangle}
\to \left\{ \begin{array}{...
...vert\epsilon \rangle} & \;\mbox{otherwise}
\end{array}\right.
\end{displaymath} (3.6)

The conditional phase gate is used in the quantum Fourier transform (see section 3.2.3).
extern operator CPhase(real phi,qureg q);


Pseudo-classic Operators


Base Permutation

The most general form for specifying an $n$ qubit pseudo-classic operator $U$, is by explicitly defining the underlying permutation $\pi$ of base-vectors:

\begin{displaymath}
U_{\mathit{pc.}}=\sum_{i=0}^{2^n-1} {\vert\pi_i \rangle}{\langle i\vert}
= {\langle \pi_0,\pi_1 \ldots \pi_{2^n-1} \rangle}
\end{displaymath} (3.7)

QCL provides external operators for vector permutations for $\vert\pi\vert=2, 4, 8, 16, 32$ and $64$ which the programmer can use to directly implement a custom set of $1$ to $6$ qubit pseudo-classical operators:

extern qufunct Perm2(int p0 ,int p1 ,qureg q);
extern qufunct Perm4(int p0 ,int p1 ,int p2 ,int p3 ,qureg q);
extern qufunct Perm8(...,qureg q);
extern qufunct Perm16(...,qureg q);
extern qufunct Perm32(...,qureg q);
extern qufunct Perm64(...,qureg q);
Base permutations are checked for unitarity before they are applied (i.e. it is verified that the given integer sequence is in fact a permutation)
qcl> qureg q[3];
qcl> Perm8(0,0,1,2,3,4,5,6,q);
! external error: no permutation


Fanout

The $\mathit{FANOUT}$ operation is a quantum function (see section 1.3.3.2) and stands for a class of transformations with the characteristic $\mathit{FANOUT}: {\vert x,0 \rangle}\to{\vert x,x \rangle}$ (see section 2.5.6.2 for details).

The external fanout operator of QCL is defined as

\begin{displaymath}
\mathit{FANOUT}: {\vert x,y \rangle}\,\to\,{\vert x,x \oplus y \rangle},
\end{displaymath} (3.8)

however, it is considered bad programming style to rely on this particular implementation.
extern qufunct Fanout(quconst a,quvoid b);


Swap

The $\mathit{SWAP}$ operator exchanges the qubits of two equal sized registers ( $\mathit{SWAP}:{\vert x,y \rangle}\to{\vert y,x \rangle}$). A one to one qubit $\mathit{SWAP}$ operator has the transformation matrix

\begin{displaymath}
\mathit{SWAP}={\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \\ ...
... & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \end{array}\right)}
\end{displaymath} (3.9)

extern qufunct Swap(qureg a,qureg b);


Not and Controlled Not

The not operator $C$ inverts a qubit. Its transformation matrix is

\begin{displaymath}
C={\left(\begin{array}{cc}0 & 1 \\ 1 & 0\end{array}\right)}
\end{displaymath} (3.10)

The controlled-not operator $C_{[[\mathbf{e}]]}$ is the conditional operator (see section 1.3.5) to $C$ with the enable register $\mathbf{e}$:
\begin{displaymath}
C_{[[\mathbf{e}]]}:{\vert b \rangle}{\vert\epsilon \rangle}...
...angle}_\mathbf{e} & \;\mbox{otherwise} \\
\end{array}\right.
\end{displaymath} (3.11)

extern qufunct Not(qureg q);
extern qufunct CNot(qureg q,quconst c);
The QCL versions of Not and CNot also work on target registers:
qcl> qureg q[4]; qureg p[4];
qcl> Not(q);
[8/8] 1 |00001111>
qcl> CNot(p,q);
[8/8] 1 |11111111>


next up previous contents
Next: Composed Operators Up: Operators and Algorithms Previous: Operators and Algorithms   Contents

(c) Bernhard Ömer - oemer@tph.tuwien.ac.at - http://tph.tuwien.ac.at/~oemer/