Skip to content

Commit

Permalink
fix a crash in antidrop
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jan 19, 2025
1 parent ff28f76 commit 7f0b00f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/algorithm/dyadic/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,30 +932,30 @@ impl<T: ArrayValue> Array<T> {
// println!("curr: {curr:?}");
// Add leading slices
for i in 0..n - 1 {
if i != n - 2 && index[i] > 0 && curr[i + 1..].iter().all(|&c| c == 0) {
if i != n - 2 && index[i + 1] > 0 && curr[i + 1..].iter().all(|&c| c == 0) {
// println!(" extend {i} {:?}", slice_sizes[i]);
extend_repeat_slice(&mut new_data, &fill.data, slice_sizes[i].unsigned_abs());
}
}
// Add leading sliver
// println!(" sliver: {}", sliver_size);
if sliver_size > 0 {
// println!(" sliver: {}", sliver_size);
extend_repeat_slice(&mut new_data, &fill.data, sliver_size.unsigned_abs());
}
// Add array row
new_data.extend_from_slice(&self.data[contig_row_size * i..][..contig_row_size]);
// Add trailing sliver
// println!(" sliver: {}", sliver_size);
if sliver_size < 0 {
// println!(" sliver: {}", sliver_size);
extend_repeat_slice(&mut new_data, &fill.data, sliver_size.unsigned_abs());
}
// Add leading slices
// Add trailing slices
for i in 0..n - 1 {
if i != n - 2
&& (curr[i + 1..].iter().enumerate()).all(|(j, &c)| c == maxes[i + 1 + j] - 1)
{
// println!(" extend {i} {:?}", slice_sizes[i]);
if index[i] < 0 {
if index[i + 1] < 0 {
extend_repeat_slice(
&mut new_data,
&fill.data,
Expand Down
2 changes: 2 additions & 0 deletions tests/dyadic.ua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
⍤⤙≍ [↯2⊚3 [⊚3 0_1_2] [⊚3 0_3_4]] ⌝↘ 1_1_1 +1°△2_1_2
⍤⤙≍ ↯3_1 0 ⌝↘ 1_1 ↯2_0 []
⍤⤙≍ ↯1_3 0 ⌝↘ 1_1 ↯0_2 []
⍤⤙≍ [[0_0_0 0_1_2 0_3_4] [0_0_0 0_5_6 0_7_8]] ⌝↘0_1_1 +1°△2_2_2
⍤⤙≍ [[1_2_0 3_4_0 0_0_0] [5_6_0 7_8_0 0_0_0]] ⌝↘0_¯1_¯1 +1°△2_2_2

# Keep
⍤⤙≍ [1 2 3] ▽ [1 1 1] [1 2 3]
Expand Down

0 comments on commit 7f0b00f

Please sign in to comment.