From ad0d85a2c43ce6d8bb69c7d1c7a99ba75628dc8b Mon Sep 17 00:00:00 2001 From: Andrii Dmytrenko Date: Mon, 16 Oct 2017 16:48:55 +0100 Subject: [PATCH] Remove square_matrix module --- src/lib.rs | 5 ++++- src/mark_matrix.rs | 2 +- src/square_matrix.rs | 3 --- src/weight_matrix.rs | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 src/square_matrix.rs diff --git a/src/lib.rs b/src/lib.rs index 0f0c298..50e4dac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,10 @@ use coverage::Coverage; use mark_matrix::MarkMatrix; pub use weight_matrix::WeightMatrix; -pub mod square_matrix; +use ndarray::Array2; + +pub type SquareMatrix = Array2; + mod coverage; mod mark_matrix; pub mod weight_matrix; diff --git a/src/mark_matrix.rs b/src/mark_matrix.rs index d4513ed..b02e77c 100644 --- a/src/mark_matrix.rs +++ b/src/mark_matrix.rs @@ -1,4 +1,4 @@ -use square_matrix::SquareMatrix; +use SquareMatrix; #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u8)] diff --git a/src/square_matrix.rs b/src/square_matrix.rs deleted file mode 100644 index 2821a35..0000000 --- a/src/square_matrix.rs +++ /dev/null @@ -1,3 +0,0 @@ -use ndarray::Array2; - -pub type SquareMatrix = Array2; diff --git a/src/weight_matrix.rs b/src/weight_matrix.rs index a9c4d92..c9a1248 100644 --- a/src/weight_matrix.rs +++ b/src/weight_matrix.rs @@ -1,5 +1,6 @@ -use super::{WeightNum, Weights}; -use super::square_matrix::SquareMatrix; +use WeightNum; +use Weights; +use SquareMatrix; #[derive(Debug)] pub struct WeightMatrix { @@ -41,8 +42,7 @@ impl Weights for WeightMatrix { impl WeightMatrix { pub fn from_row_vec(n: usize, data: Vec) -> WeightMatrix { - assert!(n > 0); - WeightMatrix { c: unsafe { SquareMatrix::from_shape_vec_unchecked((n, n), data) } } + WeightMatrix { c: SquareMatrix::from_shape_vec((n, n), data).unwrap() } } pub fn from_fn T>(n: usize, f: F) -> WeightMatrix { @@ -51,8 +51,8 @@ impl WeightMatrix { } /// Return the minimum element of row `row`. - fn min_of_row(&mut self, row: usize) -> T { - let row_slice = self.c.row_mut(row); + fn min_of_row(&self, row: usize) -> T { + let row_slice = self.c.row(row); let mut min = row_slice[0]; for &val in row_slice.iter().skip(1) { if val < min {