Simulating Quantum Algorithms including Shor's Algorithm and Deutsch-Jozsa's Algorithms.
Use C++ Eigen Library
- First, set up the dependency (C++ Eigen).
- Put all files in the same directory, then include
Quantum.hpp
. - You might refer to the
test.cpp
for sample code.
Our interface is within namespace Quantum
. You might want to use
using namespace Quantum;
It represents a quantum register.
- To instantiate a Qreg object, use
Qreg obj(initialValue, bitNumber);
- To measure a Qreg from s'th bit to t'th bit, use
obj.measure(s,t);
- To slice a Qreg, use
auto stateList = obj.slice(s,t);
It represents a sum of product form, and stored within a list of pairs, [(u1,v1),(u2,v2),...(un,vn)].
- Use
a*b
to perform Kronecker product.
It represent unitary matrix acting on small number of bits.
- Use
gate(qubit)
to take act on a quantum register and return its output. - Use
gate1(gate2)
to perform composite of gates. - Use
gate1*gate2
to perform the Kronecker product of gates.
- Use
DeutschJozsa(f, n)
to perform Deutsch-Jozsa algorithm, wheref
is a function handler either constant or balanced andn
is the total bit number
- Use
ShorFactor(N)
to return a trivial divisor. - Use
ShorPeriod(a,N)
to return the order of a mod N while a, N are co-prime.
@misc{qsim,
title={Quantum Simulation},
author={Yu Hsuan Huang},
year={2018},
howpublished = {https://github.com/asd00012334/Quantum-Simulation}
}