MCPcopy Create free account
hub / github.com/daniel-e/rustml / set

Method set

src/matrix.rs:645–657  ·  view source on GitHub ↗

Replaces the element at row `row` (indexing starts at zero) and column `col` with the new value `newval`. Returns true on success and false on failure, i.e. if the row or column does not exist. ``` # #[macro_use] extern crate rustml; use rustml::*; # fn main() { let mut m = mat![ 1.0, 1.5; 2.0, 2.5; 5.0, 5.5 ]; assert_eq!(m.get(1, 0).unwrap(), &2.0); m.set(1, 0, 8.0); assert_eq!(m.get(1, 0).unwr

(&mut self, row: usize, col: usize, newval: T)

Source from the content-addressed store, hash-verified

643 /// # }
644 /// ```
645 pub fn set(&mut self, row: usize, col: usize, newval: T) -> bool {
646
647 match self.idx(row, col) {
648 None => false,
649 Some(p) => match self.data.get_mut(p) {
650 Some(val) => {
651 *val = newval;
652 true
653 }
654 None => false,
655 }
656 }
657 }
658
659 pub fn map<F, U>(&self, f: F) -> Matrix<U>
660 where F: FnMut(&T) -> U {

Callers 2

test_setFunction · 0.80
all_pair_distancesFunction · 0.80

Calls 2

idxMethod · 0.80
get_mutMethod · 0.80

Tested by 1

test_setFunction · 0.64