Jump to content

Kronecker product: Difference between revisions

Added Sidef
(added Tcl)
(Added Sidef)
Line 1,030:
│ 0 0 0 0 1 1 1 1 0 0 0 0 │
└ ┘
</pre>
 
=={{header|Sidef}}==
{{trans|Perl 6}}
<lang ruby>func kronecker_product(a, b) {
a ~X b -> map { _[0] ~X* _[1] }
}
 
kronecker_product([[1, 2], [3,4]],
[[0, 5], [6, 7]]).each { .say }
 
say ''
kronecker_product([[0,1,0], [1,1,1], [0,1,0]],
[[1,1,1,1],[1,0,0,1], [1,1,1,1]]).each { .say }</lang>
{{out}}
<pre>
[0, 5, 0, 10]
[6, 7, 12, 14]
[0, 15, 0, 20]
[18, 21, 24, 28]
 
[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]
</pre>
 
2,747

edits

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