pub enum Triangle {
Lower,
Upper,
Full,
}Expand description
Records which triangle of a symmetric kernel matrix to write.
§Examples
use faer::Mat;
use gprx::kernel::{RbfKernel, Triangle};
assert_ne!(Triangle::Lower, Triangle::Upper);
let rbf = RbfKernel::new(1.0)?;
let dist = Mat::from_fn(2, 2, |i, j| if i == j { 0.0 } else { 1.0 });
// `Lower` leaves the strict upper triangle as it was.
let mut lower = Mat::<f64>::zeros(2, 2);
rbf.apply(dist.as_ref(), lower.as_mut(), Triangle::Lower)?;
assert!(lower[(0, 1)].abs() < 1e-12 && lower[(1, 0)] > 0.0);
// `Upper` writes the other side, `Full` both.
let mut upper = Mat::<f64>::zeros(2, 2);
rbf.apply(dist.as_ref(), upper.as_mut(), Triangle::Upper)?;
assert!(upper[(1, 0)].abs() < 1e-12 && upper[(0, 1)] > 0.0);
let mut full = Mat::<f64>::zeros(2, 2);
rbf.apply(dist.as_ref(), full.as_mut(), Triangle::Full)?;
assert!((full[(0, 1)] - full[(1, 0)]).abs() < 1e-12);Variants§
Lower
Marks entries with row >= col.
This is the default for Cholesky.
Upper
Marks entries with row <= col.
Full
Marks every entry.
Upper and lower must match when dist is symmetric.
Trait Implementations§
impl Copy for Triangle
impl Eq for Triangle
impl StructuralPartialEq for Triangle
Auto Trait Implementations§
impl Freeze for Triangle
impl RefUnwindSafe for Triangle
impl Send for Triangle
impl Sync for Triangle
impl Unpin for Triangle
impl UnsafeUnpin for Triangle
impl UnwindSafe for Triangle
Blanket Implementations§
impl<T> Boilerplate for T
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
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,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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> ⓘ
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