Quantum Computation Language: Difference between revisions

Content deleted Content added
m Widefox moved page Quantum computation language to Quantum Computation Language: proper name
markup
Line 29:
 
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).
<syntaxhighlight lang="cpp">
 
qureg x1[2]; // 2-qubit quantum register x1
qureg x2[2]; // 2-qubit quantum register x2
H(x1); // Hadamard operation on x1
H(x2[1]); // Hadamard operation on the first qubit of the register x2
</syntaxhighlight>
 
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.
<syntaxhighlight lang="text">
 
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>
</syntaxhighlight>
 
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:
<sourcesyntaxhighlight lang="cpp">
operator diffuse (qureg q) {
H(q); // Hadamard Transform
Not(q); // Invert q
CPhase(pi, q); // Rotate if q=1111..
!Not(q); // undo inversion
!H(q); // undo Hadamard Transform
}
}
</syntaxhighlight>
</source>
defines inverse about the mean operator used in [[Grover's algorithm]]. This allows one to define algorithms on a higher level of abstraction and extend the library of functions available for programmers.
 
== References ==
{{reflist}}
 
 
 
[[Category:Programming languages]]