态制备组合

oracq.algorithms.common.state_preparation

Composition utilities for initial state extension, applying encodings and physical subspace selection.

oracq.algorithms.common.state_preparation.extend_initial(prep, extra_width)[源代码]

Extend the target space of a state preparation prep by extra_width high bits.

The original preparation acts on the low bits of the extended target and the new high bits stay zero; the zero-input promise is preserved.

参数:
  • prep -- The original StatePreparation.

  • extra_width -- Number of high qubits to append.

返回:

Preparation whose target width is prep.width + extra_width.

返回类型:

StatePreparation

oracq.algorithms.common.state_preparation.select_subspace(state, output_width, high_value=0, *, label='selection')[源代码]

Select the physical subspace out of the target space of a state oracle.

The low output_width bits serve as the output, while the remaining high bits are folded into signal and required to equal high_value; the success condition is that the whole signal register returns to zero.

参数:
  • state -- The input StateOracle, with width not less than output_width.

  • output_width -- The selected physical output width.

  • high_value -- The value that the discarded high bits must equal, zero by default.

  • label -- Label used for the generated module name and algorithm attribute.

返回:

State oracle with output width output_width and a signal holding the original signal bits plus the appended high bits.

返回类型:

StateOracle

抛出:

ValidationError -- output_width exceeds state.width, or high_value is out of range.

oracq.algorithms.common.state_preparation.apply_be_to_state(a, prep)[源代码]

Apply a block encoding a to an already prepared initial state, yielding a state oracle.

The signal bits of a occupy the low bits of signal and the workspace of prep is folded into its high bits; the success condition is that the whole signal register returns to zero.

参数:
  • a -- The BlockEncoding of the operator to apply.

  • prep -- A StatePreparation with the same target width as a.

返回:

State oracle with unchanged target width and an attached signal register.

返回类型:

StateOracle

抛出:

ValidationError -- The two target widths differ.