Kronecker product: Difference between revisions
Content added Content deleted
(-- just product --) |
|||
Line 1,336: | Line 1,336: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
<lang lua> |
<lang lua> |
||
function mxn( a, b ) |
|||
print( "A x B:" ) |
|||
for m = 1, #a do |
|||
for p = 1, #b do |
|||
for n = 1, #a[m] do |
|||
for q = 1, #b[p] do |
|||
io.write( string.format( "[%d x %d] ", a[m][n], b[p][q] ) ) |
|||
end |
|||
end |
|||
print() |
|||
end |
|||
end |
|||
end |
|||
function prod( a, b ) |
function prod( a, b ) |
||
print( "\nPRODUCT:" ) |
print( "\nPRODUCT:" ) |
||
Line 1,356: | Line 1,343: | ||
for q = 1, #b[p] do |
for q = 1, #b[p] do |
||
io.write( string.format( "%3d ", a[m][n] * b[p][q] ) ) |
io.write( string.format( "%3d ", a[m][n] * b[p][q] ) ) |
||
end |
|||
end |
|||
print() |
|||
end |
|||
end |
|||
end |
|||
function aabb( a, b ) |
|||
print( "\nAROW,ACOL x BROW,BCOL:" ) |
|||
for m = 1, #a do |
|||
for p = 1, #b do |
|||
for n = 1, #a[m] do |
|||
for q = 1, #b[p] do |
|||
io.write( string.format( "[(%d, %d) x (%d, %d)] ", m, n, p, q ) ) |
|||
end |
end |
||
end |
end |