Struct lightmotif::dense::DenseMatrix

source ·
pub struct DenseMatrix<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo = DefaultAlignment> { /* private fields */ }
Expand description

A memory-aligned dense matrix with a constant number of columns.

Implementations§

source§

impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> DenseMatrix<T, C, A>

source

pub fn new(rows: usize) -> Self

Create a new matrix with the given number of rows.

source

pub unsafe fn uninitialized(rows: usize) -> Self

Create a new uninitialized matrix with the given number of rows.

source

pub fn from_rows<I>(rows: I) -> Self

Create a new dense matrix from an iterable of rows.

§Panics

Panics if any of the rows does not have the number of elements corresponding to the dense matrix columns.

source

pub const fn columns(&self) -> usize

The number of columns of the matrix.

source

pub const fn stride(&self) -> usize

The stride of the matrix, as a number of elements.

This may be different from the number of columns to account for memory alignment constraints. Multiply by std::mem::size_of::<T>() to obtain the stride in bytes.

§Example
let d = DenseMatrix::<u8, U43, U32>::new(0);
assert_eq!(d.stride(), 64);
source

pub const fn rows(&self) -> usize

The number of rows of the matrix.

source

pub fn resize(&mut self, rows: usize)

Change the number of rows of the matrix.

source

pub fn iter(&self) -> Iter<'_, T, C, A>

Iterate over the rows of the matrix.

source

pub fn iter_mut(&mut self) -> IterMut<'_, T, C, A>

Returns an iterator that allows modifying each row.

source

pub fn fill(&mut self, value: T)

Fill the entire matrix with a constant value.

Trait Implementations§

source§

impl<C: StrictlyPositive> AsMut<DenseMatrix<f32, C>> for StripedScores<C>

source§

fn as_mut(&mut self) -> &mut DenseMatrix<f32, C>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<A: Alphabet, C: StrictlyPositive> AsRef<DenseMatrix<<A as Alphabet>::Symbol, C>> for StripedSequence<A, C>

source§

fn as_ref(&self) -> &DenseMatrix<A::Symbol, C>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: Alphabet> AsRef<DenseMatrix<f32, <A as Alphabet>::K>> for FrequencyMatrix<A>

source§

fn as_ref(&self) -> &DenseMatrix<f32, A::K>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: Alphabet> AsRef<DenseMatrix<f32, <A as Alphabet>::K>> for ScoringMatrix<A>

source§

fn as_ref(&self) -> &DenseMatrix<f32, A::K>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: Alphabet> AsRef<DenseMatrix<f32, <A as Alphabet>::K>> for WeightMatrix<A>

source§

fn as_ref(&self) -> &DenseMatrix<f32, A::K>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<C: StrictlyPositive> AsRef<DenseMatrix<f32, C>> for StripedScores<C>

source§

fn as_ref(&self) -> &DenseMatrix<f32, C>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: Alphabet> AsRef<DenseMatrix<u32, <A as Alphabet>::K>> for CountMatrix<A>

source§

fn as_ref(&self) -> &DenseMatrix<u32, A::K>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Clone + Default + Copy, C: Clone + Unsigned, A: Clone + Unsigned + PowerOfTwo> Clone for DenseMatrix<T, C, A>

source§

fn clone(&self) -> DenseMatrix<T, C, A>

Returns a copy 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<T: Default + Copy + Debug, C: Unsigned, A: Unsigned + PowerOfTwo> Debug for DenseMatrix<T, C, A>

source§

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

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

impl<A: Alphabet, C: StrictlyPositive> From<StripedSequence<A, C>> for DenseMatrix<A::Symbol, C>

source§

fn from(striped: StripedSequence<A, C>) -> Self

Converts to this type from the input type.
source§

impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> Index<MatrixCoordinates> for DenseMatrix<T, C, A>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: MatrixCoordinates) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> Index<usize> for DenseMatrix<T, C, A>

§

type Output = [T]

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> IndexMut<usize> for DenseMatrix<T, C, A>

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> IntoIterator for &'a DenseMatrix<T, C, A>

§

type Item = &'a [T]

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T, C, A>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> IntoIterator for &'a mut DenseMatrix<T, C, A>

§

type Item = &'a mut [T]

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, T, C, A>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T: Default + Copy + PartialEq, C: Unsigned, A: Unsigned + PowerOfTwo> PartialEq for DenseMatrix<T, C, A>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq + Default + Copy, C: Eq + Unsigned, A: Eq + Unsigned + PowerOfTwo> Eq for DenseMatrix<T, C, A>

Auto Trait Implementations§

§

impl<T, C, A> Freeze for DenseMatrix<T, C, A>

§

impl<T, C, A> RefUnwindSafe for DenseMatrix<T, C, A>

§

impl<T, C, A> Send for DenseMatrix<T, C, A>
where C: Send, A: Send, T: Send,

§

impl<T, C, A> Sync for DenseMatrix<T, C, A>
where C: Sync, A: Sync, T: Sync,

§

impl<T, C, A> Unpin for DenseMatrix<T, C, A>
where C: Unpin, A: Unpin, T: Unpin,

§

impl<T, C, A> UnwindSafe for DenseMatrix<T, C, A>
where C: UnwindSafe, A: UnwindSafe, T: UnwindSafe,

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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