pub struct SvdTruncationPolicy {
pub threshold: f64,
pub scale: ThresholdScale,
pub measure: SingularValueMeasure,
pub rule: TruncationRule,
}Expand description
Explicit truncation policy for SVD-based decompositions.
Use this type when you need to describe how singular values are measured,
scaled, and turned into a retained rank. SvdOptions
carries this policy plus an independent max_rank cap.
§Examples
use tensor4all_core::{
SingularValueMeasure, SvdTruncationPolicy, ThresholdScale, TruncationRule,
};
let policy = SvdTruncationPolicy::new(1e-12);
assert_eq!(policy.scale, ThresholdScale::Relative);
assert_eq!(policy.measure, SingularValueMeasure::Value);
assert_eq!(policy.rule, TruncationRule::PerValue);
let tail_policy = SvdTruncationPolicy::new(1e-8)
.with_absolute()
.with_squared_values()
.with_discarded_tail_sum();
assert_eq!(tail_policy.scale, ThresholdScale::Absolute);
assert_eq!(tail_policy.measure, SingularValueMeasure::SquaredValue);
assert_eq!(tail_policy.rule, TruncationRule::DiscardedTailSum);Fields§
§threshold: f64Threshold value used by the selected scale/rule combination.
scale: ThresholdScaleWhether the threshold is interpreted relatively or absolutely.
measure: SingularValueMeasureWhether the policy measures singular values or squared singular values.
rule: TruncationRuleWhether truncation is per value or based on a discarded tail sum.
Implementations§
Source§impl SvdTruncationPolicy
impl SvdTruncationPolicy
Sourcepub const fn new(threshold: f64) -> Self
pub const fn new(threshold: f64) -> Self
Create a policy with the default semantics: relative threshold, singular values, and per-value truncation.
Sourcepub const fn with_relative(self) -> Self
pub const fn with_relative(self) -> Self
Use relative threshold scaling.
Sourcepub const fn with_absolute(self) -> Self
pub const fn with_absolute(self) -> Self
Use absolute threshold scaling.
Sourcepub const fn with_values(self) -> Self
pub const fn with_values(self) -> Self
Measure singular values directly.
Sourcepub const fn with_squared_values(self) -> Self
pub const fn with_squared_values(self) -> Self
Measure squared singular values.
Sourcepub const fn with_per_value(self) -> Self
pub const fn with_per_value(self) -> Self
Apply the threshold independently to each singular value.
Sourcepub const fn with_discarded_tail_sum(self) -> Self
pub const fn with_discarded_tail_sum(self) -> Self
Apply the threshold to the cumulative discarded tail.
Trait Implementations§
Source§impl Clone for SvdTruncationPolicy
impl Clone for SvdTruncationPolicy
Source§fn clone(&self) -> SvdTruncationPolicy
fn clone(&self) -> SvdTruncationPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SvdTruncationPolicy
impl Debug for SvdTruncationPolicy
Source§impl PartialEq for SvdTruncationPolicy
impl PartialEq for SvdTruncationPolicy
impl Copy for SvdTruncationPolicy
impl StructuralPartialEq for SvdTruncationPolicy
Auto Trait Implementations§
impl Freeze for SvdTruncationPolicy
impl RefUnwindSafe for SvdTruncationPolicy
impl Send for SvdTruncationPolicy
impl Sync for SvdTruncationPolicy
impl Unpin for SvdTruncationPolicy
impl UnsafeUnpin for SvdTruncationPolicy
impl UnwindSafe for SvdTruncationPolicy
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