The second example is the in-place addition using QFT [A. Fijany and C.P. Williams, quant-ph/9809004 (1998); T.G. Draper, quant-ph/0008033 (2000)].

Program:
# The initial state is \rho=diag(1.0, 0.0) x diag(1.0, 0.0) x diag(0.0, 1.0).
# In the command of init-mixed, a user specifies every
# population of |0> of an individual qubit.

init-mixed 1.0 1.0 0.0;

# Definition of extrinsic matrices. Here, ej means \exp(i) and pi means \pi.
matrix R1 (1 0)(0 1ej1pi);
matrix R2 (1 0)(0 1ej0.5pi);
matrix R3 (1 0)(0 1ej0.25pi);

# The beginning of the circuit.
0: print Initial state is \t; showb; print Then apply H(2).\n;
10: H(2);

20: print The state before the addition circuit is\n; showb;
30: print Add 001 using QFT.\n;

# Apply QFT to the bits 1-3.
40: FT(1-3);
# Attach the phases, i.e., R3 to bit 3, R2 to bit 2, R1 to bit 1.
50: R3(3); R2(2); R1(1);
# Apply QFT^-1 to the bits 1-3.
60: FT^-1(1-3);

70: print The result is\n;
80: showb;


The result from the run of this program:
[akira@localhost silqcs]\$ ./qcs examples/Inplace-Add-Density-Op.q
Initial state is        1|001><001|,
Then apply H(2).
The state before the addition circuit is
0.5|001><001| + 0.5|001><011| + 0.5|011><001| + 0.5|011><011|