Quantum computer simulator library
I'm building this to learn C++ and Quantum Information Theory simultaneously, so don't be surprised if they're both wrong. Instead, feel free to create a new issue or a new pull request so you can rub in exactly what I did wrong in a concise, well commented manner.
Thanks x
- C++14
Download or clone qSim-cpp into some/directory/qSim
// A confused qubit
// confused.cpp
#include "qSim.h"
using namespace qsim;
int main() {
// initialize a |0> qubit
math::Ket qubit = states::z0;
std::cout << "qubit:\n";
qubit.print();
// apply a Hadamard gate to qubit
qubit *= gates::H;
std::cout << "confused qubit:\n";
qubit.print();
}
From this directory, compile confused.cpp
using your compiler of choice:
$ g++ -std=c++14 -I some/directory/qSim/include confused.cpp -o confused
Then run your compiled file:
$ ./confused
Should output something like:
qubit:
| 1 |
| 0 |
confused qubit:
| 0.707 |
| 0.707 |
For more examples and usage, please refer to the examples.
- 0.0.1
- Work in progress
Hayk Khachatryan – chat w/ me – [email protected]
Distributed under the MIT license. See LICENSE
for more information.
- Fork it (https://github.com/haykkh/qSim-cpp/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request