pub struct SvdOptions {
pub max_rank: Option<usize>,
pub policy: Option<SvdTruncationPolicy>,
/* private fields */
}Expand description
Options for SVD decomposition with truncation control.
§Examples
use tensor4all_core::svd::{SvdOptions, svd_with};
use tensor4all_core::{DynIndex, SvdTruncationPolicy, TensorDynLen};
let i = DynIndex::new_dyn(3);
let j = DynIndex::new_dyn(3);
let data: Vec<f64> = (0..9).map(|x| x as f64).collect();
let tensor = TensorDynLen::from_dense(vec![i.clone(), j.clone()], data).unwrap();
let opts = SvdOptions::new().with_policy(SvdTruncationPolicy::new(1e-10));
let (u, s, v) = svd_with::<f64>(&tensor, &[i.clone()], &opts).unwrap();
// U has left index + bond, S is diagonal bond x bond, V has right index + bond
assert_eq!(u.dims()[0], 3);
assert_eq!(s.dims().len(), 2);Fields§
§max_rank: Option<usize>Maximum retained rank after policy-based truncation.
policy: Option<SvdTruncationPolicy>Per-call SVD truncation policy.
If None, the global default policy is used.
Implementations§
Source§impl SvdOptions
impl SvdOptions
Sourcepub fn with_max_rank(self, max_rank: usize) -> Self
pub fn with_max_rank(self, max_rank: usize) -> Self
Set the maximum retained rank.
Sourcepub fn with_policy(self, policy: SvdTruncationPolicy) -> Self
pub fn with_policy(self, policy: SvdTruncationPolicy) -> Self
Set the SVD truncation policy override.
Trait Implementations§
Source§impl Clone for SvdOptions
impl Clone for SvdOptions
Source§fn clone(&self) -> SvdOptions
fn clone(&self) -> SvdOptions
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 SvdOptions
impl Debug for SvdOptions
Source§impl Default for SvdOptions
impl Default for SvdOptions
impl Copy for SvdOptions
Auto Trait Implementations§
impl Freeze for SvdOptions
impl RefUnwindSafe for SvdOptions
impl Send for SvdOptions
impl Sync for SvdOptions
impl Unpin for SvdOptions
impl UnsafeUnpin for SvdOptions
impl UnwindSafe for SvdOptions
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