Skip to content

Commit

Permalink
Merge pull request #20 from maticnetwork/AV-120-row-wise-partitioning
Browse files Browse the repository at this point in the history
Switch partitioning to row-wise.
  • Loading branch information
aterentic-ethernal committed Dec 21, 2022
2 parents d94ec5c + 4bc256c commit 5650c84
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kate/recovery/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ impl Dimensions {
let extended_rows = self.extended_rows();

(start..end).map(move |cell| Position {
row: cell % extended_rows,
col: (cell / extended_rows) as u16,
row: cell / extended_rows,
col: (cell % extended_rows) as u16,
})
}
}
Expand All @@ -209,6 +209,8 @@ mod tests {

use crate::matrix::{Dimensions, Position};

use super::Partition;

#[test]
fn zero_dimensions() {
assert!(Dimensions::new(0, 0).is_none());
Expand Down Expand Up @@ -243,4 +245,14 @@ mod tests {
.collect::<Vec<_>>();
assert_eq!(cells, expected);
}

#[test_case(1, 2, &[(0, 0), (0, 1)] ; "First partition")]
#[test_case(2, 2, &[(1, 0), (1, 1)] ; "Second partition")]
fn iter_extended_partition_positions(number: u8, fraction: u8, expected: &[(u32, u16)]) {
Dimensions::new(1, 2)
.unwrap()
.iter_extended_partition_positions(&Partition { number, fraction })
.zip(expected.iter().map(|&(row, col)| Position { row, col }))
.for_each(|(p1, p2)| assert!(p1 == p2));
}
}

0 comments on commit 5650c84

Please sign in to comment.