Skip to content

workbench_algorithms.subroutines.prepare_khot

Qubricks for the Clock State preparation.

PrepareClockState

PrepareClockState(**kwargs)

Bases: Qubrick

Prepares a clock state.

\[\text{PREP}|0\rangle^{\otimes n} = \sum_{k=0}^n \sqrt(p_k)|1\rangle^{\otimes k}|0\rangle^{\otimes n - k}\]
Example

The output state will be of the form \(\sqrt{p_0}|000\rangle + \sqrt{p_1}|100\rangle + \sqrt{p_2}|110\rangle + \sqrt{p_3}|111\rangle\).

The ket-states should be understood as a unary representation of an integer. For example, \(|1110\rangle\) is 3 in decimal \(|1000\rangle\) is 1 in decimal.

Note

The controlled version only ensures \(\text{c-PREP}|+\rangle|0\rangle^{\otimes n} = |0\rangle|0\rangle^{\otimes n}+|1\rangle \text{PREP}|0\rangle^{\otimes n}\) (a.k.a. if the input state is not zero, there is still an action of this Qubrick).

compute

compute(target, probs, ctrl: int = 0) -> None

Prepare the clock state according to given probabilities.

Parameters:

Name Type Description Default
target Qubits

Target qubits.

required
probs list

List of probability, such that the output state is of the form \(\sqrt{p_0}|000\rangle + \sqrt{p_1}|100\rangle + \sqrt{p_2}|110\rangle + \sqrt{p_3}|111\rangle\).

required
ctrl (Qubits, int)

Control register. Default to 0.

0

PrepareWStatePowerTwo

PrepareWStatePowerTwo(**kwargs)

Bases: Qubrick

Prepares a W state for power of two target size.

\[\text{PREP}|0\rangle^{\otimes 2^n} =\sum_{k=0}^{2^n} |0\rangle^{\otimes k-1}|1\rangle|0\rangle^{\otimes 2^n - k}\]
Note

The controlled version only ensures \(\text{c-PREP}|+\rangle|0\rangle^{\otimes n} = |0\rangle|0\rangle^{\otimes n} + |1\rangle\text{PREP}|0\rangle^{\otimes 2^n}\) (a.k.a. if the input state is not zero, there is still an action of this Qubrick).

compute

compute(target: Qubits, ctrl: Qubits | int = 0)

Prepares a W state for power of two target size.

Parameters:

Name Type Description Default
target Qubits

Target qubits.

required
ctrl (Qubits, int)

Control register. Default to 0.

0

PrepareWState

PrepareWState(khot_prep=None, wpower2_prep=None, **kwargs)

Bases: Qubrick

Prepares a W state.

\[\text{PREP}|0\rangle^{\otimes n} = \sum_{k=0}^n |0\rangle^{\otimes k-1}|1\rangle|0\rangle^{\otimes n - k}\]
Note

The controlled version only ensures \(\text{c-PREP}|+\rangle|0\rangle^{\otimes n} = |0\rangle|0\rangle^{\otimes n} + |1\rangle\text{PREP}|0\rangle^{\otimes n}\) (a.k.a. if the input state is not zero, there is still an action of this Qubrick).

Parameters:

Name Type Description Default
khot_prep Qubrick

Qubrick to implement a Clock state.

None
wpower2_prep Qubrick

Qubrick to prepare a W state over a power-of-two number of amplitudes.

None
**kwargs dict[str, Any]

Other arguments to pass to the init.

{}

compute

compute(target: Qubits, ctrl: Qubits | int = 0)

Prepares a W state.

Parameters:

Name Type Description Default
target Qubits

Target qubits.

required
ctrl (Qubits, int)

Control register. Default to 0.

0