Using Qcl sessions inside TeXmacs

Qcl is a high level, architecture independent programming language for quantum computers, with a syntax derived from classical procedural languages like C or Pascal. This allows for the complete implementation and simulation of quantum algorithms (including classical components) in one consistent formalism. The TeXmacs interface is mainly useful for displaying quantum states in a readable way. For more information, see

    http://tph.tuwien.ac.at/~oemer/qcl.html

As suggest, users have better install the newest and binary version, now is 0.5, since it is difficult to compile from source. Moreover, if you install Qcl from binary installation, confirm that all the library directory, lib, is under the directory at which the binary qcl locates.

QCL Quantum Computation Language (32 qubits, seed 1051277574)
[0/32] 1|0⟩
qcl> 

qureg a[1];

qcl> 

Rot(pi/4,a);

[1/32] 0.92388|0⟩ - 0.38268|1⟩
qcl> 

Mix(a);

[1/32] 0.38268|0⟩ + 0.92388|1⟩
qcl> 

dump;

STATE: 1 / 32 qubits allocated, 31 / 32 qubits free
0.38268|0⟩ + 0.92388|1⟩
qcl> 

include "shor.qcl";

qcl> 

operator dft(qureg q) { const n=#q; int i; int j;for i=1 to n { for j=1 to i-1 { if q[n-1] and q[n-j] {Phase(pi/2^(i-j));}} H(q[n-1]);} flip(q); }

at "operator dft(qureg q) { c ...":
illegal scope: Global symbol dft already defined
qcl> 

dft(a);

[1/32] 0.70711|0⟩ + 0.70711|1⟩
qcl> 

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".