A basic quantum circuit simulator in C++
|
Niko
858af2a33d
Made project usable as a library
Can now be built and used as a library simply by doing `make`. The main file was turned into an example that can be built separately |
||
|---|---|---|
| include/qsim | Made project usable as a library | |
| src | Made project usable as a library | |
| .gitattributes | Initial commit | |
| .gitignore | Made project usable as a library | |
| LICENSE | Initial commit | |
| makefile | Made project usable as a library | |
| README.md | Made project usable as a library | |
QuantumSim
This is an educational project that implements a quantum circuit simulator in C++ for quantum registers. It implements the fundamental quantum gates and not much else but is easy to extend. There are no complexity optimizations for how the state vector is modified so the practical limit is around 20-30 qubits.
Usage
src/example.cpp currently holds an example circuit for Grover's algorithm applied to a very primitive 8 bit hash function.
Typical usage is:
//create 2 qubit register collapsed to |00>
qureg r(2, 0);
//randomize bit 0
r.op_hadamard(0);
//controlled NOT on bit 1 with control bit 0
r.op_CX(1, 0);
//system will collapse to either |00> or |11> with equal probabilities
//this is known as the Bell state
r.measure();
Building
Simply run make to build the library at build/.
You can build the example with make example.
git clone https://codeberg.org/Niko64/QuantumSim.git
cd QuantumSim
make
Windows
Use the MINGW=1 flag to build for Windows:
make MINGW=1