Skip to content

Commit 4bc256c

Browse files
Switch partitioning to row-wise.
1 parent d94ec5c commit 4bc256c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

kate/recovery/src/matrix.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ impl Dimensions {
196196
let extended_rows = self.extended_rows();
197197

198198
(start..end).map(move |cell| Position {
199-
row: cell % extended_rows,
200-
col: (cell / extended_rows) as u16,
199+
row: cell / extended_rows,
200+
col: (cell % extended_rows) as u16,
201201
})
202202
}
203203
}
@@ -209,6 +209,8 @@ mod tests {
209209

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

212+
use super::Partition;
213+
212214
#[test]
213215
fn zero_dimensions() {
214216
assert!(Dimensions::new(0, 0).is_none());
@@ -243,4 +245,14 @@ mod tests {
243245
.collect::<Vec<_>>();
244246
assert_eq!(cells, expected);
245247
}
248+
249+
#[test_case(1, 2, &[(0, 0), (0, 1)] ; "First partition")]
250+
#[test_case(2, 2, &[(1, 0), (1, 1)] ; "Second partition")]
251+
fn iter_extended_partition_positions(number: u8, fraction: u8, expected: &[(u32, u16)]) {
252+
Dimensions::new(1, 2)
253+
.unwrap()
254+
.iter_extended_partition_positions(&Partition { number, fraction })
255+
.zip(expected.iter().map(|&(row, col)| Position { row, col }))
256+
.for_each(|(p1, p2)| assert!(p1 == p2));
257+
}
246258
}

0 commit comments

Comments
 (0)