Bases

Bases#

Trainable sparsifying bases. Circuit bases (QFT, entangled QFT, TEBD, MERA, Rich, RealRich, DCT-IV) act on a whole 2^m x 2^n image; BlockedBasis tiles an inner basis over image blocks. The *_code and *_mat helpers build the underlying einsum circuits and reference DFT matrices.

Sparse-basis subpackage.

Two families:

  • bases.circuit — full circuit topologies (QFT, EntangledQFT, TEBD, MERA), comparable to FFT/DCT.

  • bases.block — BlockedBasis over arbitrary block partitions (Rich/RealRich are re-exported here for back-compat; they live in circuit).

The abstract base class and bases_allclose helper live in bases.base.

Contents

QFTBasis

QFT tensor-network basis.

EntangledQFTBasis

QFT + appended entanglement layer on min(m, n) row/col qubit pairs.

TEBDBasis

2D TEBD basis with row + column rings of controlled-phase gates.

MERABasis

2D MERA basis.

DCT4Basis

DCT-IV tensor-network basis: the real-orthogonal, ancilla-free analogue of QFTBasis.

RichBasis

QFT topology with H + learnable U(4) gates instead of H + CP.

RealRichBasis

QFT topology with H + real-orthogonal 2-qubit gates.

BlockedBasis

Wraps an inner parametric basis as a within-block transform.

AbstractSparseBasis

Structural interface shared by every basis: an image_size, a num_parameters count, and forward_transform / inverse_transform on a 2^m x 2^n image.

freeze_as_blocked

Return (basis_copy_with_identity_outer_gates, frozen_indices).

fit_to_dct

Fit a parametric basis so its forward circuit ≈ DCT_2D.

bases_allclose

Semantic equality across any of the registered basis types.

qft_code

Return (einsum_fn, initial_tensors) for 2D QFT on (2^m, 2^n) images.

entangled_qft_code

Return (einsum_fn, initial_tensors, n_entangle) for entangled 2D QFT.

tebd_code

Return (einsum_fn, initial_tensors, n_row_gates, n_col_gates).

mera_code

Return (einsum_fn, initial_tensors, n_row_gates, n_col_gates).

ft_mat

Apply 2D QFT circuit to a (2^m, 2^n) image.

ift_mat

Apply 2D inverse QFT circuit.