http://qs1969.pair.com?node_id=11144902


in reply to Re: Kronecker Product
in thread Kronecker Product

Thanks, that's exactly the reply I was waiting for.

I see no difference between your solution and mine in the benchmark, but I definitely understand your points and see the improvement in the code.

Are you aware of any reading on "array languages" that would be understandable to tyros? I understand your solution but I can't imagine how to get to it (to get mine, I used trial and error repeatedly).

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^3: Kronecker Product
by vr (Curate) on Jun 21, 2022 at 16:39 UTC

    But it's same trial and error on my part. I think if anything can count as systematic approach, as true textbooks, from very basics and up, -- that, for me, have been Learning J and J for C Programmers, books designed to teach "tyros" the "array language", their authors using a bit different perspectives.

Re^3: Kronecker Product
by etj (Deacon) on Jun 21, 2022 at 17:26 UTC
    A nice intro to the concepts of array programming is https://en.wikipedia.org/wiki/Array_programming.

    Don't feel bad about trial and error; my first go at this (and I have the dubious privilege of being current PDL maintainer) assumed (wrongly) that dupN would be suitable for both sides of the multiplication; furthermore, it took me a little while to figure out inflateN, even though, annoyingly, it is nearly identical to dupN except for swapping the two parts of the slice argument.