pub struct CompressionOptions {
pub method: CompressionMethod,
pub tolerance: f64,
pub max_bond_dim: usize,
pub normalize_error: bool,
}Expand description
Configuration for tensor train compression.
Controls the accuracy-vs-cost trade-off when reducing bond dimensions
via TensorTrain::compress or TensorTrain::compressed.
§Fields
| Field | Default | Meaning |
|---|---|---|
method | LU | Decomposition algorithm (see CompressionMethod) |
tolerance | 1e-12 | Relative truncation threshold per bond |
max_bond_dim | usize::MAX | Hard upper bound on any bond dimension |
normalize_error | true | Whether error is measured relative to the norm |
§Choosing tolerance
1e-12(default): near machine precision, almost lossless.1e-8to1e-6: good for most scientific applications.1e-4to1e-2: aggressive compression, useful for exploratory work.
Tighter tolerances produce larger bond dimensions and slower evaluation.
§Examples
use tensor4all_simplett::{CompressionOptions, CompressionMethod};
// Default: LU with tolerance 1e-12
let opts = CompressionOptions::default();
assert_eq!(opts.method, CompressionMethod::LU);
assert!((opts.tolerance - 1e-12).abs() < 1e-15);
assert_eq!(opts.max_bond_dim, usize::MAX);
// Custom: SVD with moderate tolerance and bond dim cap
let opts = CompressionOptions {
method: CompressionMethod::SVD,
tolerance: 1e-6,
max_bond_dim: 50,
..Default::default()
};
assert_eq!(opts.method, CompressionMethod::SVD);Fields§
§method: CompressionMethodDecomposition method (LU, CI, or SVD).
tolerance: f64Relative truncation tolerance per bond.
Singular values (or pivots) smaller than tolerance * sigma_max are
discarded. Smaller values preserve more accuracy but produce larger
bond dimensions.
max_bond_dim: usizeHard upper bound on any bond dimension.
Even if the tolerance would allow a larger rank, the bond dimension
is capped at this value. Set to usize::MAX (default) for no limit.
normalize_error: boolWhether to normalize the truncation error by the tensor norm.
Trait Implementations§
Source§impl Clone for CompressionOptions
impl Clone for CompressionOptions
Source§fn clone(&self) -> CompressionOptions
fn clone(&self) -> CompressionOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompressionOptions
impl Debug for CompressionOptions
Auto Trait Implementations§
impl Freeze for CompressionOptions
impl RefUnwindSafe for CompressionOptions
impl Send for CompressionOptions
impl Sync for CompressionOptions
impl Unpin for CompressionOptions
impl UnsafeUnpin for CompressionOptions
impl UnwindSafe for CompressionOptions
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more