A high-level library for building quantum circuits. Calculations based on TensorNetwork library.
$> git clone https://github.com/katolikyan/QCSimulator.git
$> pip3 install QCSimulator/Basic QCSimulator API tutorial
The detailed documentation for the library is comming soon.
import qcsimulator as qcs
# Circuit initialization:
circuit = qcs.circuit_init(2)
# Applying some gates:
circuit.h(0)
circuit.cx(0, 1)
# Getting the execution result:
result = circuit.execute()
# Getting the state vector
sv = result.get_state_vector()
# Printing Probabilities (in big-endian):
print(result.get_all_probabilities())i— Identity gate.x— Pauli-X (NOT) gate.y— Pauli-Y gatez— Pauli-Z gateh— H (Hadamard) gatet— T gateci— control-identity. (just a connection of 2 qubits)cx— CNOT gatecz— CZ gatecy— CY gatech— CH gaterx— rotation through angle θ (radians) around the x-axisry— rotation through angle θ (radians) around the y-axisrz— rotation through angle θ (radians) around the z-axisrot— Phase rotaion through angle θ (radians) gateswap— SWAP gate swaps the state of the two qubitscrot— controlled phase shift with angle θ (radians)
cirquit.qft()cirquit.qft_rev()
Check out colab explaining the QFT functions:
QFT Tutorial
All the probabilities are returned in little-endian by default. To swap to big endian just call
qcs.set_global_endian("big-endian")I recommend to work on little end only
# Executing the circuit returns a class that contains all the data we need.
result = circuit.execute()
result.get_state_vector() # returns state vector
result.get_state_tensor() # returns state tensor
#returns all possible bitstring probabilities
result.get_all_probabilities()
# returns specific bitstring probability
result.get_bitstr_probability("10")
# if the bitstr function doesn't recive a bitstring -> random bitstring probability is returned
result.get_bitstr_probability() # returns rundom bitstring probability.You can find some examples in the examples folder or check out the colab versions:
Do not hesitate to open an issue, contribute, leave feedback, or criticize.
Thank you!