The convolution of two functions and of
an integer variable is defined as the function
satisfying
:
for all integers . Assume can be non-zero only for ≤ ≤ , where is the "length" of , and similarly for and , so that the functions can be modeled as finite sequences by identifying with , etc.
Then for example, values of and would determine the following value of by definition.
:
We can write this in matrix form as:
:
or
:
For this task, implement a function (or method, procedure, subroutine, etc.) deconv to perform ''deconvolution'' (i.e., the ''inverse'' of convolution) by constructing and solving such a system of equations represented by the above matrix for given and .
* The function should work for of arbitrary length (i.e., not hard coded or constant) and of any length up to that of . Note that will be given by .
* There may be more equations than unknowns. If convenient, use a function from a [http://www.netlib.org/lapack/lug/node27.html library] that finds the best fitting solution to an overdetermined system of linear equations (as in the [[Multiple regression]] task). Otherwise, prune the set of equations as needed and solve as in the [[Reduced row echelon form]] task.
* Test your solution on the following data. Be sure to verify both that deconv and deconv and display the results in a human readable form.
h = [-8,-9,-3,-1,-6,7]
f = [-3,-6,-1,8,-6,3,-1,-9,-9,3,-2,5,2,-2,-7,-1]
g = [24,75,71,-34,3,22,-45,23,245,25,52,25,-67,-96,96,31,55,36,29,-43,-7]