aboutsummaryrefslogtreecommitdiff
path: root/src/r1.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-30 21:04:30 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-30 21:04:30 -0400
commit2e3fe35ec3ec07cb042eccbb221eec900d9ee39a (patch)
treeaa03bc4bb138bcdee08ae031a13b4b1eca045ff2 /src/r1.bqn
parent15e361bb360bdda2941d92af5a82cba49b3fed48 (diff)
Rank-less Find implementation
Diffstat (limited to 'src/r1.bqn')
-rw-r--r--src/r1.bqn16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/r1.bqn b/src/r1.bqn
index 34c90e57..ee634cb1 100644
--- a/src/r1.bqn
+++ b/src/r1.bqn
@@ -194,6 +194,14 @@ _self←{
0 Fill (PermInv g) ⊏ g 𝔽 0⊸<β—ΆβŸ¨1, -⟜1 CCβ—‹(βŠ‘βŸœ(kβŠΈΓ—βŒœg)) βŠ’βŸ©βŒœβ†•β‰ π•©
}
+Find←{
+ r←=𝕨 β‹„ d←(=𝕩)-r
+ "⍷𝕩: Rank of 𝕨 cannot exceed rank of 𝕩" ! 0≀d
+ i←<0 β‹„ j←β₯ŠβŸœ(↕1Γ—Β΄βŠ’)d↑s←≒𝕩
+ (≒𝕨) { Aβ†Γ—βŸœπ•©βŒœβŠΈ(+⌜)βŸœβ†• β‹„ i A↩𝕨 β‹„ j A↩0⌈1+𝕩-𝕨 }Β¨ d↓s
+ 0 Fill (𝕨 Match (β₯Šπ•©)⊏˜i+⌜<)⌜ j
+}β—‹ToArray
+
Indices←{
"/: Replication argument must have rank 1" ! 1==𝕩
"/: Amounts to replicate must be natural numbers" ! 1Γ—Β΄NatβŒœπ•©
@@ -694,13 +702,6 @@ GroupM←{
βŠ” ← GroupInds ⊘ GroupGen
⊐ ← SelfClas ⊘ (1 _search)
∊ ← ⊒_self ⊘ (0 _search˜)
-βŽ‰ ← _rankOp_
-
-Find←{
- r←=𝕨
- "⍷𝕩: Rank of 𝕨 cannot exceed rank of 𝕩" ! r≀=𝕩
- 0 Fill 𝕨 β‰‘βŽ‰r ((1+r-βŠΈβ†‘β‰’π•©)βŒŠβ‰’π•¨)βŠΈβ†•βŽ‰r 𝕩
-}β—‹ToArray
ProgressiveIndexOf ← 0 Fill {
c←1-˜=𝕨
@@ -838,6 +839,7 @@ Mod2Inverse ← INFΛ™ _lookup_ ⟨
βŠ‘ ↩ First ⊘ Pick
β—Ά ↩ {𝕨((𝕨𝔽𝕩)βŠ‘π•˜){𝔽}𝕩} # Same definition, new Pick
βš‡ ← _depthOp_
+βŽ‰ ← _rankOp_
β₯Š ↩ Deshape ⊘ Reshape
≍ ← >∘Pair _fillBy_ (⊒⊘IF)
⍉ ← Transpose ⊘ ReorderAxes