谱输入输出原语与算子级优化

oracq.algorithms.input_model.spectral

Spectral input/output primitives: Fourier-basis diagonal block encoding, sparse spectral block encoding, and spectral state preparation.

Corresponds to Lemma C.8 (SS-BE) of arXiv:2509.08807 and the input side of hierarchical spectral encoding. The diagonal matrix of Fourier basis functions F_k(J)=exp(2*pi*1j*k*J/2**w) factors over the binary digits of J into a tensor product of single-bit phase gates (paper Eq. C58); the controlled-product form yields a spectral block encoding with zero Toffolis (Eq. C60). Spectral state preparation sparsely prepares the frequency-domain amplitudes on the same lattice register, then a QFT performs the Hilbert-space amplification from the S-dimensional spectral space to the N-dimensional lattice space.

Convention: f(J) = sum_k c_k * exp(2*pi*1j*k*J/2**width) with integer frequencies k (negative frequencies are understood mod 2**width); the alpha of the spectral block encoding is sum_k abs(c_k).

oracq.algorithms.input_model.spectral.normalized_spectrum(spectrum)[源代码]

Validate spectral coefficients and normalize them into a contiguous frequency band.

The input {k: c_k} represents f(J) = sum_k c_k exp(2*pi*1j*k*J/2**width). The controlled-product decomposition requires a contiguous band; returns (k_min, coefficients) where coefficients covers every integer frequency in [k_min, k_max] (all-zero entries inside the band are allowed and counted as zero coefficients).

参数:

spectrum -- Non-empty mapping from frequencies to complex coefficients; it must form a contiguous band with not all coefficients zero.

返回:

(k_min, coefficients), i.e. the band lower limit and the tuple arranged in ascending frequency order, including zero coefficients inside the band.

返回类型:

tuple[int, tuple[complex, ...]]

oracq.algorithms.input_model.spectral.frequency_amplitudes(coefficients, k_min, width, *, normalize=True)[源代码]

Convert spectral coefficients into a 2**width-dimensional amplitude vector indexed by k mod 2**width.

参数:
  • coefficients -- Complex coefficients within the band, arranged in ascending frequency order.

  • k_min -- Lower frequency limit of the band.

  • width -- Lattice register bit width, determining the dimension 2**width of the amplitude vector.

  • normalize -- When True, divide by the Euclidean norm of the coefficients.

返回:

Frequency-domain amplitude vector of length 2**width.

返回类型:

list[complex]

oracq.algorithms.input_model.spectral.pruned_state_prep(amplitudes, *, name=None)[源代码]

Multiplexed-rotation state preparation with zero-angle pruning; unitarily equivalent to gate_state_prep but skipping zero rotations.

For sparse spectral input (a 2**width-dimensional vector with only S nonzero amplitudes), every rotation angle in an all-zero subtree is zero, so after pruning the resources grow with S instead of 2**width.

参数:
  • amplitudes -- Sparse complex amplitude vector; the length must be a power of two.

  • name -- Name of the generated operation; defaults to one derived from the amplitude content.

返回:

Preparation view implemented by pruned multiplexed rotations.

返回类型:

StatePreparation

oracq.algorithms.input_model.spectral.fourier_phase(width, k)[源代码]

Exact circuit of diag_J exp(2*pi*1j*k*J/2**width) (paper Eq. C58).

e^{2*pi*1j*k*J/2**width} factors over the binary digits of J into a tensor product with one single-bit phase gate per bit; the angles are binary-power multiples of pi and land on the exact-angle grid. Contains only the target register and is invoked as a submodule.

参数:
  • width -- Target register bit width, in the range 1..64.

  • k -- Integer frequency, understood mod 2**width.

返回:

Diagonal phase operation built from a tensor product of single-bit phase gates.

返回类型:

Operation

oracq.algorithms.input_model.spectral.fourier_phase_encoding(width, k)[源代码]

(1, 0, 0) block encoding of fourier_phase: zero-width signal interface.

参数:
  • width -- Target register bit width, in the range 1..64.

  • k -- Integer frequency, understood mod 2**width.

返回:

Block encoding with normalization constant 1 and a zero-width signal.

返回类型:

BlockEncoding

oracq.algorithms.input_model.spectral.spectral_diagonal(spectrum, width, *, variant='sequential')[源代码]

Sparse spectral block encoding: BE(diag f), with f given by a contiguous-band Fourier sum.

variant="sequential" (paper Lemma C.8 / Eq. (7)): P_L prepares amplitudes sqrt(abs(c_j)/alpha) on an s=log S bit spectral register, each bit of the spectral register controls the phase grid on the target register, the per-mode phases are restored by controlled gphase, and P_R=P_L^dagger uncomputes. Zero Toffolis. variant="naive": every basis function is handed to the generic LCU as an independent unitary operator, serving as the baseline against which the gain of the structured construction (sequential form) is measured.

参数:
  • spectrum -- Contiguous-band mapping from frequencies to complex coefficients.

  • width -- Lattice register bit width.

  • variant -- sequential or naive, taking the controlled-product decomposition or the generic LCU respectively.

返回:

BE(diag f) with alpha = sum_k abs(c_k).

返回类型:

BlockEncoding

oracq.algorithms.input_model.spectral.spectral_state_prep(spectrum, width)[源代码]

Spectral input (the input side of hierarchical spectral encoding): prepare the normalized state |f⟩.

The frequency-domain amplitudes sum_k c_k / norm(c) are sparsely prepared on basis states |k⟩ of the same width-bit lattice register, then a positive-sign QFT amplifies into the lattice space: the QFT maps basis states to uniform states with per-bit phases, and the linear combination yields sum_J f(J)*ket(J)/sqrt(N*sum(abs(c)^2)), the normalized state (Parseval).

参数:
  • spectrum -- Contiguous-band mapping from frequencies to complex coefficients; the band entry count must not exceed 2**width.

  • width -- Lattice register bit width.

返回:

Preparation view implemented by sparse frequency-domain preparation plus QFT amplification.

返回类型:

StatePreparation