Solvers and algorithms
Linear, eigenvalue, and nonlinear solvers, time integrators, and cross interpolation.
Linear and eigenvalue solvers
TensorTrainNumerics.linear_solve — Function
linear_solve(A, b, guess; alg=MALS())
linear_solve(A, b, guess, alg)Solve A * x = b in TT format with the algorithm object alg.
TensorTrainNumerics.eigen_solve — Function
eigen_solve(A, guess; alg=MALS())
eigen_solve(A, guess, alg)Solve a TT eigenvalue problem with the algorithm object alg.
TensorTrainNumerics.LinearSolverAlgorithm — Type
LinearSolverAlgorithmSupertype of algorithm objects accepted by linear_solve and by the implicit time steppers: ALS, MALS, AMEn, DMRG, and Krylov.
TensorTrainNumerics.EigenSolverAlgorithm — Type
EigenSolverAlgorithm <: LinearSolverAlgorithmSupertype of algorithm objects that eigen_solve also accepts: ALS, MALS, AMEn, and DMRG.
TensorTrainNumerics.ALS — Type
ALS(; kwargs...)Alternating Linear Scheme (Holtz, Rohwedder & Schneider 2012). Each micro-step optimizes a single core with all other cores fixed. One sweep optimizes the cores left to right and then right to left.
Pass to linear_solve to solve A x = b, or to eigen_solve to find the smallest eigenpair by minimizing the Rayleigh quotient. Setting a field that the chosen problem does not read throws an ArgumentError.
Keyword arguments
max_sweeps=1: number of sweeps; ALS has no convergence test and runs all of them. Foreigen_solve, a vector gives the sweeps of each rank stage.max_bond=nothing(eigen_solveonly): largest bond dimension of each stage, an integer or a vector with one entry per stage;nothingkeeps the largest rank of the initial guess. When a stage'smax_bondexceeds the current largest rank, the ranks are raised withincrease_ranks; a smaller value is an error because ALS cannot lower ranks. Inlinear_solvethe ranks of the initial guess are kept.noise=0.0(eigen_solveonly): noise amplitude for the new rank directions of each stage, a number or a per-stage vector.local_solver=:auto::direct,:iterative, or:auto(direct up tolocal_thresholdunknowns, iterative above).local_threshold=nothing:nothingmeans never iterative under:auto.local_maxiter::Int=200,local_tol=1e-8: limits of the local iterative solver.return_info::Bool=false(linear_solveonly): return(x, (; residual)), whereresidualis‖A x − b‖ / ‖b‖, instead ofx.verbosity::Int=1:2logs one line per sweep.show_progress::Bool=true: display a progress bar over the sweeps.
eigen_solve returns (E, x), where E is the history of eigenvalue estimates (one entry per micro-step) and x is the eigenvector approximation.
TensorTrainNumerics.MALS — Type
MALS(; kwargs...)Modified Alternating Linear Scheme (Holtz, Rohwedder & Schneider 2012). Each micro-step optimizes two neighboring cores jointly and splits them with a truncated SVD, so the TT ranks adapt during the solve. One sweep moves left to right and then right to left.
Pass to linear_solve or eigen_solve. Setting a field that the chosen problem does not read throws an ArgumentError.
Keyword arguments
max_sweeps=1: number of sweeps; MALS has no convergence test and runs all of them. Foreigen_solve, a vector gives the sweeps of each rank stage.max_bond=nothing: largest bond dimension, an integer or (foreigen_solve) a per-stage vector;nothingmeansround(Int, √prod(dims)).trunc_tol=1e-6: relative truncation tolerance of the two-core SVDs, with the rule oftt_round!.local_solver=:auto,local_threshold=nothing(256 unknowns),local_maxiter=200,local_tol=1e-6(eigen_solveonly): local eigensolver settings; seeALS.linear_solvesolves local systems with a dense direct solve.return_info::Bool=false(linear_solveonly): return(x, (; residual)), whereresidualis‖A x − b‖ / ‖b‖, instead ofx.verbosity::Int=1:2logs one line per sweep.show_progress::Bool=true: display a progress bar over the sweeps.
eigen_solve returns (E, x, r_hist): the eigenvalue history (one entry per micro-step), the eigenvector approximation, and the largest bond dimension after each micro-step.
TensorTrainNumerics.AMEn — Type
AMEn(; kwargs...)Alternating minimal energy method (Dolgov & Savostyanov 2014). Each micro-step optimizes a single core, as ALS does, and then enlarges the basis of that core with an approximation of the residual. The approximation is a second tensor train of rank kickrank. A truncated SVD after each local solve removes directions that are not needed, so the TT ranks adapt during the solve without the two-core local problems of MALS and DMRG.
Pass to linear_solve to solve A x = b, or to eigen_solve to find the smallest eigenpair of a Hermitian A (the eigenvalue variant follows Kressner, Steinlechner & Uschmajew 2014).
Convergence of the linear solver is proven for Hermitian positive definite A. For other operators the local systems are the Galerkin projections of A itself, with no symmetrization; this works for many non-symmetric problems but is not covered by the proof.
One sweep orthogonalizes the cores from right to left and then solves from left to right. The solve stops when the largest relative residual of the local problems in a sweep is at most tol; one further sweep without enrichment then removes the directions added last.
The stopping test measures the residual within the current TT basis. The enrichment brings the part of the residual outside that basis into the test, so with kickrank = 0, or when max_bond limits the ranks, the test can be met while ‖A x − b‖ / ‖b‖ is still above tol; return_info = true reports that residual.
Keyword arguments
tol=1e-6: target relative residual of the local problems. It is the stopping threshold and the threshold of the rank truncation.max_sweeps::Int=20: largest number of sweeps.max_bond=nothing: largest bond dimension;nothingmeans no limit.kickrank::Int=4: rank of the residual approximation, which is the number of directions added to a bond per micro-step.0disables enrichment.local_solver=:auto,local_threshold=nothing(256 unknowns),local_maxiter=200: local solver settings; seeALS. The iterative solver is GMRES forlinear_solveand Lanczos foreigen_solve.local_tol=nothing: relative tolerance of the iterative local solver;nothingmeanstol / 2.return_info::Bool=false(linear_solveonly): return(x, (; residual, converged, sweeps))instead ofx, whereresidualis‖A x − b‖ / ‖b‖,convergedtells whether the stopping test was met, andsweepsis the number of sweeps run.verbosity::Int=1:0silences the warning issued whenmax_sweepsis reached without meetingtol;2logs one line per sweep.show_progress::Bool=true: display a progress bar over the sweeps.
eigen_solve returns (E, x, r_hist): the eigenvalue history (one entry per micro-step), the eigenvector approximation, and the largest bond dimension after each micro-step. Its residual is ‖A x − λ x‖ of the local problems for unit-norm x, relative to the largest ‖A x‖ met during the solve.
TensorTrainNumerics.DMRG — Type
DMRG(; kwargs...)DMRG-style alternating scheme (White 1992; Oseledets & Dolgov 2012) that optimizes nsites neighboring cores jointly at each micro-step. With nsites ≥ 2 the ranks adapt through truncated SVDs. One sweep moves left to right and then right to left; a final micro-step on the first cores follows the last sweep.
Pass to linear_solve or eigen_solve. Both read the same fields, except that eigen_solve rejects return_info = true.
Keyword arguments
nsites::Int=2: number of cores optimized per micro-step.max_sweeps=1: number of sweeps, or a vector with the sweeps of each rank stage; DMRG has no convergence test and runs all of them.max_bond=nothing: largest bond dimension, an integer or a per-stage vector;nothingmeansisqrt(prod(dims)).trunc_tol=1e-12: relative truncation tolerance of the SVDs, with the rule oftt_round!(used whennsites ≥ 2).local_solver=:iterative,local_threshold=nothing(256 unknowns),local_maxiter=200,local_tol=1e-6: local solver settings; seeALS.return_info::Bool=false: forlinear_solve, return(x, (; residual)), whereresidualis‖A x − b‖ / ‖b‖, instead ofx.verbosity::Int=1:2logs one line per sweep,3also the rank and discarded weight at every core move.show_progress::Bool=true: display a progress bar over the sweeps.
eigen_solve returns (E, x, r_hist): the eigenvalue history (one entry per micro-step), the eigenvector approximation, and the largest bond dimension after each micro-step.
TensorTrainNumerics.Krylov — Type
Krylov(; kwargs...)Solve A x = b with a KrylovKit.jl Krylov method whose vectors are TTVectors. Pass to linear_solve; not supported by eigen_solve.
With max_bond > 0, every operator application is followed by tt_compress! to bond dimension max_bond, and the result is compressed the same way. With max_bond = 0 no truncation is applied, so ranks grow with every iteration.
Keyword arguments
max_bond::Int=0: bond dimension cap applied after each operator application.krylov_solver::Symbol=:auto::gmres,:bicgstab,:cg, or:auto.:autoselects:cgwhenisposdefand (issymmetricorishermitian) are set, otherwise:bicgstabwhenmax_bond > 0and:gmreswhen it is not.krylovdim::Int=8: Krylov subspace dimension (GMRES restart length).maxiter::Int=20: maximum number of iterations (restarts for GMRES; CG useskrylovdim * maxiteriterations).rtol::Float64=1e-8,atol::Float64=1e-12: the stopping tolerance ismax(atol, rtol * norm(b))unlesstolis given.tol=nothing: absolute stopping tolerance, overridingrtolandatol.orth: orthogonalization method passed to KrylovKit's GMRES.issymmetric,ishermitian,isposdef: properties ofAused by:auto.verbosity::Int=1: KrylovKit verbosity level. At the default level KrylovKit warns when the solve stops without reaching the tolerance;0silences it.return_info::Bool=false: return(x, info)instead ofx, whereinfo = (; converged, residual, numiter)holds whether the tolerance was reached, the relative residual‖A x − b‖ / ‖b‖reported by KrylovKit (for the rank-truncated vectors whenmax_bond > 0), and the number of iterations.show_progress::Bool=true: display a progress bar.
TensorTrainNumerics.als_linsolve — Function
als_linsolve(A, b, guess; kwargs...)Compatibility wrapper for linear_solve(A, b, guess, ALS(; kwargs...)).
TensorTrainNumerics.als_eigsolve — Function
als_eigsolve(A, guess; kwargs...)Compatibility wrapper for eigen_solve(A, guess, ALS(; kwargs...)).
TensorTrainNumerics.als_gen_eigsolve — Function
als_gen_eigsolve(A, S, tt_start; sweep_schedule, max_bond, tol, local_solver, local_threshold)Find the smallest generalized eigenpair Ax = λ S x using the ALS algorithm.
Arguments
A::TTOperator{T}: the operator on the left-hand side.S::TTOperator{T}: the positive-definite metric operator on the right-hand side.tt_start::TTVector{T}: initial guess for the eigenvector.
Keyword arguments
sweep_schedule::Vector{Int}=[2]: sweep count at which each rank stage ends.max_bond::Vector{Int}: maximum bond dimension at each stage.tol::Float64=1e-10: tolerance for the local generalized eigensolver.local_solver::Symbol=:auto: solver for the local eigenproblems::direct,:iterative, or:auto(direct up tolocal_thresholdunknowns).local_threshold::Int=2500: local problem size above which:autosolves iteratively.
Returns
(E, tt_opt) where E is the eigenvalue history and tt_opt is the approximate eigenvector, or nothing if the schedule is exhausted without a final return.
TensorTrainNumerics.mals_linsolve — Function
mals_linsolve(A, b, guess; kwargs...)Compatibility wrapper for linear_solve(A, b, guess, MALS(; kwargs...)).
TensorTrainNumerics.mals_eigsolve — Function
mals_eigsolve(A, guess; kwargs...)Compatibility wrapper for eigen_solve(A, guess, MALS(; kwargs...)).
TensorTrainNumerics.dmrg_linsolve — Function
dmrg_linsolve(A, b, guess; kwargs...)Compatibility wrapper for linear_solve(A, b, guess, DMRG(; kwargs...)).
TensorTrainNumerics.dmrg_eigsolve — Function
dmrg_eigsolve(A, guess; kwargs...)Compatibility wrapper for eigen_solve(A, guess, DMRG(; kwargs...)).
TensorTrainNumerics.TTLinearSolver — Type
Alias for LinearSolverAlgorithm.
TensorTrainNumerics.ALSSolver — Type
Alias for ALS.
TensorTrainNumerics.MALSSolver — Type
Alias for MALS.
TensorTrainNumerics.AMEnSolver — Type
Alias for AMEn.
TensorTrainNumerics.DMRGSolver — Type
Alias for DMRG.
TensorTrainNumerics.KrylovSolver — Type
Alias for Krylov.
Nonlinear solver
TensorTrainNumerics.nonlinear_solve — Function
nonlinear_solve(A, u0; alg = PenaltyALS(), g = 0.0)
nonlinear_solve(A, u0, alg::PenaltyALS; g = 0.0)Ground state of the discrete Gross–Pitaevskii functional P(u) = ⟨u|A|u⟩ + (g/2)Σ_m u_m⁴ + η(⟨u|u⟩−1)² in TT/QTT format (arXiv:1802.07259). A is the (already discretized) linear operator and g the discrete interaction coefficient (g_physical · 2^L in the QTT convention). Real TT only. Returns the discretely normalized minimizer, or (u, info) when alg.return_info.
nonlinear_solve(A_builder, u0, alg::MGR; g_builder, target_sites)MGR ground-state solve from the coarse grid nsites(u0) up to target_sites QTT sites. A_builder(d)::TTOperator returns the discrete linear operator on d sites and g_builder(d)::Real the discrete interaction coefficient (e.g. g · 2^d). Returns u, or (u, info) with info = (; energy, level_sites, level_energies).
TensorTrainNumerics.NonlinearSolverAlgorithm — Type
NonlinearSolverAlgorithmSupertype of algorithm objects accepted by nonlinear_solve: PenaltyALS and MGR.
TensorTrainNumerics.PenaltyALS — Type
PenaltyALS(; local_solver=:newton, local_steps=4, penalty_schedule=[1e2,1e4,1e6,1e8],
tol=1e-6, max_sweeps=100, return_info=false, verbosity=1, show_progress=true)Fixed-grid nonlinear penalty solver (arXiv:1802.07259): alternating site-local minimization of P(u) = ⟨u|A|u⟩ + (g/2)Σu⁴ + η(⟨u|u⟩−1)² under continuation in the penalty weight η, which takes the values of penalty_schedule in turn. local_solver is :newton (damped Newton, the paper's default), :cg (Polak–Ribière+), or :sd; local_steps line-search steps are used per site for :cg/:sd. Each stage sweeps until the relative penalty change is below tol or max_sweeps sweeps are done. verbosity ≥ 2 logs one line per sweep; show_progress displays a progress bar.
TensorTrainNumerics.MGR — Type
MGR(; inner = PenaltyALS(), max_bond = 8, return_info = false, verbosity = 1, show_progress = true)Multigrid-renormalization driver (arXiv:1802.07259): solve on the coarse grid of u0, then repeatedly prolong to one more QTT site (qtto_linear_prolongation), truncate to max_bond (keeping numerically zero singular values as bond-growth room), normalize, and re-solve with inner, up to the target grid. verbosity ≥ 2 logs one line per grid level; show_progress displays a progress bar over the levels.
TensorTrainNumerics.gpe_energy — Function
gpe_energy(A, u; g = 0.0)Discrete Gross–Pitaevskii energy readout E = ⟨u|A|u⟩/s + g·Σ_m u_m⁴/s², s = ⟨u|u⟩ (full g, matching the paper's Table-1 convention; the minimized functional carries g/2).
Time evolution
TensorTrainNumerics.time_evolve — Function
time_evolve(A, u₀, steps, alg::TimeEvolutionAlgorithm) -> TTVector
time_evolve(A, u₀, steps, alg; guess=u₀)Evolve u₀ under the generator A with the time stepper alg: an Euler, ImplicitEuler, CrankNicolson, RK4, or TDVP object.
steps holds the step sizes, not time points. Euler, ImplicitEuler, CrankNicolson, and RK4 integrate du/dt = A u; for TDVP the generator is -iA unless imaginary_time = true.
For ImplicitEuler and CrankNicolson, guess is the initial guess of the first linear solve; later steps start from the previous solution.
If alg was built with return_info = true, the result is (u, info).
TensorTrainNumerics.TimeEvolutionAlgorithm — Type
TimeEvolutionAlgorithmSupertype of algorithm objects accepted by time_evolve: Euler, ImplicitEuler, CrankNicolson, RK4, and TDVP.
TensorTrainNumerics.Euler — Type
Euler(; normalize=false, return_info=false, show_progress=true)Explicit Euler time stepping; see euler_method for the scheme and the meaning of the keyword arguments.
TensorTrainNumerics.ImplicitEuler — Type
ImplicitEuler(; linear_solver=MALS(), max_bond=0, normalize=false, return_info=false, show_progress=true)Implicit Euler time stepping. Every step solves a TT linear system with linear_solver, a LinearSolverAlgorithm; see implicit_euler_method for the scheme and the other keyword arguments.
TensorTrainNumerics.CrankNicolson — Type
CrankNicolson(; linear_solver=MALS(), max_bond=0, normalize=false, return_info=false, show_progress=true)Crank–Nicolson time stepping. Every step solves a TT linear system with linear_solver, a LinearSolverAlgorithm; see crank_nicolson_method for the scheme and the other keyword arguments.
TensorTrainNumerics.RK4 — Type
RK4(; max_bond, normalize=false, return_info=false, show_progress=true)Classical fourth-order Runge–Kutta time stepping with every stage compressed to bond dimension max_bond; see rk4_method.
TensorTrainNumerics.TDVP — Type
TDVP(; nsites=1, kwargs...)Time-dependent variational principle with one-site (nsites = 1, fixed ranks) or two-site (nsites = 2, adaptive ranks) updates; see tdvp and tdvp2 for the schemes.
Keyword arguments
nsites::Int=1:1or2.max_bond::Int=typemax(Int),trunc_tol::Real=0.0: rank truncation of the two-site updates. Setting either withnsites = 1throws anArgumentError.normalize,substeps,carry_env,imaginary_time,return_info,verbosity,show_progress: as intdvp.- Remaining keyword arguments are passed to
KrylovKit.exponentiate.
TensorTrainNumerics.euler_method — Function
euler_method(A, u₀, steps; normalize=false, return_info=false, show_progress=true)Explicit Euler time stepping u ← u + h·A·u in TT format.
With return_info = true returns (u, (; error)), where error is the relative defect of the last step, ‖u_{n+1} − (I + hA)·u_n‖ / ‖u_{n+1}‖, which measures the error introduced by orthogonalization (and normalization when normalize = true) in that step.
TensorTrainNumerics.implicit_euler_method — Function
implicit_euler_method(A, u₀, guess, steps; alg=MALS(), normalize=false, max_bond=0, return_info=false, show_progress=true, kwargs...)Implicit Euler time stepping: solve (I − h·A)·u_{n+1} = u_n at every step with the TT linear solver alg (a LinearSolverAlgorithm). Remaining keyword arguments replace fields of alg for these solves (for example max_sweeps = 2). max_bond > 0 compresses every step to that bond dimension and, for Krylov, also caps its operator applications. With return_info = true returns (u, (; error)), where error is the relative residual of the last step's linear system.
TensorTrainNumerics.crank_nicolson_method — Function
crank_nicolson_method(A, u₀, guess, steps; alg=MALS(), normalize=false, max_bond=0, return_info=false, show_progress=true, kwargs...)Crank–Nicolson time stepping: solve (I − h/2·A)·u_{n+1} = (I + h/2·A)·u_n at every step with the TT linear solver alg (a LinearSolverAlgorithm). Remaining keyword arguments replace fields of alg for these solves (for example max_sweeps = 2). max_bond > 0 compresses every step to that bond dimension and, for Krylov, also caps its operator applications. With return_info = true returns (u, (; error)), where error is the relative residual of the last step's linear system.
TensorTrainNumerics.rk4_method — Function
rk4_method(A, u₀, steps; max_bond, normalize=false, return_info=false, show_progress=true)Classical fourth-order Runge–Kutta time stepping in TT format, compressing every stage and the iterate to bond dimension max_bond.
With return_info = true returns (u, (; error)), where error is the relative defect of the last step, ‖u_{n+1} − (u_n + Δu_n)‖ / ‖u_{n+1}‖, which measures the error introduced by rank truncation (and normalization when normalize = true) in that step.
TensorTrainNumerics.tdvp — Function
tdvp(H, u₀, steps; kwargs...) -> TTVector
tdvp(H, u₀, steps; return_info=true, kwargs...) -> (TTVector, info)Evolve u₀ with the one-site time-dependent variational principle (Haegeman et al. 2016), using a symmetric (second-order) projector splitting. The TT ranks stay equal to those of orthogonalize(u₀); use tdvp2 for adaptive ranks.
The generator is applied as follows:
- real time (default):
du/dt = -i H u, so each step computes approximatelyexp(-i h H) u. RealHandu₀are promoted to complex. imaginary_time = true:du/dt = H u, so each step computes approximatelyexp(h H) uand the element type is kept. To relax toward the ground state of a HamiltonianK, passH = -Ktogether withnormalize = true.
steps is a vector of step sizes h, not of time points. Every entry of steps evolves the state by h, split into substeps substeps of h / substeps each; more substeps reduce the splitting error of a step.
Keyword arguments
normalize::Bool=false: rescale the state to unit norm after every step.substeps::Int=1: number of substeps each step is split into (see above).carry_env::Bool=true: reuse environments between the substeps of one step.return_info::Bool=false: return(ψ, (; error)), whereerroris the relative residual of the last step's finite-difference derivative,‖(u_{n+1} − u_n)/h − G u_{n+1}‖ / ‖u_{n+1}‖, andGisHor-iH.verbosity::Int=1:3logs the local energy at every site update.show_progress::Bool=true: display a progress bar over the time steps.- Remaining keyword arguments are passed to
KrylovKit.exponentiate(for exampleishermitian=false,tol, orkrylovdim).
TensorTrainNumerics.tdvp2 — Function
tdvp2(H, u₀, steps; kwargs...) -> TTVector
tdvp2(H, u₀, steps; return_info=true, kwargs...) -> (TTVector, info)Evolve u₀ with the two-site time-dependent variational principle (Haegeman et al. 2016). Each two-site update is split by a truncated SVD, so the TT ranks adapt, up to max_bond.
The generator is applied as follows:
- real time (default):
du/dt = -i H u, so each step computes approximatelyexp(-i h H) u. RealHandu₀are promoted to complex. imaginary_time = true:du/dt = H u, so each step computes approximatelyexp(h H) uand the element type is kept. To relax toward the ground state of a HamiltonianK, passH = -Ktogether withnormalize = true.
steps is a vector of step sizes h, not of time points. Every entry of steps evolves the state by h, split into substeps substeps of h / substeps each; more substeps reduce the splitting error of a step.
Keyword arguments
max_bond::Int=typemax(Int): maximum bond dimension after each two-site update.trunc_tol::Real=0.0: relative truncation tolerance of the two-site SVDs, with the rule oftt_round!.normalize::Bool=false: rescale the state to unit norm after every step.substeps::Int=1: number of substeps each step is split into (see above).carry_env::Bool=true: reuse environments between the substeps of one step.return_info::Bool=false: return(ψ, (; error)), whereerroris the relative residual of the last step's finite-difference derivative,‖(u_{n+1} − u_n)/h − G u_{n+1}‖ / ‖u_{n+1}‖, andGisHor-iH.verbosity::Int=1:3logs the local energy at every two-site update.show_progress::Bool=true: display a progress bar over the time steps.- Remaining keyword arguments are passed to
KrylovKit.exponentiate.
Cross interpolation
TensorTrainNumerics.tt_cross — Function
tt_cross(f, domain, alg::CrossAlgorithm=MaxVol(); ranks=2, val_size=1000) -> TTVector
tt_cross(f, domain; alg=MaxVol(), kwargs...)
tt_cross(f, dims; alg=MaxVol(), kwargs...)Build a TTVector approximation of the function f on a tensor-product grid by cross interpolation, evaluating f only at selected points.
domain is a vector of grid-point vectors, one per dimension. With integer dims (a tuple or vector), the grid is 1.0:dims[k] in every dimension.
f is called with a batch of points: an n × d matrix whose rows are points, and it must return n values (any array that vec flattens to length n). The element type of the result is inferred from one evaluation of f.
alg is one of MaxVol, DMRGCross, or Greedy.
Keyword arguments
ranks::Union{Int,Vector{Int}}=2: initial interior ranks (MaxVolandDMRGCrossonly;Greedyalways starts at rank 1).val_size::Int=1000: number of random grid points used to measure the relative error‖f − f̃‖ / ‖f‖that is compared withalg.tol.
If the tolerance is not reached within alg.max_sweeps iterations, the last approximation is returned, and a warning is logged when alg.verbosity ≥ 1.
Example
f(X) = vec(exp.(-sum(X .^ 2, dims = 2)))
domain = [collect(range(-1.0, 1.0, length = 8)) for _ in 1:4]
tt = tt_cross(f, domain, MaxVol(verbosity = 0, tol = 1e-8); ranks = 2)TensorTrainNumerics.tt_integrate — Function
tt_integrate(f, lower::Vector, upper::Vector; alg=MaxVol(), nquad=20, kwargs...)
tt_integrate(f, d::Int; lower=0.0, upper=1.0, kwargs...)Approximate the integral of f over the box [lower[1], upper[1]] × ⋯ with a tensor-product Gauss–Legendre rule of nquad nodes per dimension. f is approximated on the quadrature grid by tt_cross with algorithm alg (remaining keyword arguments are passed to tt_cross), and the TT is then contracted with the quadrature weights. f uses the batched calling convention of tt_cross. The second form integrates over the cube [lower, upper]^d.
The values of f must have the element type of lower and upper; complex integrands with real bounds raise a MethodError.
TensorTrainNumerics.MaxVol — Type
MaxVol(; max_sweeps=50, tol=1e-10, max_bond=500, kickrank=5, verbosity=1, show_progress=true, pivot=MaxVolPivot())TT-cross interpolation by alternating maximum-volume pivot selection (Oseledets & Tyrtyshnikov 2010). Starting from the ranks given to tt_cross, each iteration sweeps over the cores, selects interpolation pivots with the maxvol algorithm, and then increases every rank by kickrank (capped at max_bond) until the validation error drops below tol.
Keyword arguments
max_sweeps::Int=50: maximum number of iterations; each iteration is one left-to-right pass.tol::Real=1e-10: target relative error on the validation set (seett_cross).max_bond::Int=500: maximum TT rank.verbosity::Int=1:1warns whentolis not reached,2logs the validation error after every iteration.show_progress::Bool=true: display a progress bar over the iterations.kickrank::Union{Nothing,Int}=5: rank increase after each iteration;nothingkeeps the ranks fixed.pivot::MaxVolPivot: maxvol settings (tol=1.05,maxiter=100).
TensorTrainNumerics.DMRGCross — Type
DMRGCross(; max_sweeps=50, tol=1e-10, max_bond=500, kickrank=5, verbosity=1, show_progress=true, pivot=MaxVolPivot())Two-site (DMRG-style) TT-cross interpolation (Savostyanov & Oseledets 2011). Each micro-step samples a two-core superblock, splits it with an SVD truncated with the rule of tt_round! at trunc_tol = tol and rank max_bond, and selects new pivots with the maxvol algorithm, so the ranks adapt to the function.
Keyword arguments
max_sweeps::Int=50: maximum number of iterations; each iteration is a left-to-right and a right-to-left pass.tol::Real=1e-10: target relative error on the validation set (seett_cross).max_bond::Int=500: maximum TT rank.verbosity::Int=1:1warns whentolis not reached,2logs the validation error after every pass.show_progress::Bool=true: display a progress bar over the iterations.kickrank::Union{Nothing,Int}=5: extra rank directions added at every split to explore beyond the truncated rank;nothingdisables this.pivot::MaxVolPivot: maxvol settings (tol=1.05,maxiter=100).
TensorTrainNumerics.Greedy — Type
Greedy(; max_sweeps=50, tol=1e-10, max_bond=500, verbosity=1, show_progress=true, nsamples=1000, pivot=RandomPivot())Greedy rank-adaptive TT-cross interpolation (Savostyanov 2014). All ranks start at 1. At every bond, each sweep searches a random sample of candidate entries for the largest interpolation error and adds that entry as a new pivot, raising the rank by one, while the error relative to the largest sampled |f| exceeds tol and the rank is below max_bond.
Keyword arguments
max_sweeps::Int=50: maximum number of iterations; each iteration is one sweep over the bonds.tol::Real=1e-10: target relative error on the validation set (seett_cross).max_bond::Int=500: maximum TT rank.verbosity::Int=1:1warns whentolis not reached,2logs the validation error after every iteration.show_progress::Bool=true: display a progress bar over the iterations.nsamples::Int=1000: number of random candidate entries examined per bond.pivot::RandomPivot: sampling settings; setRandomPivot(seed=…)for reproducible pivots. The smaller ofnsamplesandpivot.nsamplesis used.