Skip to content

Commit

Permalink
Merge pull request #3 from lita-xyz/dorebell-emptymatrix
Browse files Browse the repository at this point in the history
allow RowMajorMatrix to be empty
  • Loading branch information
tess-eract authored Aug 13, 2024
2 parents 623741c + fe17855 commit 5fe73cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions matrix/src/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pub struct RowMajorMatrix<T> {
impl<T> RowMajorMatrix<T> {
#[must_use]
pub fn new(values: Vec<T>, width: usize) -> Self {
debug_assert!(width >= 1);
debug_assert_eq!(values.len() % width, 0);
debug_assert!(width == 0 || values.len() % width == 0);
Self { values, width }
}

Expand Down Expand Up @@ -185,7 +184,11 @@ impl<T> Matrix<T> for RowMajorMatrix<T> {
}

fn height(&self) -> usize {
self.values.len() / self.width
if self.width == 0 {
0
} else {
self.values.len() / self.width
}
}
}

Expand Down

0 comments on commit 5fe73cc

Please sign in to comment.