Quantics and operators

QTT functions and grids, differential and transfer operators, and spin-chain Hamiltonians. Unless stated otherwise, QTT functions use 2^d grid points with site 1 holding the most significant bit.

Quantics tensor trains

Functions on a uniform grid

TensorTrainNumerics.function_to_tensor — Function
function_to_tensor(f, d; a=0.0, b=1.0) -> Array{Float64,d}

Evaluate f on the 2^d grid points x_j = a + j(b − a)/(2^d − 1), j = 0, …, 2^d − 1, which include both endpoints, and return the values as a 2 × ⋯ × 2 array indexed by the bits of j (most significant first).

source
TensorTrainNumerics.qtt_to_vector — Function
qtt_to_vector(qtt::TTVector) -> Vector

Return the 2^d entries of the binary QTT qtt as a vector, with site 1 the most significant bit. The contraction is progressive and never forms the 2 × ⋯ × 2 tensor.

source
TensorTrainNumerics.matricize — Function
matricize(qtt::TTVector, core::Int) -> Vector

Evaluate a binary (QTT) tensor train on the coarse grid spanned by its first core bits, returning 2^core values in big-endian order (bit 1 is the most significant, matching tuple_to_index). The remaining sites are fixed at physical index 1 (bit value 0). For core == nsites(qtt) this is the full grid vector, identical to qtt_to_vector.

The contraction is progressive — O(d·r²·2^core) — and never materializes the full tensor.

source
TensorTrainNumerics.qtt_polynomial — Function

Constructs a Quantized Tensor Train (QTT) representation a polynomial with given coefficients over a uniform grid in the interval [a, b] with 2^d points.

source
TensorTrainNumerics.qtt_sin — Function

Constructs a Quantized Tensor Train (QTT) representation of sin(λπx) over a uniform grid in the interval [a, b] with 2^d points.

source
TensorTrainNumerics.qtt_cos — Function

Constructs a Quantized Tensor Train (QTT) representation of cos(λπx) over a uniform grid in the interval [a, b] with 2^d points.

source
TensorTrainNumerics.qtt_exp — Function

Constructs a Quantized Tensor Train (QTT) representation of the exponential function over a uniform grid in the interval [a, b] with 2^d points.

source
TensorTrainNumerics.qtt_chebyshev — Function

Constructs a Quantized Tensor Train (QTT) representation of the Chebyshev polynomial of degree n over 2^d Chebyshev-Lobatto nodes.

Details

  • The function uses the Gauss-Chebyshev-Lobatto nodes, shifted to the interval [0, 1].
source
TensorTrainNumerics.qtt_basis_vector — Function
qtt_basis_vector(d, pos::Int, val=1.0) -> TTVector

Return the rank-1 QTT with d sites that is val at the 1-based position pos (site 1 the most significant bit) and zero elsewhere.

source
TensorTrainNumerics.qtt_trapezoidal_weights — Function
qtt_trapezoidal_weights(d; a=0.0, b=1.0) -> TTVector

Return the weights of the composite trapezoidal rule on the 2^d uniform grid points of [a, b] (the grid of function_to_qtt) as a QTT: h = (b − a)/(2^d − 1) at interior points and h/2 at both endpoints. Then dot(qtt_trapezoidal_weights(d; a, b), u) approximates ∫ₐᵇ u(x) dx. The weights have TT rank at most 3.

source
TensorTrainNumerics.gauss_chebyshev_lobatto — Function
gauss_chebyshev_lobatto(n; shifted=true) -> (x, w)

Return the n Chebyshev–Lobatto nodes x[j+1] = cos(πj/(n−1)), j = 0, …, n−1 (in decreasing order), and the Gauss–Chebyshev–Lobatto weights for the weight function 1/√(1−x²): π/(n−1), halved at both endpoints. With shifted = true the nodes are mapped from [−1, 1] to [0, 1] and the weights are halved.

source
TensorTrainNumerics.index_to_point — Function
index_to_point(t; L=1.0) -> Float64

Map a tuple of 1-based QTT indices t = (t₁, …, t_d), with t₁ the most significant bit, to the grid point L·j/(2^d − 1) in [0, L], where j = Σₖ 2^(d−k)(tₖ − 1).

