pub struct TruncationParams {
pub rtol: Option<f64>,
pub max_rank: Option<usize>,
pub cutoff: Option<f64>,
}Expand description
Common truncation parameters.
This struct contains the core parameters used for rank truncation across various tensor decomposition and compression operations.
§Semantics
This crate uses relative tolerance (rtol) semantics:
- Singular values are truncated when
σ_i / σ_max < rtol
ITensorMPS.jl uses cutoff semantics:
- Singular values are truncated when
σ_i² < cutoff
Conversion: For normalized tensors (where σ_max = 1):
- ITensorMPS.jl’s
cutoff= tensor4all-rs’srtol² - To match ITensorMPS.jl behavior: use
rtol = sqrt(cutoff) - Example: ITensorMPS.jl
cutoff=1e-10↔ tensor4all-rsrtol=1e-5
Fields§
§rtol: Option<f64>Relative tolerance for truncation.
Singular values satisfying σ_i / σ_max < rtol are truncated,
where σ_max is the largest singular value.
If None, uses the algorithm’s default tolerance.
max_rank: Option<usize>Maximum rank (bond dimension).
If None, no rank limit is applied.
cutoff: Option<f64>Cutoff value (ITensorMPS.jl convention).
When set via with_cutoff, rtol is
automatically set to √cutoff. This field tracks the original cutoff
value for inspection; rtol is always the authoritative tolerance.
If None, cutoff was not used.
Implementations§
Source§impl TruncationParams
impl TruncationParams
Sourcepub fn with_rtol(self, rtol: f64) -> Self
pub fn with_rtol(self, rtol: f64) -> Self
Set the relative tolerance.
Clears any previously set cutoff origin.
Sourcepub fn with_max_rank(self, max_rank: usize) -> Self
pub fn with_max_rank(self, max_rank: usize) -> Self
Set the maximum rank.
Sourcepub fn with_cutoff(self, cutoff: f64) -> Self
pub fn with_cutoff(self, cutoff: f64) -> Self
Set cutoff (ITensorMPS.jl convention).
Internally converted to rtol = √cutoff. Clears any previously set
rtol origin so cutoff becomes the authoritative tolerance source.
Sourcepub fn with_maxdim(self, maxdim: usize) -> Self
pub fn with_maxdim(self, maxdim: usize) -> Self
Set maxdim (alias for with_max_rank).
This is provided for ITensorMPS.jl compatibility.
Sourcepub fn effective_rtol(&self, default: f64) -> f64
pub fn effective_rtol(&self, default: f64) -> f64
Get the effective rtol, using the provided default if not set.
Sourcepub fn effective_max_rank(&self) -> usize
pub fn effective_max_rank(&self) -> usize
Get the effective max_rank, using usize::MAX if not set.
Trait Implementations§
Source§impl Clone for TruncationParams
impl Clone for TruncationParams
Source§fn clone(&self) -> TruncationParams
fn clone(&self) -> TruncationParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TruncationParams
impl Debug for TruncationParams
Source§impl Default for TruncationParams
impl Default for TruncationParams
Source§fn default() -> TruncationParams
fn default() -> TruncationParams
Source§impl HasTruncationParams for TruncationParams
impl HasTruncationParams for TruncationParams
Source§fn truncation_params(&self) -> &TruncationParams
fn truncation_params(&self) -> &TruncationParams
Source§fn truncation_params_mut(&mut self) -> &mut TruncationParams
fn truncation_params_mut(&mut self) -> &mut TruncationParams
Source§fn with_rtol(self, rtol: f64) -> Selfwhere
Self: Sized,
fn with_rtol(self, rtol: f64) -> Selfwhere
Self: Sized,
Source§fn with_max_rank(self, max_rank: usize) -> Selfwhere
Self: Sized,
fn with_max_rank(self, max_rank: usize) -> Selfwhere
Self: Sized,
Source§fn with_cutoff(self, cutoff: f64) -> Selfwhere
Self: Sized,
fn with_cutoff(self, cutoff: f64) -> Selfwhere
Self: Sized,
Source§fn with_maxdim(self, maxdim: usize) -> Selfwhere
Self: Sized,
fn with_maxdim(self, maxdim: usize) -> Selfwhere
Self: Sized,
Source§fn set_cutoff(&mut self, cutoff: f64)
fn set_cutoff(&mut self, cutoff: f64)
Source§fn set_maxdim(&mut self, maxdim: usize)
fn set_maxdim(&mut self, maxdim: usize)
impl Copy for TruncationParams
Auto Trait Implementations§
impl Freeze for TruncationParams
impl RefUnwindSafe for TruncationParams
impl Send for TruncationParams
impl Sync for TruncationParams
impl Unpin for TruncationParams
impl UnwindSafe for TruncationParams
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>,
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
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>
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>
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