Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-20 Thread Thomas McGuire
Also Raghu’s write up was about taking the wikipedia looping pseudo-code for matrix multiplication and thinking in array languages on how to implement. I thought the solution in K was rather elegant and wondered what matrix multiplication from scratch would look like in J using Raghu’s K implem

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Devon McCormick
I missed that. I think this is an elegant way that avoids explicit rank. On Tue, Jul 19, 2022 at 2:13 PM Hauke Rehr wrote: > Tom did, in the very post starting this thread: > > (1+i. 4 3) +/ . * 1+i. 3 4 > 38 44 50 56 > 83 98 113 128 > 128 152 176 200 > 173 206 239 272 > > Am 19.07.

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Hauke Rehr
Tom did, in the very post starting this thread: (1+i. 4 3) +/ . * 1+i. 3 4 38 44 50 56 83 98 113 128 128 152 176 200 173 206 239 272 Am 19.07.22 um 20:10 schrieb Devon McCormick: I'm puzzled why no one has used the basic matrix multiplication expression in J. matmul3 ([: +/ *)"1 _

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Devon McCormick
I'm puzzled why no one has used the basic matrix multiplication expression in J. matmul3 ([: +/ *)"1 _ mat1=. <.0.5+10*<:+:1000 1000?@$0 mat0=. <.0.5+10*<:+:1000 1000?@$0 (10) 6!:2 'mat0 matmul3 mat1' 0.737084 (10) 6!:2 'mat0 +/ . * mat1' 0.0499271 (mat0 matmul3 mat1) -: mat0 +/

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Thomas McGuire
My late night laziness and I got bitten by the 13 : definition doesn’t always work correctly with both x and y variables. Which I just assumed was working correctly. Now when I fix the definition of matmul3 so it works correctly (as Elijah pointed out) the variable representation does not incu

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Elijah Stone
On Tue, 19 Jul 2022, Thomas McGuire wrote: Now the wierd thing is the timing for matmul3 is slow on par with emulating K matrices in J But if I use the fork directly it is as fast as Raul’s solution You are measuring two completely different things. 10 timex'bmat1 ([: +/ *)"1 _ bmat2' 0.

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Thomas McGuire
I had a chance to digest the K-way of lists of a list method Raul presented in J. After I understood it somewhat and its use of the leaf operator. I was curious as how fast these things ran, as implied by Raghu and Raul it was fairly slow compared to the J matrix implementation proposed by Ra

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-13 Thread Elijah Stone
https://gist.github.com/chrispsn/af6844b80687462814fc39d4b97399a6 may be of interest On Wed, 13 Jul 2022, Raul Miller wrote: On Wed, Jul 13, 2022 at 4:23 AM Razetime wrote: The ngn/k version is much better for the K array model, and it's intended as a nice and short description of the algori

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-13 Thread Raul Miller
On Wed, Jul 13, 2022 at 4:23 AM Razetime wrote: > The ngn/k version is much better for the K array model, and it's intended > as a nice and short description of the algorithm for nested lists. Oh... yes... K is highly optimized for nested rank 1 lists of rank 1 lists -- J... not so much. J's rank

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-13 Thread Razetime
Hi, I wrote the original essay. The ngn/k version is much better for the K array model, and it's intended as a nice and short description of the algorithm for nested lists. Your translation looks correct, and you might get a one-to-one translation with boxed arrays and table. J doesn't really encou

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-12 Thread Henry Rich
I have to question the use of 'elegant' here. Matrix multiplication has a similarly short representation in J. But the actual code: it breaks the operation into several layers of loops: one sized to the registers, one sized to D1$, one sized to D2$. Simply following the definition of the oper

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-12 Thread Raul Miller
Well... of course, you can express matrix multiplication *using* rank: (1+i.4 3) +/@:*"1 _(1+i.3 4) 38 44 50 56 83 98 113 128 128 152 176 200 173 206 239 272 And, conceptually, all verbs in J have rank, so that always gets used. But, I guess you are asking how to avoid the rank conjunct

[Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-12 Thread Thomas McGuire
Devon had shared a kx example of performing matrix multiplication backing out the loops from a wikipedia pseudocode. Providing an elegant solution in K. You can see it in the NYCJUG notes here: https://code.jsoftware.com/wiki/NYCJUG/2022-07-12