[−][src]Struct mop_blocks::dr_matrix::DrMatrix
Dense Row Matrix
Dense matrix filled row-by-row, i.e., the tradicional matrix that is generally taught in class or used by dense linear algebra algorithms.
Tailored exclusively for storing purposes, doesn't provide any arithmetic method.
Types
DS: Data Storage
Methods
impl<DS> DrMatrix<DS> where
DS: WithCapacity<Input = usize>, [src]
DS: WithCapacity<Input = usize>,
pub fn with_capacity(rows: usize, cols: usize) -> Self[src]
impl<DS> DrMatrix<DS>[src]
pub fn cols(&self) -> usize[src]
pub fn rows(&self) -> usize[src]
pub fn stride(&self, idx: usize) -> usize[src]
impl<DATA, DS> DrMatrix<DS> where
DS: AsRef<[DATA]> + Storage<Item = DATA>, [src]
DS: AsRef<[DATA]> + Storage<Item = DATA>,
pub fn new<IDS>(rows: usize, cols: usize, into_data: IDS) -> Self where
IDS: Into<DS>, [src]
IDS: Into<DS>,
Creates a new DrMatrix from raw parameters.
Arguments
shape- An array containing the number of rows and columns.data- The matrix data.
Example
use mop_blocks::dr_matrix::DrMatrixArray; let _ = DrMatrixArray::new(2, 4, [1, 2, 3, 4, 5, 6, 7, 8]);
Assertions
- The length of
datamust be equal the number of rows times the number of columns.
use mop_blocks::dr_matrix::DrMatrixRef; let _ = DrMatrixRef::new(2, 4, &[1, 2, 3][..]);
pub fn as_ref(&self) -> DrMatrixRef<DATA>[src]
Converts the inner storage to a generic immutable slice storage.
Example
use mop_blocks::{doc_tests::dr_matrix_array, dr_matrix::DrMatrixRef}; assert_eq!( dr_matrix_array().as_ref(), DrMatrixRef::new( 4, 5, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][..], ) );
pub fn clear(&mut self) where
DS: Clear, [src]
DS: Clear,
Example
use mop_blocks::doc_tests::dr_matrix_vec; let mut dcca = dr_matrix_vec(); dcca.clear(); assert_eq!(dcca.cols(), 5); assert_eq!(dcca.data(), &[]); assert_eq!(dcca.rows(), 0);
pub fn data(&self) -> &[DATA][src]
pub fn extend<'b>(&mut self, other: &'b DrMatrix<DS>) where
DATA: Copy + 'b,
DS: Extend<&'b DATA>, [src]
DATA: Copy + 'b,
DS: Extend<&'b DATA>,
pub fn extend_from_clone<'b>(&mut self, other: &'b DrMatrix<DS>) where
DATA: Clone + 'b,
DS: Extend<&'b DATA>, [src]
DATA: Clone + 'b,
DS: Extend<&'b DATA>,
pub fn row(&self, idx: usize) -> &[DATA][src]
Example
use mop_blocks::doc_tests::dr_matrix_array; let ddma = dr_matrix_array(); for row_idx in 0..4 { let starting_row_value = row_idx * 5 + 1; assert_eq!( ddma.row(row_idx as usize), &[ starting_row_value, starting_row_value + 1, starting_row_value + 2, starting_row_value + 3, starting_row_value + 4 ] ); }
pub fn row_iter(&self) -> DrMatrixRowIter<DATA>[src]
pub fn value(&self, row_idx: usize, col_idx: usize) -> &DATA[src]
Example
use mop_blocks::doc_tests::dr_matrix_array; let ddma = dr_matrix_array(); for row_idx in 0..4 { let starting_row_value = row_idx * 5 + 1; for col_idx in 0..5 { assert_eq!(*ddma.value(row_idx as usize, col_idx as usize), starting_row_value + col_idx); } }
impl<DATA, DS> DrMatrix<DS> where
DS: AsMut<[DATA]> + Storage<Item = DATA>, [src]
DS: AsMut<[DATA]> + Storage<Item = DATA>,
pub fn data_mut(&mut self) -> &mut [DATA][src]
pub fn row_mut(&mut self, idx: usize) -> &mut [DATA][src]
pub fn row_iter_mut(&mut self) -> DrMatrixRowIterMut<DATA>[src]
pub fn swap(&mut self, a: [usize; 2], b: [usize; 2])[src]
pub fn swap_rows(&mut self, a: usize, b: usize)[src]
Example
use mop_blocks::doc_tests::dr_matrix_array; let mut matrix = dr_matrix_array(); let original_0_row = matrix.row(0).to_vec(); let original_3_row = matrix.row(3).to_vec(); matrix.swap_rows(0, 3); assert_eq!(matrix.row(0), &original_3_row[..]); assert_eq!(matrix.row(3), &original_0_row[..]);
pub fn two_rows_mut(
&mut self,
smaller_idx: usize,
bigger_idx: usize
) -> [&mut [DATA]; 2][src]
&mut self,
smaller_idx: usize,
bigger_idx: usize
) -> [&mut [DATA]; 2]
pub fn value_mut(&mut self, row_idx: usize, col_idx: usize) -> &mut DATA[src]
impl<DATA, DS> DrMatrix<DS> where
DS: Push<Input = DATA> + Storage<Item = DATA>, [src]
DS: Push<Input = DATA> + Storage<Item = DATA>,
pub fn fill<F>(&mut self, cb: F) where
F: FnMut(usize, usize) -> DATA, [src]
F: FnMut(usize, usize) -> DATA,
pub fn row_constructor(&mut self) -> DrMatrixRowConstructor<DS>[src]
impl<DATA, DS> DrMatrix<DS> where
DS: AsMut<[DATA]> + Storage<Item = DATA> + Truncate<Input = usize>, [src]
DS: AsMut<[DATA]> + Storage<Item = DATA> + Truncate<Input = usize>,
pub fn remove_row(&mut self, idx: usize)[src]
Example
use mop_blocks::doc_tests::dr_matrix_vec; let mut ddma = dr_matrix_vec(); ddma.remove_row(2); assert_eq!(ddma.data(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20]); assert_eq!(ddma.rows(), 3);
impl<DS> DrMatrix<DS> where
DS: Truncate<Input = usize>, [src]
DS: Truncate<Input = usize>,
pub fn truncate(&mut self, until_row_idx: usize)[src]
Example
use mop_blocks::doc_tests::dr_matrix_vec; let mut ddma = dr_matrix_vec(); ddma.truncate(2); assert_eq!(ddma.cols(), 5); assert_eq!(ddma.data(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); assert_eq!(ddma.rows(), 2);
Trait Implementations
impl<DS: Clone> Clone for DrMatrix<DS>[src]
fn clone(&self) -> DrMatrix<DS>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<DS: Copy> Copy for DrMatrix<DS>[src]
impl<DS: Debug> Debug for DrMatrix<DS>[src]
impl<DS: Default> Default for DrMatrix<DS>[src]
impl<DS: Hash> Hash for DrMatrix<DS>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<DS: PartialEq> PartialEq<DrMatrix<DS>> for DrMatrix<DS>[src]
impl<DS: PartialOrd> PartialOrd<DrMatrix<DS>> for DrMatrix<DS>[src]
fn partial_cmp(&self, other: &DrMatrix<DS>) -> Option<Ordering>[src]
fn lt(&self, other: &DrMatrix<DS>) -> bool[src]
fn le(&self, other: &DrMatrix<DS>) -> bool[src]
fn gt(&self, other: &DrMatrix<DS>) -> bool[src]
fn ge(&self, other: &DrMatrix<DS>) -> bool[src]
impl<DS> StructuralPartialEq for DrMatrix<DS>[src]
Auto Trait Implementations
impl<DS> Send for DrMatrix<DS> where
DS: Send,
DS: Send,
impl<DS> Sync for DrMatrix<DS> where
DS: Sync,
DS: Sync,
impl<DS> Unpin for DrMatrix<DS> where
DS: Unpin,
DS: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> TraitCfg for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,