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

Method row

src/matrix.rs:589–595  ·  view source on GitHub ↗

Returns the row at index `n` (starting at zero) in O(1). ``` # #[macro_use] extern crate rustml; use rustml::*; # fn main() { let m = mat![ 1.0, 1.5; 2.0, 2.5; 5.0, 5.5 ]; assert_eq!(m.row(0).unwrap(), [1.0, 1.5]); assert_eq!(m.row(1).unwrap(), [2.0, 2.5]); assert_eq!(m.row(2).unwrap(), [5.0, 5.5]); assert!(m.row(3).is_none()) # } ```

(&self, n: usize)

Source from the content-addressed store, hash-verified

587 /// # }
588 /// ```
589 pub fn row(&self, n: usize) -> Option<&[T]> {
590
591 match self.idx(n, 0) {
592 None => None,
593 Some(p) => Some(self.data.split_at(p).1.split_at(self.ncols).0)
594 }
595 }
596
597 /// Returns the row at index `n` in O(1) that is mutable.
598 ///

Callers 1

nextMethod · 0.80

Calls 1

idxMethod · 0.80

Tested by

no test coverage detected