« first day (867 days earlier)      last day (1790 days later) » 

12:15 AM
which leads to the following perf report: 20% of the time is spent in `Exec` - the class responsible for parsing tokens to an execution sequence, i.e. dfns...; the most often called functions - `|` and `∪` are kind of visible - `|` taking 3.28% and AbstractCollection_toArray & the spam of Linked___ for my lazy unique implementation
https://tio.run/##nVjLbhtJErzPV@jgvQr1ynoctbQHI8CPwQrYy2DRyMrKknpNNbl8@LE/740mqbEx2EPTAiSSotTRlRkZEUnh6RPvv327uXHm1pi/3dzc/f42PNzc/PDk@9cft/@6efNFZRj3g5JrpFWjsqlRTao2O66hZOqtUKEcQhMXfsH/xVu/5NIPh904PQ7j1PTLhz4wCzuN3Lna5JWtiy7nZrz1PeYcqTrXe2gzQrilsADh7t3rGO52O/56f
 
 
8 hours later…
8:44 AM
@ngn I'm having a look now - I suspect you're right as I see nothing about 'i' on the wikipedia for FEN
@ngn That 'i' is definitely 'f', although I will double check with the author
 
ngn
9:18 AM
@RichardPark i like the chess problem very much but i think it needs more serious tests. is there any chance of dyalog adding more examples while the contest is in progress?
e.g. pawn capturing another piece, pawn's initial leap blocked by another piece at rank 3, en-passant, stalemate, revealed check
or nasty cases where notation needs to be disambiguated by mentioning the starting square of a move
@ngn *at rank 3 or 6
 
9:45 AM
@ngn I personally feel like the problem should have been simplified to ignore castling, en passant and the case you just described - but that's just me being lazy
@ngn Isn't the starting square given by the board configuration?
 
