Jump to content

Kronecker product: Difference between revisions

J draft
(J draft)
Line 1,001:
[0,0,0,0,1,0,0,1,0,0,0,0]
[0,0,0,0,1,1,1,1,0,0,0,0]</pre>
 
=={{header|J}}==
 
Explicit:
 
<lang J>KP=: dyad def ',/"2 ,/ 1 3 |: x */ y'</lang>
 
Tacit:
 
<lang J>KP=: 1 3 ,/"2@(,/)@|: */</lang>
 
these definitions are functionally equivalent.
 
Task examples:
 
<lang J> M=: 1+i.2 2
N=: (+4**)i.2 2
P=: -.0 2 6 8 e.~i.3 3
Q=: -.5 6 e.~i.3 4
M KP N
0 5 0 10
6 7 12 14
0 15 0 20
18 21 24 28
P KP Q
0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 1 0 0 1 0 0 0 0
0 0 0 0 1 1 1 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 1 1 0 0 1 1 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 1 0 0 1 0 0 0 0
0 0 0 0 1 1 1 1 0 0 0 0</lang>
 
=={{header|JavaScript}}==
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.