« first day (1864 days earlier)      last day (785 days later) » 

1:48 AM
Hmm, looks like some parameters will default a path to the location of the config file itself, while other will not.
 
How can I run a dyalog script on the (unix) command line?
I keep running into dyalog/mapl which is documented in the manuals, but doesn't seem to have a flag to disable the repl and just run.
Piping input into mapl from a file almost works, but has the opposite problem. It terminates without launching the repl, but never seems to get evaluated.
 
 
2 hours later…
3:56 AM
@AviFS dyalog -script script.dyalog?
 
 
8 hours later…
yay
 
Just in time for the next episode…
 
12:49 PM
it requires creating an arbitrary number of parallel threads, which i understand is only possible with ¨?
      ∇f
[1]  :While 1
[2]  {⎕←(⎕DL 5)⊢⎕}&0
[3]  :EndWhile
[4]  ∇
sadly not a thing
 
1:05 PM
@Adám i mean today's is really easy
identity matrix
 
True, but several approaches are possible.
 
@Razetime huh, so Dyalog won't process other threads while a / is taking input
{∇&⎕←(⎕dl 1)⊢⍞}0 is kind of close, but breaks if you enter anything during that 5s interval
here's a CBQN solution because why not: •term.Raw 1⋄{𝕊:t←•MonoTime@⋄r←𝕩∾(0⊸≠/⟜⋈⋈⟜t)•term.CharN@⋄m←t>5+1⊑¨r⋄•term.OutRaw 0⊑¨m/r⋄m¬⊸/r}•_while_ 1⟨⟩
 
 
1 hour later…
2:35 PM
↑⍤,⍥⊂ looks like a dazed owl holding a spear. I could use that as a mnemonic. :)
 
2:48 PM
In ⎕ML←3 (APL2-compatibility mode where some functions are slightly different) it looks like ⊃⍤,⍥⊂
 
I'm on mobile now so can't post my solution but it will pass probably never the less
 
@Richard This should work on your mobile.
Welcome to the APL Quest! Today's quest is Identity Crisis:
> An identity matrix is a square matrix (table) of 0 with 1’s in the main diagonal.

Write an APL dfn which produces an n×n identity matrix.
 
This is pretty fast: {⍵ ⍵⍴1@((⍳+⊢×⍳)⍵)⊢0↑⍨×⍨⍵}. The more obvious {s←⍵ ⍵⍴0⋄(0 0⍉s)←1⋄s} is pretty slow. Both ⎕IO←0.
 
Interesting. Anyone else?
How about the outer product? ⋄ ∘.=⍨⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
3:02 PM
I Ireshaped a matrix with 1 and as many zeros as the dimension
 
Very good. That's what I wanted to get to. Something like {⍵ ⍵⍴1,⍵↑0}
Can anyone spot why that might be slow?
… and any ideas for how to fix it?
 
Because the 1 had to be out in front of the zeros
 
{⍵ ⍵⍴(⍵+1)↑1}?
 
Correct, both of you!
 
My first one still the fastest :)
 
3:05 PM
Want to make that tacit?
@xpqz For what sizes?
 
I tried 1000
      cmpx '{⍵ ⍵⍴1@((⍳+⊢×⍳)⍵)⊢0↑⍨×⍨⍵}1000' '{s←⍵ ⍵⍴0⋄(0 0⍉s)←1⋄s}1000' '∘.=⍨⍳1000' '{⍵ ⍵⍴(⍵+1)↑1}1000'
  {⍵ ⍵⍴1@((⍳+⊢×⍳)⍵)⊢0↑⍨×⍨⍵}1000 → 2.6E¯5 |     0% ⎕
  {s←⍵ ⍵⍴0⋄(0 0⍉s)←1⋄s}1000     → 1.2E¯3 | +4307% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  ∘.=⍨⍳1000                     → 3.3E¯4 | +1162% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  {⍵ ⍵⍴(⍵+1)↑1}1000             → 3.2E¯5 |   +23% ⎕
 
I had overtake much faster on 100 and 1000.
 
Yeah, similar by me.
 
im late lol
 
3:09 PM
i'm pretty sure cmpx/]runtime are unreliable for precise timings of things magnitudes faster than the slowest in the list
 
@dzaima Interesting.
 
Here's a fun one: ⋄ ⎕IO←0 ⋄ {2⊥⍣¯1⌽2*⍳⍵} 5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
Is mirroring 0 0 0 0 1 faster maybe?
 
@Richard Surely not faster than generating 1 0 0 0 0 to begin with.
 
3:11 PM
In k: =
 
:=)
 
Why is assigning to 0 0⍉ so slow?
 
Any other approaches? Do we need an "industrial quality" one?
 
Can APL create an inverse matrix? Then A X A-1 is also the I matrix of I remember correctly. It's not fast off course
 
I had two approaches, and I'm wondering why the second one is THAT much slower:
    id1 ← ∘.=⍥⍳⍨
    id2 ← =/¨⍳∘(,⍨)
    ]runtime -c 'id1 100' 'id2 100'
id1 100 → 2.4E¯6 |      0%
id2 100 → 1.8E¯3 | +74400% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
3:13 PM
@Richard Yeah, nice: ⋄ ⌹⍨?5 5⍴0
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
@xpqz just not optimized probably, going a very generic path and copying things slowly
 
@Adám That's brilliant
 
Of course, it has a tiny probability of failing. I wonder if we can fix that.
@BojanPetrović The first one uses flat arrays, the second uses nested arrays.
 
