Struct forust_ml::data::Matrix

source ·
pub struct Matrix<'a, T> {
    pub data: &'a [T],
    pub index: Vec<usize>,
    pub rows: usize,
    pub cols: usize,
    /* private fields */
}
Expand description

Contigious Column major matrix data container. This is used throughout the crate, to house both the user provided data as well as the binned data.

Fields§

§data: &'a [T]§index: Vec<usize>§rows: usize§cols: usize

Implementations§

source§

impl<'a, T> Matrix<'a, T>

source

pub fn new(data: &'a [T], rows: usize, cols: usize) -> Self

source

pub fn get(&self, i: usize, j: usize) -> &T

Get a single reference to an item in the matrix.

  • i - The ith row of the data to get.
  • j - the jth column of the data to get.
source

pub fn get_row_iter(&self, row: usize) -> StepBy<Skip<Iter<'_, T>>>

Get access to a row of the data, as an iterator.

source

pub fn get_col_slice( &self, col: usize, start_row: usize, end_row: usize ) -> &[T]

Get a slice of a column in the matrix.

  • col - The index of the column to select.
  • start_row - The index of the start of the slice.
  • end_row - The index of the end of the slice of the column to select.
source

pub fn get_col(&self, col: usize) -> &[T]

Get an entire column in the matrix.

  • col - The index of the column to get.
source§

impl<'a, T> Matrix<'a, T>
where T: Copy,

source

pub fn get_row(&self, row: usize) -> Vec<T>

Get a row of the data as a vector.

Trait Implementations§

source§

impl<'a, T> Display for Matrix<'a, T>
where T: FromStr + Display, <T as FromStr>::Err: 'static + Error,

source§

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

Format a Matrix.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Matrix<'a, T>

§

impl<'a, T> RefUnwindSafe for Matrix<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Matrix<'a, T>
where T: Sync,

§

impl<'a, T> Sync for Matrix<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Matrix<'a, T>

§

impl<'a, T> UnwindSafe for Matrix<'a, T>
where T: RefUnwindSafe,

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

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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