January 15, 2026
•Vlad Gheorghiu, PhD
The Future of Quantum Computing II
This is another test
Welcome to second test blog post. This is some other code snippet from qpp.
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Qubit teleportation quantum circuit simulator
#include <iostream>
#include <qpp/qpp.hpp>
int main() {
using namespace qpp;
std::cout << ">> Qubit teleportation quantum circuit simulation\n\n";
// quantum circuit with 3 qubits and 2 classical bits
QCircuit qc{3, 2};
// set the qubit 0 to a random state
cmat U = randU(2);
// apply the gate U with name randU to qubit 0
qc.gate(U, 0, "randU");
// set the MES between qubits 1 and 2
qc.gate(gt.H, 1);
qc.CTRL(gt.X, 1, 2);
// perform the Bell measurement between qubits 0 and 1
qc.CTRL(gt.X, 0, 1);
qc.gate(gt.H, 0);
qc.measure({0, 1});
// apply the classical controls
qc.cCTRL(gt.X, 1, 2);
qc.cCTRL(gt.Z, 0, 2);
// initialize the quantum engine with the circuit
QEngine engine{qc};
// display the quantum circuit and its corresponding resources
std::cout << qc << "\n\n" << qc.get_resources() << "\n\n";
// execute the entire circuit
engine.execute();
// display the measurement statistics
std::cout << engine << "\n\n";
// verify that the teleportation was successful
ket psi_in = U * 0_ket;
ket psi_out = engine.get_state();
std::cout << ">> Teleported state:\n";
std::cout << disp(dirac(psi_out)) << '\n';
std::cout << ">> Norm difference: " << norm(psi_out - psi_in) << '\n';
}