{⌹⍨?⍵ ⍵⍴0}1000                → 5.8E¯1 | +464700% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Ouch
All nice solutions are dog slow :)
 
3:17 PM
@BojanPetrović Also ∘.=⍥⍳⍨ is the same as ∘.=⍨⍳ but the latter doesn't need to compute twice.
 
@Adám Thanks, I didn't think about that.
 
@xpqz ∘.=⍨⍳ is probably fine for most uses.
 
@xpqz beauty may cost more ;)
 
You betcha
 
⋄ ↑,⍨\5↑1
 
3:19 PM
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
Terribly slow too, of course.
⋄ 1↑⍨⍤0-⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
What was the industrial strength version?
 
Or 1, 0xj5
 
@Richard What?
 
3:21 PM
1, 0 times iota 5
 
0×⍳5 is 5⍴0
 
Yes
 
⋄ ⍸⍣¯1⍤⊢⌸⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
3:24 PM
@Adám ?
 
I'm guessing that's slow, too
 
Me too.
Same as ⋄ ⍸⍣¯1⍤,⍤0⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
Can you explain this one?
 
0=-⍤⍳⌽⍤0 1⍳ reasonably fun
 
3:26 PM
@Richard applies ⍸⍣¯1⍤⊢ to each list of indices where a unique element is found. ⍳5 has 1 at 1, 2 at 2, etc. ⍸⍣¯1 generates a Boolean vector of minimal length with 1s in those positions. Due to mixing, 0s are padded on the right.
 
@rak1507 what sort of voodoo is this
 
⍸⍣¯1⍤⊢⌸⍳
oh.. I scrolled up
 
@Richard Each (⍤0) element of ⍳5 fed to ⍸⍣¯1 as before, but we have to ravel ⍤, to make the arguments acceptable to ⍸⍣¯1
Oh, of course, rotating.
⋄ ⎕IO←0 ⋄ (-⍤⍳⌽⍤0 1↑∘1)5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
@rak1507 fun indeed :)
 
3:30 PM
Expand: ⋄ (,⍨⍴1(\⍨)1,-)5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
↑1⌽⍤↑⍨¨⍳
 
Same thing, really.
 
=/¨⍳⍤,⍨
 
19 mins ago, by Bojan Petrović
    id1 ← ∘.=⍥⍳⍨
    id2 ← =/¨⍳∘(,⍨)
    ]runtime -c 'id1 100' 'id2 100'
id1 100 → 2.4E¯6 |      0%
id2 100 → 1.8E¯3 | +74400% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
3:33 PM
0<⌽⍤↑⌸⍤⍳
 
@rak1507 Slowest so far :)
 
lol
 
@rak1507 and I thought I started to read and understandAPL better :)
 
@xpqz Nah, is slower.
 
Must be a complex arithmetic version somehow
 
3:38 PM
@xpqz ⋄ {4=○÷12○⍵∘.+0j1×⍵}⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
I hope someone submitted that at the time.
 
OK, have we beaten this one to death?
 
@Adám Yes, I understand that nested arrays are slower, I was just wondering why so much in this case. Is, for example, bad cache locality the primary issue, or something else?
 
I think @Richard takes it with {⍵ ⍵⍴(⍵+1)↑1}
Fast and simple.
 
3:41 PM
@BojanPetrović You're generating 10000 pointers!
 
Maybe something with a cosinus with interval of the dimension and rounded down
 
@xpqz We never made that tacit. Who want the honours?
@Richard What?
 
@Adám That's 10000 mallocs, right?
 
Something like that, but ¨ also has to go chasing each pointer.
⋄ {~×(2*÷2)|10○⍵∘.+0j1×⍵}⍳5
 
@Adám
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
 
3:44 PM
The number-theoretical edition…
Y'all can keep discussing — I'll see you next week for Home On The Range!
 
oh no, i missed it.
{⍸⍣¯1⊢,¨⍨⍳⍵} was my solution
@Adám also considered it
 
@KamilaSzewczyk We had something similar.
 
@BojanPetrović besides 10000 allocations from , it's 10000 iterations in the loop of ¨, 10000 separate invocations of =/, and another 10000 allocations for the result number of each =/. Compare that to ∘.=, which should have a native implementation, going through 32 elements at a time (the max number of bytes an AVX2 register can hold)
 
@Adám I offer ((,⍨⊢)⍴1∘(⊣↑⍨+))
 
@xpqz You can do much better.
 
3:55 PM
I was quite pleased with that one
 
Dec 30, 2021 at 10:52, by PyGamer0
CMC: Generate an identity matrix of order x.
 
@xpqz ,⍨⍴1∘+↑1⍨ or even ,⍨⍴1∘+↑≢
Announcement: APL Seeds '22 is happening on 29 March 2022. Free to attend, but registration is required. See website for details.
 
(,⍨⍴1∘(+↑⊣) if you truly want that 1 to be deduplicated, even though there's no reason to)
 
,⍨⍴+∘≢⍨↑≢ ← look ma, no 1s.
 
@dzaima Thanks, that helps a lot!
 
4:05 PM
@Adám I'll give it a try using cosinus when I am behind my computer again later this week
 
 
4 hours later…
7:47 PM
@Adám is the event phisical or online? can i attend online?
 
 
2 hours later…
9:21 PM
@BrianBED online via zoom
 
ok good to know
thanks
 

« first day (1864 days earlier)      last day (785 days later) »