12:44 AM
3 hours later…
3:25 AM
@MasterQuiz Here's an alternative using ⌽ and ⊖ that performs better for larger matrices. This can easily be golfed more, but this is a simple definition. Not sure how you want to handle borders -- we can get around that by padding:
2 hours later…
5:17 AM
5 hours later…
10:34 AM
1
CONTEXT let ns be an unsorted array of unique integers of arbitrary length, return the smallest missing positive number of that array. for example ns = {-1, -3, -2} -> 1 ns = {7, 8, 9} -> 10 ns = {-1, 5, 1} -> 2 I saw this on an APL youtube video and decided to give it a try myself, my solution ...
4 hours later…
2:29 PM
@Adám Oh wow, the 2 windowed reduce option didn't come to me initially. That is interesting that all those windowed comparisons are quicker even on large matrices -- wonder how a similar stencil solution would perform. Gotta run but I'll experiment later. Right now your definition is giving me a domain error on numeric mats & failed a test with a matrix of all 1's
6 hours later…
8:24 PM
I'm seeing mixed performance results for the windowed reduction approach. Generally it does seem faster than HasConsecutiveRows, but still atleast in the same order of magnitude. I'd say the windowed reduction approach is better though. The padding hack is kind of hacky IMO. Also curious about how these would perform against eachother in co-dfns GPU
]runtime -c "{b←0=⍵ ⋄ (1∊2^/b)∨(1∊2^⌿b)}m" "HasConsecutiveZeros m" "f m" {b←0=⍵ ⋄ (1∊2^/b)∨(1∊2^⌿b)}m → 1.1E¯1 | 0% ⎕ HasConsecutiveZeros m → 9.4E¯2 | -16% ⎕ f m → 3.5E0 | +3014% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
]runtime -c "{b←0=⍵ ⋄ (1∊2^/b)∨(1∊2^⌿b)}m" "HasConsecutiveZeros m" {b←0=⍵ ⋄ (1∊2^/b)∨(1∊2^⌿b)}m → 5.9E¯2 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ HasConsecutiveZeros m → 8.7E¯2 | +48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
The other interesting approach would be with ⍸
my guess is that performance would vary a lot with how dense/sparsely consecutive 0s are found in the matrix. Materializing those booleans to ints would be pretty costly IMO
my guess is that performance would vary a lot with how dense/sparsely consecutive 0s are found in the matrix. Materializing those booleans to ints would be pretty costly IMO
« first day (2321 days earlier) ← previous day next day → last day (339 days later) »