Skip to content

Amplitude Loading

amplitude_loading

Functions:

Name Description
assign_amplitude_table

[Qmod Classiq-library function]

assign_amplitude_table

assign_amplitude_table(
    amplitudes: list[float], index: QNum, indicator: QBit
) -> None

[Qmod Classiq-library function]

Load a specified list of real amplitudes into a quantum variable using an extra indicator qubit: \( |i\rangle|0\rangle \rightarrow a(i),\ |i\rangle|1\rangle + \sqrt{1 - a(i)^2},\ |x\rangle|0\rangle \). Here, \(a(i)\) is the i-th amplitude, determined by the QNum when the index is in state \(i\). A list extracted from a given classical function \(f(x)\), with indexing according to a given QNum, can be obtained via the utility SDK function lookup_table. This function expects the indicator qubit to be initialized to \(|0\rangle\).

Parameters:

Name Type Description Default
amplitudes list[float]

Real values for the amplitudes

required
index QNum

The quantum variable used for amplitude indexing

required
indicator QBit

The quantum indicator qubit

required
Example
from classiq import *


@qfunc
def main(x: Output[QNum[5, UNSIGNED, 5]], ind: Output[QBit]) -> None:
    allocate(x)
    hadamard_transform(x)
    allocate(ind)

    assign_amplitude_table(lookup_table(lambda x: x**2, x), x, ind)