source
TensorTrainNumerics.tuple_to_index — Function
tuple_to_index(t) -> Int

Map a tuple of 1-based QTT indices t = (t₁, …, t_d), with t₁ the most significant bit, to the 1-based linear index 1 + Σₖ 2^(d−k)(tₖ − 1).

source
TensorTrainNumerics.reverse_qtt_bits — Function
reverse_qtt_bits(x::TTVector) -> TTVector

Reverse the order of the sites of x. For a binary QTT this reverses the bit order of the position index, converting between most-significant-bit-first and least-significant-bit-first layouts.

source

Multidimensional QTT

TensorTrainNumerics.function_to_qttv — Function
function_to_qttv(f, n_dims, bits_per_dim; ordering=:interleaved, a=0.0, b=1.0)

Evaluate an n_dims-dimensional function f on a uniform grid with 2^bits_per_dim points per dimension and return a QTTVector. f receives an n_dims-length coordinate vector.

Grid points: a + i * (b - a) / (2^bits_per_dim - 1) for i = 0, ..., 2^bits_per_dim - 1.

source
TensorTrainNumerics.qttv_to_array — Function
qttv_to_array(q::QTTVector)

Contract the TT chain and return an n_dims-dimensional array of size 2^bits_per_dim per dimension, with values ordered on the uniform grid (index 1 = leftmost grid point).

source
TensorTrainNumerics.to_qtt — Function
to_qtt(tt, split_dims; threshold=0.0)

Convert a TTVector to QTT format by splitting each core's physical dimension via SVD.

split_dims[i] is a list of integers whose product equals tt.dims[i], specifying how to factor that core. The first entry is the coarsest (most significant) dimension, consistent with the rest of the package's QTT convention.

An optional threshold (relative to the largest singular value) controls rank truncation.

source
TensorTrainNumerics.to_ttv — Function
to_ttv(qtt, merge_numbers)

Convert a QTT (or any TTVector) back to TT format by contracting consecutive cores.

merge_numbers[i] is the number of consecutive QTT cores to merge into TT core i. sum(merge_numbers) must equal the total number of QTT cores.

Physical dimensions are merged using the same BIG-ENDIAN convention as to_qtt: the earlier (coarser) core provides the more significant bits.

source
TensorTrainNumerics.reorder — Function
reorder(q::QTTVector, new_ordering::Symbol; threshold=0.0)

Convert a QTTVector between :interleaved and :serial orderings by performing a sequence of adjacent site swaps (sorting-network style, via bubble sort).

Each adjacent swap contracts two neighboring cores, permutes their physical indices, and re-factorizes via SVD. The optional threshold (relative to the largest singular value) controls rank truncation during each SVD step.

Returns a new QTTVector with ordering == new_ordering.

source
reorder(A::QTTOperator, new_ordering::Symbol; threshold=0.0)

Convert a QTTOperator between :interleaved and :serial orderings by performing a sequence of adjacent site swaps (sorting-network style, via bubble sort).

Returns a new QTTOperator with ordering == new_ordering.

source
TensorTrainNumerics.check_compat — Function
check_compat(a::QTTVector, b::QTTVector)

Verify that two QTTVectors have compatible QTT metadata (ndims, bitsper_dim, ordering).

Throws AssertionError if incompatible.

source
check_compat(A::QTTOperator, ψ::QTTVector)

Verify that a QTTOperator and QTTVector have compatible QTT metadata.

Throws AssertionError if incompatible.

source
check_compat(::TTVector, ::TTVector)

No-op for plain TTVectors (always compatible).

source
check_compat(::TTOperator, ::TTVector)

No-op for plain TTOperator/TTVector pairs (always compatible).

source

Differential and transfer operators

TensorTrainNumerics.Δ — Function
Δ(d; bc=:DD) -> TTOperator

Second-difference (negative Laplacian) operator on a grid of 2^d points in QTT format, without the 1/h² scaling.

bc selects the boundary conditions at the left and right end of the grid: :DD (Dirichlet–Dirichlet), :DN (Dirichlet–Neumann), :ND (Neumann–Dirichlet), :NN (Neumann–Neumann), or :periodic. All except :DD require d ≥ 4.

