Simple, efficient Tensor Train (MPS) implementation for numerical computation.
TensorTrain— basic MPS withf64andComplex64supportSiteTensorTrain— center-canonical MPS with specified orthogonality centerVidalTensorTrain— Vidal canonical form with explicit singular valuesCompressionOptions— controls tolerance and maximum bond dimension for compression
use tensor4all_simplett::{AbstractTensorTrain, CompressionOptions, TensorTrain};
// Create a constant tensor train (all entries = 1.0) over a 2x3x4 grid
let tt = TensorTrain::<f64>::constant(&[2, 3, 4], 1.0);
// Evaluate at a specific multi-index
let value = tt.evaluate(&[0, 1, 2])?;
assert!((value - 1.0).abs() < 1e-15);
// Sum over all indices: 2 * 3 * 4 = 24
let total = tt.sum();
assert!((total - 24.0).abs() < 1e-10);
// Compress with tolerance
let options = CompressionOptions {
tolerance: 1e-10,
max_bond_dim: 20,
..Default::default()
};
let compressed = tt.compressed(&options)?;
assert!(compressed.rank() <= tt.rank());