Deconvolution/2D+: Difference between revisions
m
→{{header|Phix}}
(Added Go) |
|||
Line 1,012:
Quite frankly I'm fairly astonished that it actually works...<br>
(be warned this contains an exciting mix of 0- and 1- based indexes)
<lang Phix>
function m_size(sequence m)
--
-- returns the size of a matrix as a list of lengths
Line 1,176 ⟶ 1,178:
end function
constant
g1
h1
g = {{{ 54, 42, 53, -42, 85, -72},▼
if deconvolve(g1, f1)!=h1 then ?9/0 end if
{ 45, -170, 94, -36, 48, 73},▼
if deconvolve(g1, h1)!=f1 then ?9/0 end if
{-39, 65, -112, -16, -78, -72},▼
{ 6, -11, -6, 62, 49, 8}},▼
constant f2
{
{
{
g2 = {{ 40,
{-
{
{
{
{-
{ 48, -6, 21,
h2 = {{-8, 1,-7,-2,-9, 4},
{ 4, 5,-5, 2, 7,-1},
{-6,-3,-3,-6, 9, 5}}
if deconvolve(g2, f2)!=h2 then ?9/0 end if
if deconvolve(g2, h2)!=f2 then ?9/0 end if
constant f3 = {{{-9, 5, -8}, { 3, 5, 1}},
{{-1, -7, 2}, {-5, -6, 6}},
{{ 8, 5, 8}, {-2, -6, -4}}},
{{-57, 49, -23, 52,-135, 66},
{-23, 127, -58, -5,-118, 64},
{ 87, -16, 121, 23, -41, -12},
{-19, 29, 35,-148, -11, 45}},
{{-55,-147,-146, -31, 55, 60},
{-88, -45, -28, 46, -26,-144},
{-12,-107, -34, 150, 249, 66},
{ 11, -15, -34, 27, -78, -50}},
{{ 56, 67, 108, 4, 2, -48},
{ 58, 67, 89, 32, 32, -8},
{-42, -31,-103, -30, -23, -8},
{ 6, 4, -26, -10, 26, 12}}},
h3 = {{{ -6, -8, -5, 9},
{ -7, 9, -6, -8},
{ 2, -7, 9, 8}},
{{ 7, 4, 4, -6},
{ 9, 9, 4, -4},
{ -3, 7, -2, -3}}}
if deconvolve(g3, f3)!=h3 then ?9/0 end if
if deconvolve(g3, h3)!=f3 then ?9/0 end if
ppOpt({pp_Nest,2,pp_IntFmt,"%3d"})
pp(deconvolve(
pp(deconvolve(g3, h3))</lang>
{{out}}
<pre>
Line 1,206 ⟶ 1,244:
{ 9, 9, 4, -4},
{ -3, 7, -2, -3}}}
{{{ -9, 5, -8},
{ 3, 5, 1}},
{{ -1, -7, 2},
{ -5, -6, 6}},
{{ 8, 5, 8},
{ -2, -6, -4}}}
</pre>
The version shipped in demo\rosetta contains the full 5 test sets: note that 5D takes a minute or two to complete.
=={{header|Tcl}}==
|