pub(super) struct Shells<const N: usize> {
pub(super) sum: Jet<N>,
error: Jet<N>,
cancelling: bool,
pub(super) bound: Rounding<N>,
count: i32,
floor: i32,
last: [f64; 2],
net: [f64; 2],
pub(super) settled: bool,
}Expand description
One Ewald part summed over cube shells of integer points (Shells::sum), which
Shells::extend continues. Below every automatic split (below_automatic), where
the parts cancel, a part that stops at SHELL_TOLERANCE of its own sum leaves that
much in the complete sum, so both parts continue to SHELL_TOLERANCE of the
complete sum, and each part keeps the rounding errors of its additions
(add_exactly): next to a lattice point at a zero Bloch vector millions of
real-space terms add in phase far below an ulp of it.
Calibrated: continuing the parts this way at every split costs the other splits 5%
and gains them 1e-14 of max(|S|, 1).
Fields§
§sum: Jet<N>The sum, or with error its leading part.
error: Jet<N>The rounding errors of the additions to sum since the last shell, where they
are kept (cancelling); each shell adds them to sum.
cancelling: boolWhether the part may cancel against the other, below every automatic split: it
then keeps the rounding errors of its additions and counts bound.
bound: Rounding<N>The rounding bounds of the value and each derivative that its terms predict, in
units of epsilon: TERM_ULPS ulps of the moduli of each term, plus the bounds
the terms add beyond their relative accuracy.
count: i32Shells summed so far.
floor: i32Shells to sum before the convergence test may stop the sum (peak_shells).
last: [f64; 2]The largest moduli of the value and derivatives that the last two shells added.
net: [f64; 2]The same of what each of the last two shells added in all, where their terms cancel.
settled: boolWhether the sum stopped at its shell limit on net instead of last (see
Shells::sum).
Implementations§
Source§impl<const N: usize> Shells<N>
impl<const N: usize> Shells<N>
Sourcepub(super) fn sum(
dim: usize,
[maximum, floor]: [i32; 2],
term: &mut impl FnMut([i64; 3], &mut Rounding<N>) -> Result<Jet<N>>,
settle: bool,
cancelling: bool,
) -> Result<Self>
pub(super) fn sum( dim: usize, [maximum, floor]: [i32; 2], term: &mut impl FnMut([i64; 3], &mut Rounding<N>) -> Result<Jet<N>>, settle: bool, cancelling: bool, ) -> Result<Self>
Sum term over cube shells until two consecutive shells add less than
SHELL_TOLERANCE times max(|sum|, 1), but not before floor shells
(peak_shells), failing after maximum shells; where cancelling, keep the
rounding errors of the additions and count their bounds (Self::bound). With
settle a sum at the limit whose last two shells add less than that in all
(Self::settled) is returned for the caller to verify: at |k eta| far below the
automatic split the real-space terms reach beyond the limit while their Bloch
phases cancel them within each shell.
Sourcepub(super) fn tail(&self) -> f64
pub(super) fn tail(&self) -> f64
The moduli of the last two shells, or for a sum that settled what they added in all: a bound on what the shells beyond would add.
Sourcefn add_compensated(&mut self, value: &Jet<N>)
fn add_compensated(&mut self, value: &Jet<N>)
Adds value to a cancelling sum with the rounding error of that addition, and
counts TERM_ULPS of its moduli in Self::bound. Kept out of line, like
small_split_kambe, for the sums at other splits.
Sourcepub(super) fn extend(
&mut self,
dim: usize,
maximum: i32,
term: &mut impl FnMut([i64; 3], &mut Rounding<N>) -> Result<Jet<N>>,
scale: Option<f64>,
) -> Result<bool>
pub(super) fn extend( &mut self, dim: usize, maximum: i32, term: &mut impl FnMut([i64; 3], &mut Rounding<N>) -> Result<Jet<N>>, scale: Option<f64>, ) -> Result<bool>
Add shells until the last two add less than SHELL_TOLERANCE times scale, or
without one each less than that of max(|sum|, 1) as it was then, from
Self::floor shells on, and whether they did within maximum shells.
Trait Implementations§
impl<const N: usize> Copy for Shells<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Shells<N>
impl<const N: usize> RefUnwindSafe for Shells<N>
impl<const N: usize> Send for Shells<N>
impl<const N: usize> Sync for Shells<N>
impl<const N: usize> Unpin for Shells<N>
impl<const N: usize> UnwindSafe for Shells<N>
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
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>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.