Deconvolution/2D+: Difference between revisions

m
(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)demo\rosetta\Deconvolution.exw
 
function m_size(sequence m)
--
-- returns the size of a matrix as a list of lengths
Line 1,176 ⟶ 1,178:
end function
 
constant ff1 = {{{-9, 56, -8}9, { 3-7, -5, 1}},
g1 = {{-148, 84, -716, 95, 2}125, {-570, -67, 29, 54, 6}10},
h1 = {{ -8, 52, 8}-9, {-2, 9, -68, -42}}},
 
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 = {{-575, 492, -232, 52-6, -1357}, 66},
{-23 9, 1277, -586, -5, -1187}, 64},
{ 871, -161, 1219, 232, -417}, -12},
{-19, 295, 359, -1489, 2,-115}, 45}},
{ {-558, -1475, -1462, -318, 55, 605}},
g2 = {{ 40, {-8821, 53, -45 42, 105, -28 1, 87, 4660, -2639, -14428},
{-1292, -10764, 19,-167, -3471, -47, 150128,-109, 24940, 66-21},
{ 1158, 85,-1593, 37, 101, -3414, 275, 37, -7876, -50}56},
{{-90,-135, 5660,-125, 6768, 10853, 223, 4, 2-36, -48},
{ 5878, 6716, 7,-199, 89156,-162, 3229, 3228,-103, -810},
{-4262, -3189, 69, -10361, -3066, 193, -2361, 71, -8, -30},
{ 48, -6, 21, 4-9,-150, -2622, -1056, 2632, 85, 12} 25}},
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}}},
gg3 = {{{ 54, 42, 53, -42, 85, -72},
{ 45, -170, 94, -36, 48, 73},
{-39, 65, -112, -16, -78, -72},
{ 6, -11, -6, 62, 49, 8}},
{{-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(gg3, ff3))</lang>
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}}==
7,805

edits