Kronecker product: Difference between revisions
Content added Content deleted
(Added C#) |
m (added whitespace to the task's preamble, added "corner" glyphs to the matrices, centered one of the "times" symbol.) |
||
Line 9: | Line 9: | ||
;Test cases: |
;Test cases: |
||
Show results for each of the following two samples:<br> |
Show results for each of the following two samples:<br> |
||
Sample 1 (from Wikipedia): |
Sample 1 (from Wikipedia): |
||
<pre> |
<pre> |
||
┌ ┐ ┌ ┐ ┌ ┐ |
|||
│1 2│ x │0 5│ = │ 0 5 0 10│ |
|||
│1 2│ x │0 5│ = │ 0 5 0 10│ |
|||
│3 4│ │6 7│ │ 6 7 12 14│ |
|||
└ ┘ └ ┘ │ 0 15 0 20│ |
|||
│18 21 24 28│ |
|||
└ ┘ |
|||
</pre> |
</pre> |
||
Sample 2: |
Sample 2: |
||
<pre> |
<pre> |
||
┌ ┐ ┌ ┐ ┌ ┐ |
|||
⚫ | |||
│0 1 0│ │1 1 1 1│ = │0 0 0 0 1 1 1 1 0 0 0 0│ |
|||
│1 1 1│ x │1 0 0 1│ │0 0 0 0 1 0 0 1 0 0 0 0│ |
|||
│0 1 0│ │1 1 1 1│ │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│ |
||
│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 |
│0 0 0 0 1 1 1 1 0 0 0 0│ |
||
│0 0 0 0 1 |
│0 0 0 0 1 0 0 1 0 0 0 0│ |
||
⚫ | |||
└ ┘ |
|||
</pre> |
</pre> |
||
See implementations and results below in JavaScript and PARI/GP languages. |
See implementations and results below in JavaScript and PARI/GP languages. |
||