Skip to main content
Functions:
NameDescription
free[Qmod core-library function].
prepare_state[Qmod core-library function].
prepare_amplitudes[Qmod core-library function].
inplace_prepare_state[Qmod core-library function].
inplace_prepare_amplitudes[Qmod core-library function].
assign_phase_table[Qmod core-library function].

free

free(
in_: Input[QArray[QBit]]
) -> None
[Qmod core-library function] Releases the qubits allocated to a quantum variable, allowing them to be reused. Parameters:
NameTypeDescriptionDefault
in_Input[QArray[QBit]]The quantum variable that will be freed. Must be initialized before.required

prepare_state

prepare_state(
probabilities: CArray[CReal],
bound: CReal,
out: Output[QArray[QBit, Literal[‘log(probabilities.len, 2)’]]]
) -> None
[Qmod core-library function] Initializes a quantum variable in a state corresponding to a given probability distribution: out=i=0len(probabilities)1probabilities[i]i \left|\text{out}\right\rangle = \sum_{i=0}^{\text{len(probabilities)}-1} \sqrt{\text{probabilities}[i]} \left|i\right\rangle with i=0,1,2,...,{len(amplitudes)}1i = 0, 1, 2, ..., \text\{len(amplitudes)\}-1 corresponding to computational basis states. Parameters:
NameTypeDescriptionDefault
probabilitiesCArray[CReal]The probability distribution to initialize the quantum variable. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2).required
boundCRealAn error bound, expressed as the L{2}L^\{2\} norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.required
outOutput[QArray[QBit, Literal['log(probabilities.len, 2)']]]The quantum variable that will receive the initialized state. Must be uninitialized.required

prepare_amplitudes

prepare_amplitudes(
amplitudes: CArray[CReal],
bound: CReal,
out: Output[QArray[QBit, Literal[‘log(amplitudes.len, 2)’]]]
) -> None
[Qmod core-library function] Initializes a quantum variable in a state corresponding to the given amplitudes: out=i=0len(amplitudes)1amplitudes[i]i \left|\text{out}\right\rangle = \sum_{i=0}^{\text{len(amplitudes)}-1} \text{amplitudes}[i] \left|i\right\rangle with i=0,1,2,...,{len(amplitudes)}1i = 0, 1, 2, ..., \text\{len(amplitudes)\}-1 corresponding to computational basis states. Parameters:
NameTypeDescriptionDefault
amplitudesCArray[CReal]The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2).required
boundCRealAn error bound, expressed as the L{2}L^\{2\} norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.required
outOutput[QArray[QBit, Literal['log(amplitudes.len, 2)']]]The quantum variable that will receive the initialized state. Must be uninitialized.required

inplace_prepare_state

inplace_prepare_state(
probabilities: CArray[CReal],
bound: CReal,
target: QArray[QBit, Literal[‘log(probabilities.len, 2)’]]
) -> None
[Qmod core-library function] Transforms a given quantum variable in the state |0> to the state per the specified probability distribution (similar to prepare_state but preformed on an initialized variable). Parameters:
NameTypeDescriptionDefault
probabilitiesCArray[CReal]The probability distribution corresponding to the quantum variable state. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2).required
boundCRealAn error bound, expressed as the L{2}L^\{2\} norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.required
targetQArray[QBit, Literal['log(probabilities.len, 2)']]The quantum variable to act upon.required

inplace_prepare_amplitudes

inplace_prepare_amplitudes(
amplitudes: CArray[CReal],
bound: CReal,
target: QArray[QBit, Literal[‘log(amplitudes.len, 2)’]]
) -> None
[Qmod core-library function] Transforms a given quantum variable in the state |0> to the state per the specified amplitudes (similar to prepare_amplitudes but preformed on an initialized variable). Parameters:
NameTypeDescriptionDefault
amplitudesCArray[CReal]The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2).required
boundCRealAn error bound, expressed as the L{2}L^\{2\} norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number.required
targetQArray[QBit, Literal['log(amplitudes.len, 2)']]The quantum variable to act upon.required

assign_phase_table

assign_phase_table(
phases: CArray[CReal],
target: Const[QArray[QBit, Literal[‘log(phases.len, 2)’]]]
) -> None
[Qmod core-library function] Transforms a given quantum variable in the state |n> to e{iphases[n]}e^\{i phases[n]\} |n> for all n, where |n> are the computational basis states. Parameters:
NameTypeDescriptionDefault
phasesCArray[CReal]The phases to rotate the quantum variable. Must be a real vector. Must have a valid length (2 to the power of the number of qubits in the target variable).required
targetConst[QArray[QBit, Literal['log(phases.len, 2)']]]The quantum variable to act upon.required