Deconvolution/1D: Difference between revisions

m
{{out}}
(→‎{{header|Java}}: fixed error in deconv method where input parameters were reversed; changed array types from double[] to int[]; updated output; removed "untested" banner.)
m ({{out}})
Line 6:
:<math> G(n) = \sum_{m=-\infty}^{\infty} F(m) H(n-m) </math>
 
for all integers <math>\mathit{n}</math>. Assume <math>F(n)</math> can be non-zero only for <math>0</math> &le; <math>\mathit{n}</math> &le; <math>|\mathit{F}|</math>, where <math>|\mathit{F}|</math> is the "length" of <math>\mathit{F}</math>, and similarly for <math>\mathit{G}</math> and <math>\mathit{H}</math>, so that the functions can be modeled as finite sequences by identifying <math>f_0, f_1, f_2, \dots</math> with <math>F(0), F(1), F(2), \dots</math>, etc. Then for example, values of <math>|\mathit{F}| = 6</math> and <math>|\mathit{H}| = 5</math> would determine the following value of <math>\mathit{g}</math> by definition.
Then for example, values of <math>|\mathit{F}| = 6</math> and <math>|\mathit{H}| = 5</math> would determine the following value of <math>\mathit{g}</math> by definition.
 
:<math>
Line 120 ⟶ 121:
NEXT
= LEFT$(LEFT$(a$))</lang>
{{out}}
'''Output:'''
<pre>
deconv(g,f) = -8, -9, -3, -1, -6, 7
Line 219 ⟶ 220:
for (int i = 0; i < lh; i++) printf(" %g", h2[i]);
printf("\n");
}</lang>
{{out}}</lang>Output<langpre>f[] data is : -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1
deconv(g, h): -3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1
h[] data is : -8 -9 -3 -1 -6 7
deconv(g, f): -8 -9 -3 -1 -6 7</langpre>
 
=={{header|Common Lisp}}==
Line 424 ⟶ 426:
return h
}</lang>
{{out}}
Output:
<pre>
[-8 -9 -3 -1 -6 7]
Line 431 ⟶ 433:
[-3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1]
</pre>
 
{{trans|C}}
<lang go>package main
Line 585 ⟶ 588:
}
}</lang>
{{out}}
Output:
<pre>
h = [-8, -9, -3, -1, -6, 7]
Line 634 ⟶ 637:
deconv[f,g]
</pre>
{{out}}
Gives the output:
<pre>{-8, -9, -3, -1, -6, 7}</pre>
 
=={{header|MATLAB}}==
The deconvolution function is built-in to MATLAB as the "deconv(a,b)" function, where "a" and "b" are vectors storing the convolved function values and the values of one of the deconvoluted vectors of "a". To test that this operates according to the task spec we can test the criteria above:
To test that this operates according to the task spec we can test the criteria above:
<lang MATLAB>>> h = [-8,-9,-3,-1,-6,7];
>> g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7];
Line 741 ⟶ 745:
.say for ~@f, ~deconvolve(@g, @h),'';</lang>
 
{{out}}
Output:
<pre>
24 75 71 -34 3 22 -45 23 245 25 52 25 -67 -96 96 31 55 36 29 -43 -7
Line 907 ⟶ 911:
(deconvolve g h)
</lang>
{{out}}
Output:
<lang racket>
#<array '#(6 1) #[-8 -9 -3 -1 -6 7]>
Line 1,036 ⟶ 1,040:
pp "deconv(g,h) = f" [1D deconvolve $g $h]
pp " conv(f,h) = g" [1D convolve $f $h]</lang>
{{out}}
Output:
<pre>
deconv(g,f) = h = [-8,-9,-3,-1,-6,7]
Line 1,071 ⟶ 1,075:
'f': deconv(g,h)>
</lang>
{{out}}
output:
<pre>
<
Anonymous user