pub struct SiteView<'a, const N: usize> { /* private fields */ }
Expand description
A view of a single site of SAF likelihoods for N
populations.
Implementations§
Source§impl<'a, const N: usize> SiteView<'a, N>
impl<'a, const N: usize> SiteView<'a, N>
Sourcepub fn new(values: &'a [f32], shape: [usize; N]) -> Result<Self, ShapeError<N>>
pub fn new(values: &'a [f32], shape: [usize; N]) -> Result<Self, ShapeError<N>>
Returns a new SAF site view;
The number of provided values must be equal to the sum of shapes.
See the Site
documentation for details on the storage order.
§Examples
use winsfs_core::saf::SiteView;
let slice = &[0.0, 0.1, 0.2, 1.0, 1.2];
let shape = [3, 2];
let site = SiteView::new(slice, shape).unwrap();
assert_eq!(site.split(), [&[0.0, 0.1, 0.2][..], &[1.0, 1.2][..]]);
A ShapeError
is thrown if the shape does not fit the number of values:
use winsfs_core::saf::SiteView;
let slice = &[0.0, 0.1, 0.2, 1.0, 1.2];
let wrong_shape = [6, 2];
assert!(SiteView::new(slice, wrong_shape).is_err());
Sourcepub fn as_slice(&self) -> &[f32]
pub fn as_slice(&self) -> &[f32]
Returns the values of the site as a flat slice.
See the Site
documentation for details on the storage order.
Trait Implementations§
Source§impl<'a, const N: usize> AsSiteView<N> for SiteView<'a, N>
impl<'a, const N: usize> AsSiteView<N> for SiteView<'a, N>
Source§fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
Returns a SAF site view of
self
.impl<'a, const N: usize> Copy for SiteView<'a, N>
impl<'a, const N: usize> StructuralPartialEq for SiteView<'a, N>
Auto Trait Implementations§
impl<'a, const N: usize> Freeze for SiteView<'a, N>
impl<'a, const N: usize> RefUnwindSafe for SiteView<'a, N>
impl<'a, const N: usize> Send for SiteView<'a, N>
impl<'a, const N: usize> Sync for SiteView<'a, N>
impl<'a, const N: usize> Unpin for SiteView<'a, N>
impl<'a, const N: usize> UnwindSafe for SiteView<'a, 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
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<const D: usize, T> EmSite<D> for Twhere
T: AsSiteView<D>,
impl<const D: usize, T> EmSite<D> for Twhere
T: AsSiteView<D>,
Source§fn likelihood(&self, sfs: &SfsBase<[usize; D], Norm>) -> Likelihood
fn likelihood(&self, sfs: &SfsBase<[usize; D], Norm>) -> Likelihood
Returns the likelihood of a single site given the SFS. Read more
Source§fn posterior_into(
&self,
sfs: &SfsBase<[usize; D], Norm>,
posterior: &mut SfsBase<[usize; D], Unnorm>,
buf: &mut SfsBase<[usize; D], Unnorm>,
) -> Likelihood
fn posterior_into( &self, sfs: &SfsBase<[usize; D], Norm>, posterior: &mut SfsBase<[usize; D], Unnorm>, buf: &mut SfsBase<[usize; D], Unnorm>, ) -> Likelihood
Adds the posterior counts for the site into the provided
posterior
buffer, using the
extra buf
to avoid extraneous allocations. Read moreSource§fn log_likelihood(&self, sfs: &Sfs<D>) -> LogLikelihood
fn log_likelihood(&self, sfs: &Sfs<D>) -> LogLikelihood
Returns the log-likelihood of a single site given the SFS. Read more
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