[−][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
Implementations
impl<DS> DrMatrix<DS>[src]
pub fn constructor(&mut self) -> DrMatrixRowsConstructor<DS>[src]
pub fn clear(&mut self) where
DS: Clear, [src]
DS: Clear,
Clears the internal data and sets the number of rows to zero.
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 cols(&self) -> usize[src]
The number of columns.
Example
use mop_blocks::doc_tests::dr_matrix_array; assert_eq!(dr_matrix_array().cols(), 5);
pub fn rows(&self) -> usize[src]
The number of rows.
Example
use mop_blocks::doc_tests::dr_matrix_array; assert_eq!(dr_matrix_array().rows(), 4);
pub fn truncate(&mut self, until_row_idx: usize) where
DS: Truncate<Input = usize>, [src]
DS: Truncate<Input = usize>,
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);
impl<DS> DrMatrix<DS> where
DS: WithCapacity<Input = usize>, [src]
DS: WithCapacity<Input = usize>,
pub fn with_capacity(rows: usize, cols: usize) -> Self[src]
Creates a new instance with an initial rows * cols capacity.
The number of columns will be equal cols while the number of rows will be
equal to zero.
Example
use mop_blocks::dr_matrix::DrMatrix; let matrix = DrMatrix::<Vec<i32>>::with_capacity(2, 3); assert_eq!(matrix.cols(), 3); assert_eq!(matrix.rows(), 0);
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) -> Result<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]);
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!( Ok(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 data(&self) -> &[DATA][src]
Immutable slice of the internal data.
Example
use mop_blocks::doc_tests::dr_matrix_vec; assert_eq!( dr_matrix_vec().data(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] );
pub fn row(&self, row_idx: usize) -> Option<&[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), Some(&[ 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 to_vec(&self) -> DrMatrixVec<DATA> where
DATA: Clone, [src]
DATA: Clone,
pub fn value(&self, row_idx: usize, col_idx: usize) -> Option<&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 { let value = (starting_row_value + col_idx) as i32; assert_eq!(ddma.value(row_idx, col_idx).copied(), Some(value)); } }
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 remove_row(&mut self, idx: usize) where
DS: Truncate<Input = usize>, [src]
DS: Truncate<Input = usize>,
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);
pub fn row_mut(&mut self, row_idx: usize) -> Option<&mut [DATA]>[src]
pub fn row_iter_mut(&mut self) -> DrMatrixRowIterMut<DATA>[src]
pub fn swap(&mut self, a: [usize; 2], b: [usize; 2]) -> bool where
DS: AsRef<[DATA]>, [src]
DS: AsRef<[DATA]>,
pub fn swap_rows(&mut self, a: usize, b: usize) -> bool[src]
Example
use mop_blocks::doc_tests::dr_matrix_array; let mut matrix = dr_matrix_array(); let original_0_row = matrix.row(0).unwrap().to_vec(); let original_3_row = matrix.row(3).unwrap().to_vec(); matrix.swap_rows(0, 3); assert_eq!(matrix.row(0), Some(&original_3_row[..])); assert_eq!(matrix.row(3), Some(&original_0_row[..]));
pub fn two_rows_mut(&mut self, a: usize, b: usize) -> Option<[&mut [DATA]; 2]>[src]
pub fn value_mut(&mut self, row_idx: usize, col_idx: usize) -> Option<&mut DATA>[src]
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>,