BlockEncoding instances (see
Constructing Block Encodings),
combine them with arithmetic operators or classmethods to block-encode sums, products, and scaled
matrices, or transform a single encoding into its inverse or its qubitized walk operator. This
page covers a selection of the available combinators and transformations — more are added over
time, so check the SDK reference for the full,
current list. Every combinator returns a new
BlockEncoding with alpha, block_size, and hermitian_be computed from its inputs.
All examples on this page import:
Sum: +
be_a + be_b block-encodes via LCU, using one extra block qubit to select between the
two branches.
be_sum.alpha prints 13.0, and be_sum.to_matrix() is the diagonal matrix .
Weighted sum: weighted_sum
For more than two terms, or complex coefficients, use BlockEncoding.weighted_sum directly
instead of chaining +: it’s more efficient.
be_ws.alpha prints 32.0, and be_ws.to_matrix() is the diagonal matrix .
Scalar multiplication: * / rmul
scalar * be (or be * scalar) block-encodes for a complex scalar . block_size
is unchanged; alpha is rescaled by .
be_scaled.alpha prints 14.0, and be_scaled.to_matrix() is the diagonal matrix
.
Product: @ / product
be_a @ be_b block-encodes the product , applying be_b’s unitary followed by
be_a’s. BlockEncoding.product([be_1, ..., be_n]) generalizes this to more than two factors
efficiently.
be_product.alpha prints 33.0, and be_product.to_matrix() is the diagonal matrix
.
Inverse
be.inverse(kappa) block-encodes using QSVT polynomial inversion, given an estimate
kappa of ‘s condition number. Pass either the QSVT polynomial degree, or eps (a target
relative error, from which the degree is derived).
to_matrix for more on this global-phase caveat.
Qubitize
be.qubitize() builds the Low–Chuang qubitization walk operator , where
reflects about the block variable’s state and is be’s own unitary.
Powers of give Chebyshev polynomials of the encoded matrix:
. These are the basis of quantum signal
processing and QSVT algorithms.
qubitize requires be.hermitian_be=True and be.block_size > 0. The walk operator is built
from two reflections, so itself must also be Hermitian. It also needs a block variable to
reflect about.
hermitian_be is computed automatically by every constructor and combinator on this page and in
Constructing Block Encodings.
If you’re confident your block encoding’s unitary is Hermitian but the computed value is
False (or vice versa), you can build a corrected copy with
dataclasses.replace(be, hermitian_be=True). Only do this when you’re sure it’s genuinely true
— qubitize’s walk operator is only correct when hermitian_be reflects reality.Verifying with to_matrix
be.to_matrix() reconstructs the encoded matrix by state-vector simulation: it prepares an
equal superposition over data, applies be.unitary, post-selects the block variable on
|0>, and rescales by alpha. It’s meant for testing and small examples, not as part of a
production algorithm.