source
TensorTrainNumerics.qtt_laplacian — Function
qtt_laplacian(n_dims, bits_per_dim; ordering=:interleaved, a=0.0, b=1.0, bc=:DN)

Build the n_dims-dimensional Laplacian operator in QTT format as the Kronecker sum of 1D second-derivative operators:

Δ_nd = Δ₁⊗I⊗…⊗I + I⊗Δ₂⊗I⊗…⊗I + … + I⊗…⊗I⊗Δₙ

Each 1D operator acts on bits_per_dim sites, a uniform grid of N = 2^bits_per_dim points. The finite-difference scaling 1/h² is included. The grid contains both endpoints of [a, b], so h = (b - a) / (N - 1), except for bc = :periodic, where it covers one period [a, b) without repeating the endpoint and h = (b - a) / N.

Arguments

  • n_dims::Int: Number of spatial dimensions (≥ 1).
  • bits_per_dim::Int: Number of QTT bits per dimension.

Keyword arguments

  • ordering::Symbol: :serial (sites grouped by dimension) or :interleaved (sites interleaved across dimensions). Default: :interleaved.
  • a::Real, b::Real: Interval endpoints. Default: [0, 1].
  • bc::Symbol: Boundary conditions of each 1D operator, as in Δ: :DD, :DN, :ND, :NN, or :periodic. Default: :DN.

Returns

A QTTOperator with N = n_dims * bits_per_dim sites.

source
TensorTrainNumerics.fourier_qtto — Function
fourier_qtto(d; sign=-1.0, K=25, normalize=true) -> TTOperator{ComplexF64}

Discrete Fourier transform on 2^d points as a QTT operator, built with the interpolative construction of Chen and Lindsey (arXiv:2404.03182):

y_k = s · Σₙ x_n exp(sign · 2πi · k n / 2^d),   s = 2^(−d/2) if `normalize`, else 1.

The operator reverses the bit order: the input must have its least significant bit of n on site 1 (as produced by function_to_qtt_uniform), and the output has the most significant bit of k on site 1 (as read by qtt_to_vector and matricize). Every interior bond has rank K + 1; larger K gives a more accurate transform.

source

Spin-chain operators

TensorTrainNumerics.pauli_pair_sum_tto — Function
pauli_pair_sum_tto(μ, ν, d)

Construct the rank-3 nearest-neighbor TT operator

H_{μ,ν} = sum_i I ⊗ ... ⊗ P_μ ⊗ P_ν ⊗ ... ⊗ I

on d spin-1/2 sites with open boundaries.

source
TensorTrainNumerics.heisenberg_xyz_tto — Function
heisenberg_xyz_tto(d; jx=1.0, jy=1.0, jz=1.0, λ=0.0, field=:x)

Construct the open-boundary Heisenberg XYZ Hamiltonian

H = jx H_{x,x} + jy H_{y,y} + jz H_{z,z} + λ H_field

as a direct low-rank TT operator on d spin-1/2 sites.

source
TensorTrainNumerics.ising_tto — Function
ising_tto(d; J=1.0, h=0.0, interaction=:z, field=:x)

Construct the open-boundary Ising Hamiltonian

H = J H_{interaction,interaction} + h H_field

on d spin-1/2 sites. Coefficients are used with their given sign.

source
TensorTrainNumerics.xxz_tto — Function
xxz_tto(d; J=1.0, Δ=1.0, h=0.0, field=:z)

Construct the open-boundary XXZ Hamiltonian

H = J(H_{x,x} + H_{y,y}) + JΔ H_{z,z} + h H_field.
source
TensorTrainNumerics.xxx_tto — Function
xxx_tto(d; J=1.0, h=0.0, field=:z)

Construct the open-boundary isotropic Heisenberg XXX Hamiltonian

H = J(H_{x,x} + H_{y,y} + H_{z,z}) + h H_field.
source
TensorTrainNumerics.xy_tto — Function
xy_tto(d; jx=1.0, jy=1.0, h=0.0, field=:z)

Construct the open-boundary XY Hamiltonian

H = jx H_{x,x} + jy H_{y,y} + h H_field.
source