Skip to content

Commit

Permalink
fix some cases of under dip
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jan 4, 2025
1 parent d67a42e commit ca381c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/compile/invert/under.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ under!(DipPat, input, g_sig, inverse, asm, Dip, span, [f], {
let rest_before_sig = rest_before.sig()?;
let rest_after_sig = rest_after.sig()?;

let balanced = g_sig.args + rest_before_sig.args <= g_sig.outputs + rest_after_sig.outputs;
let bal_symmetric = g_sig.args + rest_before_sig.args <= g_sig.outputs + rest_after_sig.outputs;
let bal_assymetic = rest_before_sig.args > 1 && rest_before_sig == rest_after_sig.inverse();
let balanced = bal_symmetric || bal_assymetic;

// Make before
let mut before = if !inverse || balanced {
Expand Down
18 changes: 12 additions & 6 deletions tests/under.ua
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,6 @@ G ← ⍜(⊙⊙⊢) ⋅⊙∘
⍤⤙≍ [10_2_3 4_50_6 7_8_90] ⍜⌝⤸(×10) 0_0 +1°△3_3
⍤⤙≍ [10_2_3 4_50_6 7_8_9] ⍜⌝⤸(×10↙2) 0_0 +1°△3_3

# Experimental!

# Un under
⍤⤙≍ [[1_2 3_4] [1_2 5_6]] [°⍜∩(↘1)⊟] [1_2 3_4 5_6]
⍤⤙≍ [10 2] [°⍜⊙(×10)⊟] [1 2]

# Obverse
⍤⤙≍ 5 ⍜⌅(+|-)∘ 2 5
⍤⤙≍ 3 ⍜⌅(+|)∘ 1 2
Expand All @@ -409,3 +403,15 @@ F ← ⌅(+|⊃⌊(⍜×⁅1e12◿1)|⟜+|-|-)
⍤⤙≍ [10 2 30 4 50] ⍜(▽⌅⊸◿2|×10) [1 2 3 4 5]
⍤⤙≍ [1 20 3 40 5] ⍜(▽⌅⊸(¬◿)2|×10) [1 2 3 4 5]
⍤⤙≍ [1 20 3 40 5] ⍜(▽⌅⊸(¬◿2)|×10) [1 2 3 4 5]

# Experimental!

# Un under
⍤⤙≍ [[1_2 3_4] [1_2 5_6]] [°⍜∩(↘1)⊟] [1_2 3_4 5_6]
⍤⤙≍ [10 2] [°⍜⊙(×10)⊟] [1 2]

# Reach
⍤⤙≍ [4 ∞ 5] [⍜𝄐⊟+ 1 ∞ 2 3]
⍤⤙≍ [¯1 ∞ ¯2] [⍜𝄐⊟¯ 1 ∞ 2]
⍤⤙≍ [4 ∞ 5] [⍜(⊟⊙◌)+ 1 ∞ 2 3]
⍤⤙≍ [¯1 ∞ ¯2] [⍜(⊟⊙◌)¯ 1 ∞ 2]

0 comments on commit ca381c5

Please sign in to comment.