guppyalgos.algorithms.block_encoding.lcu

Perform sums / Linear Combinations of Unitaries.

Functions

build_cntrl_single_cntrl_select(data)

Build an externally controlled two-term SELECT oracle from LCU data.

build_cntrl_unary_iteration_select(data[, ...])

Build an externally controlled unary-iteration SELECT from LCU data.

build_double_cntrl_select(data)

Build a doubly-controlled SELECT oracle from LCU data.

build_single_cntrl_select(data)

Build a single-control SELECT oracle from LCU data.

build_unary_iteration_select(data[, ...])

Build a unary-iteration SELECT oracle from LCU data.

Classes

LCU()

Guppy struct representing an LCU block encoding.

LCUCntrl()

LCU block encoding with an externally controlled SELECT oracle.

LCUData(n_state_qubits, n_terms, ...)

Classical Hamiltonian data used to build LCU oracles.

class guppyalgos.algorithms.block_encoding.lcu.LCU

Guppy struct representing an LCU block encoding.

Given PREPARE, SELECT, and UNPREPARE oracles, compose applies

\[ L = \mathrm{UNPREPARE}\,\mathrm{SELECT}\,\mathrm{PREPARE}. \]

PREPARE initializes PrepRegs with the amplitudes used to select terms in the linear combination. SELECT applies the corresponding operation to TargetRegs, controlled by the state of PrepRegs. UNPREPARE then restores the initial PrepRegs basis state; it is typically the inverse of PREPARE, giving \(L = \mathrm{PREPARE}^{\dagger}\,\mathrm{SELECT}\,\mathrm{PREPARE}\).

When these oracles encode an operator \(A\) with normalization \(\lambda\), projecting PrepRegs onto its all-zero state extracts the block \(A / \lambda\).

PrepRegs and TargetRegs are generic register types. They may be individual qubit arrays or Guppy structs containing multiple registers, as long as the three oracle signatures agree with the types used by LCU.

Type Parameters:

PrepRegs: PREPARE register type shared by all three oracles. TargetRegs: Type of the target registers acted on by SELECT.

Variables:
  • prepare – PREPARE oracle acting on PrepRegs.

  • select – SELECT oracle acting on PrepRegs and TargetRegs.

  • unprepare – UNPREPARE oracle restoring the initial PrepRegs state.

compose(prep_register, state_register)

Apply the LCU block encoding \(L\).

Parameters:
  • prep_register – The PREPARE register.

  • state_register – The SELECT register.

prepare
select
unprepare
class guppyalgos.algorithms.block_encoding.lcu.LCUCntrl

LCU block encoding with an externally controlled SELECT oracle.

ControlRegs is forwarded unchanged to cntrl_select and may be a qubit, qubit array, or structured register type. The supplied SELECT oracle defines the condition under which its target operation is applied.

cntrl_select
compose(controls, prep_register, target_registers)

Apply PREPARE, controlled SELECT, and UNPREPARE.

prepare
unprepare
class guppyalgos.algorithms.block_encoding.lcu.LCUData(n_state_qubits, n_terms, n_prep_qubits, pauli_strings, coeffs, coefficient_phases, l1_norm)

Classical Hamiltonian data used to build LCU oracles.

property amplitudes: NDArray[float64]

Return normalized PREPARE amplitudes for the Hamiltonian terms.

coefficient_phases: list[float]
coeffs: list[float | complex]
classmethod from_hamiltonian(ham_op)

Build classical data for LCU oracles.

Return type:

LCUData

l1_norm: float
n_prep_qubits: int
n_state_qubits: int
n_terms: int
pauli_strings: list[String]
guppyalgos.algorithms.block_encoding.lcu.build_cntrl_single_cntrl_select(data)

Build an externally controlled two-term SELECT oracle from LCU data.

Return type:

GuppyFunctionDefinition[(qubit, array[qubit, 1], array[qubit, TypeVar(n_state_q, bound= nat)]), None]

guppyalgos.algorithms.block_encoding.lcu.build_cntrl_unary_iteration_select(data, comp_and_op=<function toffoli>, uncomp_and_op=<function toffoli>)

Build an externally controlled unary-iteration SELECT from LCU data.

Parameters:
Return type:

GuppyFunctionDefinition[(qubit, array[qubit, TypeVar(n_prep_q, bound= nat)], array[qubit, TypeVar(n_state_q, bound= nat)]), None]

Returns:

The externally controlled unary-iteration SELECT function.

guppyalgos.algorithms.block_encoding.lcu.build_double_cntrl_select(data)

Build a doubly-controlled SELECT oracle from LCU data.

Return type:

GuppyFunctionDefinition[(array[qubit, 2], array[qubit, TypeVar(n_state_q, bound= nat)]), None]

guppyalgos.algorithms.block_encoding.lcu.build_single_cntrl_select(data)

Build a single-control SELECT oracle from LCU data.

Return type:

GuppyFunctionDefinition[(array[qubit, 1], array[qubit, TypeVar(n_state_q, bound= nat)]), None]

guppyalgos.algorithms.block_encoding.lcu.build_unary_iteration_select(data, comp_and_op=<function toffoli>, uncomp_and_op=<function toffoli>)

Build a unary-iteration SELECT oracle from LCU data.

Parameters:
Return type:

GuppyFunctionDefinition[(array[qubit, TypeVar(n_prep_q, bound= nat)], array[qubit, TypeVar(n_state_q, bound= nat)]), None]

Returns:

The unary-iteration SELECT function.