Yes, I didn’t see a definition in the non-J Wikipedia page. Some papers popped up with vaguely relevant titles, which I didn’t pursue.
Thanks, Mike Sent from my iPad > On 1 Oct 2021, at 13:26, Jan-Pieter Jacobs <[email protected]> wrote: > > "How is the generalized Kronecker product defined?": Good question. > I don't know how it is officially done, but extended the 2D-2D case in the > examples such that the axes between x and y are paired, any trailing axes > not matched by the other being padded with appended 1's. > > As Raul said, if you have A of shape ijk and b of shape mno you'd end up > with a result of shape i j k * m n o. > In case of different shapes, the shortest is padded > e.g. : i j k , m n -> i j k * m n 1. My current definition just doesn't > work for scalars, which should now be passed as a 1 element rank 1, e.g. A > kp ,5. > > That said, I've searched it, but found no single mention of a Kronecker > product generalised to arbitrary dimensions, so I don't even know whether > it could be useful, but it looked cute. > > Possible (silly) use I could think of is: > > kp=: cs ($,) dp |: *"0 _ > NB. cs calculates the eventual size of result > cs=: ([: */&:> >.&# {.!.1&.> ;)&$ > NB. dp axis shuffle needed to interleave corresponding axes of x and y > dp=: (+ {. [: ,@|:@i. 2 , >.)&(#@$) > > AA=: 10 10 10 ?@$ 2 > A=: =i. 10 > B=: 6 8 15 19 21 22 23 e.~i. 5 5 > load'viewmat' > viewmat A kp B > viewmat ({."1 A kp 5 5$1) * +/&.|: A kp B > > Have fun! > >> On Fri, Oct 1, 2021, 11:08 Raul Miller <[email protected]> wrote: >> >> I can reproduce this issue. >> >> Furthermore, while trying to understand it, I found a workaround. >> >> A ([:*/&:>>.&#{.!.1&.>;)&$B >> |domain error >> >> A ([:*/&:>>.&#{.!.1&.>;)&{{y}}&$B >> 6 6 >> >> The success of this workaround suggests an issue with special code. >> >> Thanks, >> >> -- >> Raul >> >> On Fri, Oct 1, 2021 at 3:23 AM Jan-Pieter Jacobs >> <[email protected]> wrote: >>> >>> Hi, >>> Yesterday I was playing with the Kronecker product, trying to extend it >> to >>> arbitrary dimensions (not that I really needed, but it seemed fun). It >>> works on this J: >>> JVERSION >>> Engine: j902/j32/android >>> Release-a: commercial/2020-12-24T11:35:03 >>> Library: 9.02.08 >>> Platform: Android 32 (armeabi-v7a) >>> Installer: unknown >>> InstallPath: /mnt/sdcard/Android/data/com.jsoftware.j.android/files >>> Contact: www.jsoftware.com >>> >>> But not on beta-r, nor beta-s on windows 64, avx2. >>> >>> The definition is as follows (based on >>> https://wiki.jsoftware.com/wiki/Essays/Kronecker_Product): >>> >>> kp=: cs ($,) dp |: *"0 _ >>> NB. cs calculates the eventual size of pairwise joining axes >>> cs=: ([: */&:> >.&# {.!.1&.> ;)&$ >>> NB. dp calculates the axis shuffle needed to interleave corresponding >> axes >>> of x and y >>> dp=: (+ {. [: ,@|:@i. 2 , >.)&(#@$) >>> >>> A=: =i. 3 NB. identity, shape 3 3 >>> B=: >:i. 2 2 NB. shape 2 2 >>> AA=: 0 13 26 e.~i. 3 3 NB. shape 3 3 3 >>> >>> 'A kp B' and 'AA kp B' fail because 'A cs B' and 'AA cs B' throw a domain >>> error in J903-beta-r/s I don't understand, but do work in J902. Dissect >>> mentions an inconsistency, but eventually shows the right result. >>> >>> however, removing &$ from cs and feeding in shapes directly does work. >>> >>> 3 3 3 ([: */&:> >.&# {.!.1&.> ;) 2 2 >>> 6 6 3 >>> >>> Am I missing something or is this an interpreter bug? >>> >>> Any comments on the Kronecker product as such, does it make sense? The >> 2x2 >>> case is at least consistent with the definitions in the essay. >>> If it is sound, I'd add it to the Essay. >>> >>> Best regards, >>> Jan-Pieter. >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
