You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
After that you're free to start creating your circuits.
Create circuits
For instance, to Create a Bell State, just run:
packageexamplesimportCircuitimportproviders.Outcomeimportproviders.local.LocalBackendimportproviders.local.gates.Himportproviders.local.gates.CNOTfunmain(){val circuit=Circuit(2)//circuit with 2 qubits circuit.addGate(H(arrayListOf(0)))// add an H gate on qubit 0 circuit.addGate(CNOT(arrayListOf(0,1)))// add a CNOT between qubits 1 and 0val backend=LocalBackend()val result:Outcome= backend.execute(circuit)// execute the jobprintln("---OUTPUT---")for((index,prob)in result.toDist().withIndex()){// map through your probabilities distributionval binaryRep= index.toString(radix=2).padStart(2,'0')println("$binaryRep$prob") }}
In this framework, we've chosen to follow the big-endian pattern, so the less significant qubit is the first from the left to the right ($q_{0}q_{1}q_{3}\ldots q_{n-1}$). This choice implies on the final bitstrings sequence, for example, applying$X(q_{0})$ changes$00$ to$10$ instead of$01$. For some people, it may seem as a problem, but in practice it's easy to remap to little-endian just flipping the sequence and its easier to think during the gates implementation. Also, in the near future, a method will be added to apply the remapping with ease.