View on GitHub
Open this notebook in GitHub to run it yourself
Example
The following example will show negation of a signed quantum variable.Output:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
from classiq import *
@qfunc
def main(a: Output[QNum], b: Output[QNum]) -> None:
allocate(3, SIGNED, 0, a)
hadamard_transform(a)
b |= -a
qprog = synthesize(main)
result = sample(qprog)
result
Submitting job to simulator
Job: https://platform.classiq.io/jobs/8591ea24-674d-40a8-befd-cbf3b1470a65
| a | b | counts | probability | bitstring | |
|---|---|---|---|---|---|
| 0 | 3 | -3 | 274 | 0.133789 | 1101011 |
| 1 | -1 | 1 | 258 | 0.125977 | 0001111 |
| 2 | -3 | 3 | 258 | 0.125977 | 0011101 |
| 3 | 1 | -1 | 258 | 0.125977 | 1111001 |
| 4 | -2 | 2 | 256 | 0.125000 | 0010110 |
| 5 | -4 | 4 | 256 | 0.125000 | 0100100 |
| 6 | 0 | 0 | 248 | 0.121094 | 0000000 |
| 7 | 2 | -2 | 240 | 0.117188 | 1110010 |
Was this page helpful?