COMPUTING SCIENCE

# Programming Your Quantum Computer

The hardware doesn’t yet exist, but languages for quantum coding are ready to go.

# The Imperative Mood

QCL, or Quantum Computation Language, is the invention of Bernhard Ömer of the Vienna University of Technology. He began the project in 1998 and continues to extend and refine it. Ömer’s interpreter for the language (http://www.itp.tuwien.ac.at/~oemer/qcl.html) includes an emulator that runs quantum programs on classical hardware. Of course the emulator can’t provide the speedup of quantum parallelism; on the other hand, it offers the programmer some helpful facilities—such as commands for inspecting the internal state of qubits—that are impossible with real quantum hardware.

QCL borrows the syntax of languages such as C and Java, which are sometimes described as “imperative” languages because they rely on direct commands to set and reset the values of variables. As noted, such commands are generally forbidden within a quantum computation, and so major parts of a QCL program run only on classical hardware. The quantum system serves as an “oracle,” answering questions that can be posed in a format suitable for qubit computations. Each query to the oracle must have the requisite stovepipe architecture, but it can be embedded in a loop in the outer, classical context. During each iteration, the quantum part of the computation starts fresh and runs to completion.

An annotated snippet of code written in QCL is shown in the illustration at right. The procedure shown, which is taken from a 2000 paper by Ömer, calculates the discrete Fourier transform, a crucial step in Shor’s factoring algorithm. Fourier analysis resolves a waveform into its constituent frequencies. In Shor’s algorithm a number to be factored is viewed as a wavelike, periodic signal. If *N* has the factors *u* and *v*, then *N* consists of *u* repetitions of *v* or *v *repetitions of *u*. Shor’s algorithm uses quantum parallelism to search for the period of such repetitions, although the process is not as simple and direct as this account might suggest. The QCL program has a classical control structure, with two nested loops, and a quantum section that performs the actual Fourier transform.

**IN THIS SECTION**

EMAIL TO A FRIEND :

**Of Possible Interest**

**Essay**: Invitation to an Insect Rendezvous

**Spotlight**: First Person: Exploring the Unconscious Brain

**Feature Article**: Social Media Monitors the Largest Fish in the Sea