if you post your code here someone might be able to find a better approach, but I don't think 1500⌶ works with ~ so the actual ~ operation probably can't get any faster
Last night in bed, I was wondering about the possibility of writing constant-time algorithms in APL. Are there any cryptographic libraries written in Dyalog APL? I'd assume that GC especially would do Bad Things™ for side-channel attacks.
Maybe yet another place for Co-dfns to potentially shine?
Dyalog wouldn't be suitable for constant-time code at all. It decides the storage type of a numeric array based on what numbers it contains, and can switch algorithms based on the data it sees too.
@sloorush Depending on your goals, maybe it'd be enough to simply transform ⍳Y into whatever set of points you want? 0J1×⍳5 gets you points on the imaginary line. (÷2*0.5)×+⌿1 0J1∘.×⍳5 gets you the same but rotated clockwise by 45 degrees. *(0J1×○2)×(÷5)×⍳5 should get you 5 points on the unit circle. Etc.
There you go. If that suffices for your needs, it's certainly prettier!
BTW, it's easy enough to tacitify that dfns: (⊢,-)
Man J's generalization of scalar extension is really quite nice, applying even to higher ranked arrays as long as the shape of one argument is exactly some prefix of the shape of the other argument.
So you can write the equivalent of 1 0J1×2 3⍴⍳6 and get 2 3⍴1 2 3 0J4 0J5 0J6
Even more generally, you could think about extension as long as one shape is a sub-sequence of the other's, but then you'd have to make a choice in ambiguous cases.
Maybe it's sufficient to just take the convention that the "left-most" subsequence always wins.