ngn
@RichardPark right, it does feel like it's drowning me in details that don't have much to do with array programming. this problem is more "real-world" than "competitive"
@RichardPark i meant, some moves in the output might be ambiguous. for instance imagine just two white rooks at a1 and h1 (and the two kings are far away from rank1). if we output Re1, that would be ambiguous, as it's not clear which of the two rooks moved there.
it has to be something like Ra1-e1 or Rae1 (i still haven't read the formal SAN spec)
there are examples of this in "Problem 3. Moving Along" - e.g. 17.exd4 exd4 ... 21.Nd3 Rab8 ... 24.Nexc5 but those are inputs (much easier to ignore when parsing) rather than outputs (need dedicated code to disambiguate)
 
10:16 AM
@ngn Just browsed the spec again and you are correct (it's Rae1 or R1e1 or Ra1e1 depending on which is most convenient) - for now make a note and I'll discuss with the author what is to be done about ambiguous moves
 
 
1 hour later…
11:35 AM
I'm working on the Van Eck sequence problem and I've forgotten how to get "the indices of an array where an element was found"
I only need the first index (else, an element not found signifier) but I'm not sure how to go about it
 
ngn
@Sherlock9 ⍸bitmask
 
@Sherlock9 as in index? Gives 1+maxsindex to indicate "not found"
 
ngn
@Sherlock9 bitmask⍳1
 
Hrm, 1+max_index is going to be tricky to check for
Let me write up an idea and see where it goes. Thank you both
 
11:54 AM
Ok so I have the basic (find the next element part down
⎕←2 0 1 0 0{∨/⍺∊⍵:(⍺⍳⍵),⍵,⍺ ⋄ 0}2
 
@Sherlock9
1 2 2 0 1 0 0
 
Welp that last bit should be ⋄0,⍵,⍺ or something similar, but that's fine
The two steps I'm not sure about are: 1) I need to get the head and the tail as and to that dfn; and 2) I forget what the idiom is to build up a sequence until it's length
*the head and the tail of the new array I've just built in the last step
Oh right and exist
⎕←0{⍵<1:⍺⋄((1↓⍺){∨/⍺∊⍵:⍺⍳⍵⋄0}(1↑⍺)),⍺∇⍵-1}2
 
@Sherlock9
0 0 0
 
Well, it almost works
⎕←0 0{((1↓⍺){∨/⍺∊⍵:⍺⍳⍵⋄0}(1↑⍺)),⍺}'⍵ not used here so this is filler text'
 
12:14 PM
@Sherlock9
1 0 0
 
But that works
Solved by more parentheses!
⎕←0{⍵<1:⍺⋄(((1↓⍺){∨/⍺∊⍵:⍺⍳⍵⋄0}(1↑⍺)),⍺)∇⍵-1}10
 
@Sherlock9
0 6 1 2 2 0 2 0 1 0 0
 
ngn
12:55 PM
⎕←⌽{⍵,⍨(≢⍵)|(1↓⍵)⍳⊃⍵}⍣10⊢0 ⊣⎕io←1
 
@ngn
0 0 1 0 2 0 2 2 1 6 0
 
ngn
@Sherlock9 ^ should be easy to turn into a train
⎕←⌽(⊢,⍨≢|1∘↓⍳⊃)⍣10⊢0
 
@ngn
0 0 1 0 2 0 2 2 1 6 0
 
I don't need to reverse, I don't think. Just grab the latest element with while it's still reversed
Also holy crap that's short
Hm, I was about to post {⊃⍬{⍵<1:⍺⋄(((1↓⍺){∨/⍺∊⍵:⍺⍳⍵⋄0}⊃⍺),⍺)∇⍵-1}⍵} as that can be 0-indexed and 1-indexed (since the author of the challenge hasn't clarified and it's apparently 1-indexed) but I don't know how to make that last golf 1-indexed
 
@Sherlock9 ⊢0⊢⍬
 
1:01 PM
⎕←(⊢,⍨≢|1∘↓⍳⊃)⍣10⊢⍬
 
@Sherlock9
3 0 2 3 0 3 1 0 0 1
 
oh hm didn't test that much, only tested input 8 :|
 
Should've clarified that "I don't know how" meant that I'd tried ⊢⍬ and it hadn't worked. Pardon me
 
I think ⊢¯1 works
 
@H.PWiz If so, then -1 is shorter.
 
1:03 PM
true
 
Anyone know how to do half an outer product?
 
@RichardPark What does that mean?
 
e.g. I only want the bottom-left (or top-right) triangle of ∘.-⍨1 4 7 6
 
ngn
@RichardPark scan :)
 
@RichardPark But you can't have triangular arrays. What do you want the result to look like? Nested? Padded?
 
ngn
1:06 PM
⎕←(⊢-,\)1 4 7 6
 
@ngn
┌─┬───┬─────┬────────┐
│0│3 0│6 3 0│5 2 ¯1 0│
└─┴───┴─────┴────────┘
 
remember the table operator you did for my MD code?
{⍺⍺ ⍤1 99⍨⍵}
I only need half of those calculations
 
@ngn Either double backslash or four leading spaces!
 
ngn
@Adám facepalm markdown...
 
⎕←(⊢,⍨≢|1∘↓⍳⊃)⍣10⊢¯1
 
1:07 PM
@Sherlock9
6 1 2 2 0 2 0 1 0 0 ¯1
 
Well that extra -1 is just rude :P
Ah well, I only need the first element anyway
 
⎕←{⊃(⊢,⍨≢|1∘↓⍳⊃)⍣⍵-1}¨⍳20
 
@H.PWiz
0 0 1 0 2 0 2 2 1 6 0 5 0 2 6 5 4 0 5 3
 
@RichardPark You spoke with Marshall about that no? No way to save on those computations without severe slowdown due to structure. ∘.- could be smarter…
 
Ohh
Thanks H.PWiz. Time to go try to figure out how I'll write the explanation
 
1:15 PM
@Adám for ∘.- sure, but for dfns even with the ¨¨ there is a speed gain. i've needed that some times but never bothered to find a solution.
 
@dzaima Maybe another candidate for the memoisation operator
 
@Adám i'd think forcing memoization would mean a 10-100x slowdown above the 2x potential speedup though
hmm the ¨¨ here doesn't do much to the speed - is Dyalog optimizing it away?
 
1:49 PM
I'm still puzzling over (⊢,⍨≢|1∘↓⍳⊃). Where does the array come from? ?
 
@Adám Because of Newton's 1st law I only need the distances between pairs of particles once
 
@RichardPark Sure, I get that. In this case (-) due to the nature of mathematics, the second half doesn't actually need computing per se. However, due to the nature of processor speed vs memory speed, there's no speed-up to be gained by no computing that extra half.
 
@Sherlock9 And what does ≢| do?
 
@Adám There has to be if I'm gonna do 1000's of atoms
@Sherlock9 ⎕←≢2 4 3⍴0 ⍝ Length of first axis
@Sherlock9 ⎕←|¯3+⍳5 ⍝ Absolute value of numbers
 
@RichardPark | is dyadic.
 
2:00 PM
Ah, so it is modulo
 
@Sherlock9 Yeah, remainder.
 
Alright so why do we need the tally ?
 
@Adám Not if you put a ≢ first? Or is it a train?
 
⎕←⊢,⍨≢|1∘↓⍳⊃
 
@Adám
┌─┼───┐
⊢ ⍨ ┌─┼───┐
┌─┘ ≢ | ┌─┼─┐
,       ∘ ⍳ ⊃
       ┌┴┐
       1 ↓
 
2:02 PM
Oh
Alright, posted. Thanks very much
Let me know if I made any errors in the explanation
 
@Sherlock9 ⍣⍵ repeats times, not ⍵-1
 
@Sherlock9 You can save 2 byte making it a tradfn body ("whole program"), replacing with and removing the outer braces.
 
Thank you both, all fixed.
 
3:11 PM
@Adám Does APL really not slow down when ∘.-ing the thousands of elements in RichardPark's array?
Or whichever method they ended up using
 
]runtime -c "↓{⍵×∘.>⍨⍳≢⍵}∘.-⍨a" "{(≢⍵)↑¨⍵}(⊢-,\)a"

↓{⍵×∘.>⍨⍳≢⍵}∘.-⍨a → 1.2E¯2 | 0% ⎕
{(≢⍵)↑¨⍵}(⊢-,\)a → 9.0E¯1 | +7525% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

]runtime -c "↓{⍵×∘.>⍨⍳≢⍵}∘.-⍨a" "(⊢-,\)a"

