diff --git a/src/matrix/mat.rs b/src/matrix/mat.rs index 400facc..6378172 100644 --- a/src/matrix/mat.rs +++ b/src/matrix/mat.rs @@ -8,7 +8,7 @@ pub struct Matrix { data: Vec, } -impl Matrix { +impl Matrix { /// Build from columns (each inner Vec is one column) pub fn from_cols(cols_data: Vec>) -> Self { let cols = cols_data.len(); @@ -38,13 +38,22 @@ impl Matrix { Matrix { rows, cols, data } } - pub fn rows(&self) -> usize { - self.rows - } pub fn data(&self) -> &[T] { &self.data } + pub fn data_mut(&mut self) -> &mut [T] { + &mut self.data + } + + pub fn as_vec(&self) -> Vec { + self.data.clone() + } + + pub fn rows(&self) -> usize { + self.rows + } + pub fn cols(&self) -> usize { self.cols }