Quantum Computation Language (QCL) is one of the first implemented
quantum programming
Quantum programming is the process of assembling sequences of instructions, called quantum circuits, that are capable of running on a quantum computer. Quantum programming languages help express quantum algorithms using high-level constructs. Th ...
languages
Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of met ...
. The most important feature of QCL is the support for user-defined operators and functions. Its
syntax resembles the syntax of the
C programming language
''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
and its classical
data type
In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
s are similar to primitive data types in C. One can combine classical code and quantum code in the same program.
The language was created to explore programming concepts for quantum computers.
The QCL library provides standard quantum operators used in quantum algorithms such as:
QCL web page
/ref>
* Controlled-not with many target qubits,
* Hadamard operation on many qubits,
* Phase and controlled phase.
* Quantum algorithms for addition, multiplication and exponentiation with binary constants (all modulus n)
* The quantum fourier transform
Syntax
*Data types
**Quantum - qureg, quvoid, quconst, quscratch, qucond
**Classical - int, real, complex, boolean, string, vector, matrix, tensor
*Function types
**qufunct - Pseudo-classic operators. Can only change the permutation of basis states.
**operator - General unitary operators. Can change the amplitude.
**procedure - Can call measure, print, and dump inside this function. This function is non-invertible.
*Built-in functions
**Quantum
***qufunct - Fanout, Swap, Perm2, Perm4, Perm8, Not, CNot
***operator - Matrix2x2, Matrix4x4, Matrix8x8, Rot, Mix, H, CPhase, SqrtNot, X, Y, Z, S, T
***procedure - measure, dump, reset
**Classical
***Arithmetic - sin, cos, tan, log, sqrt, ...
***Complex - Re, Im, conj
Examples
The basic built-in quantum data type in QCL is the qureg (quantum register). It can be interpreted as an array of qubits (quantum bits).
qureg x1 // 2-qubit quantum register x1
qureg x2 // 2-qubit quantum register x2
H(x1); // Hadamard operation on x1
H(x2 ; // Hadamard operation on the first qubit of the register x2
Since the qcl interpreter uses qlib simulation library, it is possible to observe the internal state of the quantum machine during execution of the quantum program.
qcl> dump
: STATE: 4 / 32 qubits allocated, 28 / 32 qubits free
0.35355 , 0> + 0.35355 , 1> + 0.35355 , 2> + 0.35355 , 3>
+ 0.35355 , 8> + 0.35355 , 9> + 0.35355 , 10> + 0.35355 , 11>
Note that the dump operation is different from measurement, since it does not influence the state of the quantum machine and can be realized only using a simulator.
Like in modern programming languages, it is possible to define new operations which can be used to manipulate quantum data. For example:
operator diffuse (qureg q)
defines inverse about the mean operator used in Grover's algorithm
In quantum computing, Grover's algorithm, also known as the quantum search algorithm, refers to a quantum algorithm for unstructured search that finds with high probability the unique input to a black box function that produces a particular output ...
(it is sometimes called ''Grover's diffusion operator''). This allows one to define algorithms on a higher level of abstraction and extend the library of functions available for programmers.
References
{{reflist
Programming languages
Quantum programming