pub fn floating_zone<T, F>(
tt: &TensorTrain<T>,
f: &F,
local_dims: &[usize],
init_p: Option<&MultiIndex>,
early_stop_tol: f64,
) -> (MultiIndex, f64)Expand description
Local search for the multi-index with the largest interpolation error.
Starting from init_p, sweeps through each site position, evaluating
all local indices while fixing the others, and picks the index with
the maximum error |f(idx) - tt(idx)|. Repeats until the error
stops increasing or early_stop_tol is exceeded.
§Examples
use tensor4all_tensorci::floating_zone;
use tensor4all_simplett::TensorTrain;
// Constant TT (value = 0.0) on a 4×4 grid
let tt = TensorTrain::<f64>::constant(&[4, 4], 0.0);
// f(i,j) = i * j, so TT error = |i*j|
let f = |idx: &Vec<usize>| (idx[0] * idx[1]) as f64;
let local_dims = vec![4, 4];
// Search from (2, 2) without early stopping
let (pivot, error) = floating_zone(&tt, &f, &local_dims, Some(&vec![2, 2]), f64::MAX);
// Should find maximum error at (3, 3): |3*3 - 0| = 9
assert_eq!(pivot, vec![3, 3]);
assert!((error - 9.0).abs() < 1e-10);§Arguments
tt– the tensor train approximationf– the exact functionlocal_dims– number of values each index can takeinit_p– starting point (Nonedefaults to the all-zeros index)early_stop_tol– stop early once the error exceeds this value (usef64::MAXto search exhaustively)
§Returns
(pivot, max_error) – the best multi-index found and its error.