diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-31 14:32:18 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-05-31 14:32:18 -0400 |
| commit | 87fd60f6d3f574155214fea44147c7f0a8744e71 (patch) | |
| tree | e41e1bf35006d61990e33949a7677f30bda00cd3 | |
| parent | 10392a6cac0f3f318817c16c591f826e5146ce92 (diff) | |
Allow Rand to take a shape left argument
| -rw-r--r-- | test/fuzz.bqn | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/fuzz.bqn b/test/fuzz.bqn index 1bc10213..ee116a2f 100644 --- a/test/fuzz.bqn +++ b/test/fuzz.bqn @@ -7,8 +7,10 @@ _makeRand ← {st←𝕗 {𝕤⋄ d ⌊∘÷˜ st ↩ m|2531011+214013×st } } RandGen ← 1234 _makeRand -Rand ← { 𝕩 | 0 rr⊸×⊸+˜´ RandGen¨↕⌈rr⋆⁼𝕩 }∘(1⊸⌈)⚇0 +RandSh ← ⊢ ⥊ ·RandGen¨ (↕×´) +Rand ← { 𝕩⌈↩1 ⋄ 𝕨 ⊢⊘⥊ 𝕩 | 0 rr⊸×⊸+˜´ (𝕨RandGen⊘(RandSh∘⊣)⊢)¨↕⌈rr⋆⁼𝕩 } _randChoose ← { Rand∘(≠𝕗)◶𝕗 } +_randUnbounded ← { 𝕊⊸+⍟(1=-)⟜Rand 𝕗 } # Prime factorization ⟨Factor⟩ ← { @@ -30,7 +32,7 @@ Sigmoid ← (40≤|)◶⟨1(-÷+)˜⋆,×⟩ -⟜1 ⌊ Rand∘(1⌈⌈)⌾((2⋆3+⊢)⁼) + ¯7+Rand∘15 # Near power of two ⟩_randChoose - RandRank ← { 𝕊⊸+⍟(1=-)⟜Rand 4 } + RandRank ← 4 _randUnbounded Augment ← { d ← 1+⌊𝕨÷1⌈×´𝕩 # Maximum bound that can be added, plus 1 @@ -39,7 +41,7 @@ Sigmoid ← (40≤|)◶⟨1(-÷+)˜⋆,×⟩ } Combine ← ⟨ Rand∘≠⊸⌽ (2+Rand∘≠)⊸{×´¨𝕨↑(𝕨|↕∘≠)⊸⊔𝕩}∘⊢ # Random number of groups - ×´¨ (⊐·Rand⥊˜∘≠)⊸⊔∘⊢ # Distribute randomly + ×´¨ (⊐·Rand¨⥊˜∘≠)⊸⊔∘⊢ # Distribute randomly ⟩_randChoose RandShape ⇐ ⊢ Augment ⟨ ⊢ (⊢ ⌊∘× ⊢ ≠⊸√ (Sigmoid⊸÷1⌈×´⊸÷˜)) · Rand¨ (RandRank⌈√<Rand)⊸⥊ @@ -49,7 +51,7 @@ Sigmoid ← (40≤|)◶⟨1(-÷+)˜⋆,×⟩ # 𝕨 is 2⋆⁼bits in type; 𝕩 is shape RandArith ← { - •internal.Squeeze (1⊸<⊸×m÷2) -˜ Rand 𝕩⥊m←2⋆𝕨 + •internal.Squeeze (1⊸<⊸×m÷2) -˜ 𝕩 Rand m←2⋆𝕨 } # 𝕩 is bound RandMonArith ← RandArith⟜RandShape |
