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)
| 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 | /// |