pub struct SegmentHints { /* private fields */ }Expand description
SVEHints given by the segment boundaries of the domain
The boundaries are given on the full domain [xmin, xmax] × [ymin, ymax]
of the kernel, whether it is centrosymmetric or not. A centrosymmetric
kernel is discretized on [0, xmax] × [0, ymax] and the mirror images of
its segments (SVEHints): the boundaries in (0, xmax] ((0, ymax]),
with 0 added if it is not one of them.
The accuracy of the SVE depends on the segments: on each of them, the
kernel must be resolved by polynomials of degree ngauss - 1 in each
variable. sve_residual measures how well the
result reproduces the kernel.
§Example
use sparse_ir_sve::{AbstractKernel, CustomNumeric, SVEKernel, ExpandableKernel, SegmentHints};
use std::fmt::Debug;
/// K(x, y) = exp(-(x - y)²) on [-1, 1] × [0, 2]
#[derive(Clone)]
struct Gaussian;
impl AbstractKernel for Gaussian {
fn compute<T: CustomNumeric + Copy + Debug>(&self, x: T, y: T) -> T {
(-(x - y) * (x - y)).exp()
}
}
impl SVEKernel for Gaussian {
type SVEHintsType<T>
= SegmentHints
where
T: Copy + Debug + Send + Sync + CustomNumeric + 'static;
fn xmax(&self) -> f64 {
1.0
}
fn ymax(&self) -> f64 {
2.0
}
fn ymin(&self) -> f64 {
0.0
}
fn sve_hints<T>(&self, _epsilon: f64) -> SegmentHints
where
T: Copy + Debug + Send + Sync + CustomNumeric + 'static,
{
// Four segments on each axis, 16 Gauss points on each segment
SegmentHints::uniform(self, 4, 4, 16).unwrap()
}
}
// Not centrosymmetric: the SVE is taken over the full domain
impl ExpandableKernel for Gaussian {}Implementations§
Source§impl SegmentHints
impl SegmentHints
Sourcepub fn new<K>(
kernel: &K,
segments_x: &[f64],
segments_y: &[f64],
ngauss: usize,
) -> Result<SegmentHints, Error>where
K: SVEKernel,
pub fn new<K>(
kernel: &K,
segments_x: &[f64],
segments_y: &[f64],
ngauss: usize,
) -> Result<SegmentHints, Error>where
K: SVEKernel,
Hints with the segment boundaries segments_x and segments_y of the
full domain of kernel and ngauss Gauss points per segment
§Errors
Error::InvalidParameter if ngauss is 0, or the boundaries on an
axis are not finite and strictly increasing from the lower to the
upper bound of the domain of kernel on that axis (as
SVEKernel::xmin and SVEKernel::xmax return them)
Sourcepub fn uniform<K>(
kernel: &K,
nseg_x: usize,
nseg_y: usize,
ngauss: usize,
) -> Result<SegmentHints, Error>where
K: SVEKernel,
pub fn uniform<K>(
kernel: &K,
nseg_x: usize,
nseg_y: usize,
ngauss: usize,
) -> Result<SegmentHints, Error>where
K: SVEKernel,
Hints with nseg_x and nseg_y segments of equal length on the full
domain of kernel and ngauss Gauss points per segment
On a domain symmetric about 0, the boundaries are symmetric as well, so a centrosymmetric kernel with an even number of segments is discretized on half of them.
§Errors
Error::InvalidParameter if nseg_x, nseg_y or ngauss is 0, or
the domain of kernel is not a finite, non-empty interval on an axis
Trait Implementations§
Source§impl Clone for SegmentHints
impl Clone for SegmentHints
Source§fn clone(&self) -> SegmentHints
fn clone(&self) -> SegmentHints
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SegmentHints
impl Debug for SegmentHints
Source§impl PartialEq for SegmentHints
impl PartialEq for SegmentHints
Source§impl<T> SVEHints<T> for SegmentHints
impl<T> SVEHints<T> for SegmentHints
impl StructuralPartialEq for SegmentHints
Auto Trait Implementations§
impl Freeze for SegmentHints
impl RefUnwindSafe for SegmentHints
impl Send for SegmentHints
impl Sync for SegmentHints
impl Unpin for SegmentHints
impl UnsafeUnpin for SegmentHints
impl UnwindSafe for SegmentHints
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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, U> Imply<T> for U
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 moreimpl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSendSync for T
impl<T> MaybeSync for Twhere
T: Sync,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar 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.