pub struct Site<const N: usize> { /* private fields */ }Expand description
A single site of SAF likelihoods for N populations.
Internally, the site is stored as a contiguous block of memory, with all values from the first
population first, then the second, and so on. Site::shape gives the number of values for
each population.
Implementations§
Source§impl<const N: usize> Site<N>
impl<const N: usize> Site<N>
Sourcepub fn as_mut_slice(&mut self) -> &mut [f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
Returns a mutable reference to the values of the SAF site as a flat slice.
See the Site documentation for details on the storage order.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, f32>
pub fn iter_mut(&mut self) -> IterMut<'_, f32>
Returns an iterator over all values in the site.
See the Site documentation for details on the storage order.
Sourcepub fn new(values: Vec<f32>, shape: [usize; N]) -> Result<Self, ShapeError<N>>
pub fn new(values: Vec<f32>, shape: [usize; N]) -> Result<Self, ShapeError<N>>
Returns a new SAF site.
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::Site;
let vec = vec![0.0, 0.1, 0.2, 1.0, 1.2];
let shape = [3, 2];
let site = Site::new(vec, 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::Site;
let vec = vec![0.0, 0.1, 0.2, 1.0, 1.2];
let wrong_shape = [6, 2];
assert!(Site::new(vec, 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 &'a Site<N>
impl<'a, const N: usize> AsSiteView<N> for &'a Site<N>
Source§fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
self.Source§impl<const N: usize> AsSiteView<N> for Site<N>
impl<const N: usize> AsSiteView<N> for Site<N>
Source§fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item
self.Source§impl<const D: usize> StreamEmSite<D> for Site<D>
impl<const D: usize> StreamEmSite<D> for Site<D>
impl<const N: usize> StructuralPartialEq for Site<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Site<N>
impl<const N: usize> RefUnwindSafe for Site<N>
impl<const N: usize> Send for Site<N>
impl<const N: usize> Sync for Site<N>
impl<const N: usize> Unpin for Site<N>
impl<const N: usize> UnwindSafe for Site<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<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
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
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
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