↓{⍵×∘.>⍨⍳≢⍵}∘.-⍨a → 8.0E¯3 | 0%
* (⊢-,\)a → 9.0E¯1 | +11153% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
@Sherlock9 Sure, but if the array has has to stay square, the extra half has to be filled with something. Subtraction basically runs at memory throughput speed, so whether subtraction is or filling is done, doesn't matter much.
@Sherlock9 And as you can see on the speed comparisons above, going for a non-flat storage of the data is much slower.
 
Huh. Makes sense
And it's probably the same amount of time if you leave it square at first and instead flatten the list and pick the elements you want then
Assuming you even want a flat array
 
@Sherlock9 I think there are a couple of fundamental changes to the way my program works which will allow it to scale without slowing down as much as it does now - I intend to clean up and plan the project before putting it on GitHub with milestones etc.
 
Best of luck, then
 
3:30 PM
@Adám if you chose a format to store the data so the triangle could easily linearly stay in a 1-dimensional structure, you should be able to get the 2x speedup. though apl isn't well suited for that
 
@dzaima Firstly, this should be directed to @RichardPark. Secondly, there are more dramatic speed-ups to be gained by not recalculating distance between all particles for cut-off of influence, when the new distance follows the old distance×speed. At least the list of candidates can be significantly reduced.
 
3:55 PM
@Adám So LAMMPS is still fast even though the script seems to suggest that they're calculating neighbours every step - but they can't be comparing every pair of particles every step since I'm getting 100 steps 10k atoms in <6 seconds (APL does 330 seconds)
 
4:13 PM
Interestingly, for a box size 10000×10000, 1000 atoms for 1000 steps takes about the same time between LAMMPS and APL
And the two longest lines are:
S-←((0.5∘<)-(¯0.5∘>))S
Rmask←(rcutoff*2)>+/R*2
 

« first day (867 days earlier)      last day (1790 days later) »