Struct SiteView

Source
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>

Source

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());
Source

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.

Source

pub fn iter(&self) -> Iter<'_, f32>

Returns an iterator over all values in the site.

See the Site documentation for details on the storage order.

Source

pub fn shape(&self) -> [usize; N]

Returns the shape of the site.

Source

pub fn split(&self) -> [&[f32]; N]

Returns an array of slices corresponding to the sites in each population.

Trait Implementations§

Source§

impl<'a, const N: usize> AsSiteView<N> for SiteView<'a, N>

Source§

fn as_site_view(&self) -> <Self as Lifetime<'_>>::Item

Returns a SAF site view of self.
Source§

impl<'a, const N: usize> Clone for SiteView<'a, N>

Source§

fn clone(&self) -> SiteView<'a, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, const N: usize> Debug for SiteView<'a, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 'b, const N: usize> Lifetime<'a> for SiteView<'b, N>

Source§

type Item = SiteView<'a, N>

The inner item, the lifetime of which should be tied to Self.
Source§

impl<'a, const N: usize> PartialEq for SiteView<'a, N>

Source§

fn eq(&self, other: &SiteView<'a, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, const N: usize> Copy for SiteView<'a, N>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<const D: usize, T> EmSite<D> for T
where T: AsSiteView<D>,

Source§

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

Adds the posterior counts for the site into the provided posterior buffer, using the extra buf to avoid extraneous allocations. Read more
Source§

fn log_likelihood(&self, sfs: &Sfs<D>) -> LogLikelihood

Returns the log-likelihood of a single site given the SFS. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V