Quantum Unitary Simulator - qus

by Mika Uusnakki

The program "qus" simulates the effects of the Hadamard and Controlled Phase quantum operators on a Q-bit register and allows for the execution of Shor's Factorization algorithm

Included with the program is a script, Shor15.txt, which when run from the program will create an 8 qubit system, and perform the steps for Shor's factorization algorithm as described by Ekert and Jozsa in Reviews of Modern Physics Vol68, No 3, July 1996. The script uses y=7 for the random number used in the modular exponentiation step.

The program and accessory files may be downloaded from http://gene.phys.washington.edu/~bertsch/qus.tar It contains the following:

qus.cpp Contains main() and Interface class
Operator.h Contains Matrix2d2 class and Operator class
QuNbit.h Contains QuNbit class, which contains the implementation of most commands on the register
ASCIIMenuConstants.h Provides globally accessible variables and functions for pretty output to console
Shor15.txt The script file for executing Shor's factorization algorithm on the number 15
qus_ReadMe.htm This document
qus_thumb.gif thumbnail image for qus_ReadMe.htm
qus.gif full image of qus output for qus_ReadMe.htm

The program is written in c++ and has been verified to compile and run under WindowsXP and Linux (gcc 3.x).


Commands:

New System
  n(size);
Creates a qubit system with size number of qubits. This system is initialized so that the |0> state has amplitude 1.
Execute Hadamard
  h(targetbit);
This command takes the 2x2 Hadamard matrix: [[1,1][1,-1]] and applies it to the target bit.
The first bit has index 0.
Execute ControlledPhase
  c(targetbit, phaseangle_modPI, controlbit1, controlbit2, ...);
This command takes the 2x2 matrix: [[1,0][0,e^(i*pi*theta)]] and applies it to the target bit, only if all the control bits are 1.
The first bit has index 0. The control bits are optional parameters.
Reverse Bitorder on bases
  b(FirstBit, LastBit); or b;
This command will send the amplitude of each computational basis to the basis which is the result of reversing the positions of the digits in the interval defined by FirstBit, LastBit in the binary expansion of the original basis. For Example: b(1,2); will exchange the amplitudes of |13> (|1101>) and |11> (|1011>).
If FirstBit and LastBit are not supplied, the reverse will be performed on the entire system.
Perform DFT
  d(FirstBit, LastBit); or d;
This command will perform the appropriate combination of Hadamard and Controlled Phase operations on the range of qubits. This sequence mimics the sequence given in Ekert and Jozsa.
If FirstBit and LastBit are not supplied, the reverse will be performed on the entire system.
Modular Exponentiation
  x(y, n);
This command does not use quantum operators to achieve modular exponentiation. This explicity maps amplitudes from one basis and assigns them to another. | a*2^(size/2) > -> | a*2^(size/2) + y^a mod n >
Perform Measurement
  m(FirstBit, LastBit); or m;
This command measures the specified range of bits, causing that set of bits to collapse to a single state with a probability of the square magnitude of the amplitude of that state. Afterward, the entire system is then renormalized.
If FirstBit and LastBit are not supplied, the reverse will be performed on the entire system.
Run Script
  r(filename);
This command will open the given file and consider its contents as if it had been typed into the prompt. In this way one can create scripts for performing certain tasks. A sample script Shor15.txt has been provided that goes through the procedure of factoring 15 via Shor's algorithm.
Toggle Suppression of Menu
  s;
This command will cause the program to cease output of the command menu and notes section. These are automatically suppressed when executing multiple commands separated by semicolons.
Quit
  q;
Ends the program


Additional Notes:

1: For systems of 8 or more qubits, the program does not output all basis states to the console. Instead, it filters the basis states, and only displays the states with amplitudes with square magnitude greater than 1/size (size being the number of qubits in the system).
- For example, the command n(8);d; will end up displaying nothing because the DFTQ applied to |0> results in a state with every basis having the same amplitude = 1/sqrt(8) = .3536

2: The command parser has been designed to be very forgiving with syntax. However, sometimes this can be a problem.
- For example: n(8)d; this command will only perform n(8); and the program will NOT warn you that your intended DFTQ did not occur.