Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
The multiplication operation, denoted '∗', is a series of additions (“long multiplication”).The multiplier has different implementations, depending on the type of adder in use.Note that integer and fixed-point numbers are represented in a two-complement method during function evaluation.The binary number is extended in the case of a register size mismatch.For example, the positive signed number (110)2=6 is expressed as (00110)2 when working with a five-qubit register.
Similarly, the negative signed number (110)2=−2 is expressed as (11110)2.
The number of digits needed to store the answer is 4+2-1 =
The multiplication is done in the ‘regular’ manner where each number is extended to five bits and only five digits are kept in the intermediary
results.
Example 2: Float and Quantum Variable Multiplication
This code example generates a quantum program that multiplies two arguments.
Here, the left argument is a fixed-point number (11.1)2 (3.5),
and the right argument is a quantum variable of size
@qfuncdef main(a: Output[QNum], res: Output[QNum]) -> None: allocate(2, a) hadamard_transform(a) res |= 3.5 * aqmod = create_model(main)