pub struct TopN(pub usize);Expand description
Retain the n terms of largest coefficient magnitude.
With t the n-th largest magnitude, every term above t is kept, plus as many terms at exactly t as fit in n, the first in bucket order; which tied terms survive is not a semantic promise.
A sum of more than n terms keeps exactly n, and n == 0 clears; a NaN coefficient is never kept, so a sum with fewer than n other terms keeps those.
Magnitudes are compared squared, so those below about 1.6e-162 tie at zero.
Tuple Fields§
§0: usizeThe retained term count.
Trait Implementations§
Source§impl From<TopN> for BuiltinTruncation
impl From<TopN> for BuiltinTruncation
Source§impl<const W: usize> TruncationPolicy<W> for TopN
impl<const W: usize> TruncationPolicy<W> for TopN
Source§fn finalize_layer_partitioned(
&self,
local: &mut PauliSum<W>,
collectives: &dyn Collectives,
)
fn finalize_layer_partitioned( &self, local: &mut PauliSum<W>, collectives: &dyn Collectives, )
Panics above one partition, where the n-th largest of a split sum has no collective form yet.
Source§fn finalize_layer(&self, sum: &mut PauliSum<W>)
fn finalize_layer(&self, sum: &mut PauliSum<W>)
Pass over the whole sum after each layer;
PauliSum::retain is the easy way to write a filter here.Source§fn keep_term(&self, _x: &[u64; W], _z: &[u64; W], _c: Complex64) -> bool
fn keep_term(&self, _x: &[u64; W], _z: &[u64; W], _c: Complex64) -> bool
Per-term filter, run inside the merge on every output, so it must be cheap. Read more
Source§fn finalizes_layer(&self) -> bool
fn finalizes_layer(&self) -> bool
Whether
finalize_layer does anything, a hint that lets the engine skip it. Read moreSource§fn supports_partitioned(&self) -> bool
fn supports_partitioned(&self) -> bool
Whether
finalize_layer_partitioned runs above one partition; every partitioned driver checks it before the first layer. Read moreimpl Copy for TopN
impl StructuralPartialEq for TopN
Auto Trait Implementations§
impl Freeze for TopN
impl RefUnwindSafe for TopN
impl Send for TopN
impl Sync for TopN
impl Unpin for TopN
impl UnwindSafe for TopN
Blanket Implementations§
Source§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,
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