Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
The following comparators are supported:
Equal (denoted as ’==’)
NotEqual (denoted as ’!=’)
GreaterThan (denoted as ’>’)
GreaterEqual (denoted as ’>=’)
LessThan (denoted as ’<’)
LessEqual (denoted as ’<=’)
Note that integer and fixed-point numbers are represented in a 2-complement method during function evaluation.The binary number is extended in the case of a register size miss-match.For example, the positive signed number (110)2=6 is expressed as (00110)2 when operating with a 5-qubit register.
Similarly, the negative signed number (110)2=−2 is expressed as (11110)2.Examples:(5 <= 3) = 0(5 == 5) = 1((011)2 == (11)2) = 1(signed (101)2 < unsigned (101)2) = 1
This example generates a quantum program that performs ‘equal’ between two variables.The left arg is a signed variable with 5 qubits and the right arg is an unsigned varialbe with 3 qubits.
from classiq import *@qfuncdef main(a: Output[QNum], b: Output[QNum], res: Output[QNum]) -> None: allocate(5, True, 0, a) allocate(3, False, 0, b) res |= a == bqmod = create_model(main)
This example generates a quantum program that performs ‘less equal’ between a quantum register and an integer.The left arg is an unsigned quantum variable with 3 qubits, and the right arg is an integer equal to
@qfuncdef main(a: Output[QNum], res: Output[QNum]) -> None: allocate(3, a) hadamard_transform(a) res |= a <= 2qmod = create_model(main)