Skip to content

workbench_algorithms.experimental.subroutines.state_preparation.arbitrary_state_prep

Class and functions for the multiplexor-style arbitary state preparation circuits((PREP without garbage)).

ArbitraryStatePrep

ArbitraryStatePrep(
    amplitude_prep: AmplitudePreparation,
    phase_prep: PhasePreparation | None = None,
    **kwargs,
)

Bases: Qubrick

Qubrick for preparing states with arbitrary coefficients.

The strategy used is straightforward: first we prepare the amplitudes for the state such that the probabilities for each basis state are correct, then we prepare the phases to get the full state.

Parameters:

Name Type Description Default
amplitude_prep AmplitudePreparation

Qubrick to prepare the amplitudes for the state.

required
phase_prep PhasePreparation | None

Qubrick to prepare the phases given the amplitudes have already been prepared.

None
kwargs dict[str, Any]

Other key word arguments to pass to the constructor.

{}

compute

compute(
    psi: Qubits,
    data: StatePrepDataInterface,
    ctrl: Qubits | int = 0,
)

Compute the arbitrary state prep.

Note

This Qubrick makes no assumptions about how the amplitudes and phases are prepared and so all data processing is delegated to those Qubricks.

Parameters:

Name Type Description Default
psi Qubits

Register to prepare the state on.

required
data StatePrepDataInterface

Dataclass encoding the specification of the state.

required
ctrl Qubits | int

Register to control the state preparation.

0

is_positive_real

is_positive_real(coeffs: Iterable[float | complex]) -> bool

Checks whether the coeffs are all positive real.