Thanks, J-P.
The new version works when left hand rank >: right hand rank, but still fails otherwise:

   $2 3 4 kpnd&i. 7 8 9
14 24 36
   $2 3 4 kpnd&i. 7 8 9 10
|index error: kpnd
|   $2 3 4     kpnd&i.7 8 9 10
   $2 3 4 kpnd&i.~ 7 8 9 10
14 24 36 10
   $2 3 4 kpnd&i. 7 8 9 10 11
|index error: kpnd
|   $2 3 4     kpnd&i.7 8 9 10 11
   $2 3 4 kpnd&i.~ 7 8 9 10 11
14 24 36 10 11

This is using J903 beta-u under Windows,  but the verb "as" probably needs a bit
more tweaking.

Cheers,

Mike

On 05/10/2021 17:09, Jan-Pieter Jacobs wrote:
Hi Mike,
You are entirely right!
I discovered the same yesterday evening and cooked up a new version of the
axis shuffle that works right and happens to be beatiful (IMHO).

It's on the Kronecker product wiki page.

Jan-Pieter

On Tue, Oct 5, 2021, 16:38 'Michael Day' via Beta <[email protected]>
wrote:

Probably not a beta problem, now, but that's where this thread started.

It looks as if whatever was going wrong for you in beta-r and and beta-s
is now ok.
However, there seems to be an underlying problem when the ranks of the
inputs
differ by 2 or more.

     JVERSION
Engine: j903/j64avx2/windows
Beta-u: commercial/2021-10-01T12:08:24
Library: 9.03.06
Qt IDE: 1.9.3/5.15.2(5.15.2)
Platform: Win 64
Installer: J903 install
InstallPath: c:/d/j903-beta
Contact: www.jsoftware.com

NB. using definitions as in the original post,  of 1 Oct,  copied below.
     A $@:kp B
6 6
     AA $@:kp B
6 6
      $each A;B
+---+---+
|3 3|2 2|
+---+---+
     3 3 $@kp&i. 2 2  NB.  concentrating on input dimensions serves our
purpose here...
6 6

However,  errors occur in some of the following examples:
     2 3 $@kp&i.7 8   NB. resulting dimension as expected
14 24
     2 3 $@kp&i.7 8 9 NB. resulting dimension as expected - with extension
14 24 9
     2 3 $@kp&i.7 8 9 10  NB. fails!?
|index error: kp
|   2 3    $@kp&i.7 8 9 10
     2 3 4 $@kp&i.7 8 9 10 NB. resulting dimension as expected
14 24 36 10
     2 3 4 $@kp&i.7 8 9 10 11 NB. fails!?
|index error: kp
|   2 3 4    $@kp&i.7 8 9 10 11
     2 3 4 5 $@kp&i.7 8 9  NB. resulting dimension as expected - with
extension
14 24 36 5
     2 3 4 5  $@kp&i.7 8 9 10 NB. resulting dimension as expected
14 24 36 50
     2 3 4 5 6 $@kp&i.7 8 9 NB. fails?!
|index error: kp
|   2 3 4 5 6    $@kp&i.7 8 9

FWIW,  I won't bother you with my effort using direct definition ( {{
... }} ) ; it is far slower
and more space consuming and less fun than kp;  however, it does as
least appear to work
where kp fails in these examples!

Cheers,

Mike

On 01/10/2021 08:23, Jan-Pieter Jacobs 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

--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to