pub trait IndexableMatrix {
// Required methods
fn rows(&self) -> usize;
fn cols(&self) -> usize;
unsafe fn get_unchecked(&self, row: usize, column: usize) -> f32;
unsafe fn get_unchecked_mut(
&mut self,
row: usize,
column: usize,
) -> &mut f32;
// Provided methods
fn get(&self, row: usize, column: usize) -> f32 { ... }
fn get_mut(&mut self, row: usize, column: usize) -> &mut f32 { ... }
fn set(&mut self, row: usize, column: usize, value: f32) { ... }
unsafe fn set_unchecked(&mut self, row: usize, column: usize, value: f32) { ... }
}
Expand description
Trait representing a shaped matrix whose entries can be accessed at will using their row and column position.
Required Methods§
Sourceunsafe fn get_unchecked(&self, row: usize, column: usize) -> f32
unsafe fn get_unchecked(&self, row: usize, column: usize) -> f32
Get the value of the entry at (row
, column
) without bounds checking.
Sourceunsafe fn get_unchecked_mut(&mut self, row: usize, column: usize) -> &mut f32
unsafe fn get_unchecked_mut(&mut self, row: usize, column: usize) -> &mut f32
Get a mutable reference to the value of the entry at (row
, column
)
without bounds checking.
Provided Methods§
Sourcefn get(&self, row: usize, column: usize) -> f32
fn get(&self, row: usize, column: usize) -> f32
Get the value of the entry at (row
, column
).
§Panics
Will panic if the element accessed is out of bounds.
Sourcefn get_mut(&mut self, row: usize, column: usize) -> &mut f32
fn get_mut(&mut self, row: usize, column: usize) -> &mut f32
Get a mutable reference to value of the entry at (row
, column
).
§Panics
Will panic if the element accessed is out of bounds.
Sourcefn set(&mut self, row: usize, column: usize, value: f32)
fn set(&mut self, row: usize, column: usize, value: f32)
Set the value of the entry at (row
, column
) to value
.
§Panics
Will panic if the element accessed is out of bounds.
Sourceunsafe fn set_unchecked(&mut self, row: usize, column: usize, value: f32)
unsafe fn set_unchecked(&mut self, row: usize, column: usize, value: f32)
Set the value of the entry at (row
, column
) to value
without bounds checking.