filterarray, convolve, and correlate perform filtering, and compute the convolution, and correlation respectively, of arrays of real.
filterarray
filterarray really performs a convolution and is adapted to applying as a kernel an array of real of small size nr to a array of real with a larger size ns. The resulting array of real's size is ns - nr + 1.
(filterarray {1, 2, 2, 2, 3, 1, 2, 2, 2, 3} using {-1, 2, -1}) as list of real
-- {1.0, 0.0, -1.0, 3.0, -3.0, 1.0, 0.0, -1.0}
convolve
Returns the convolution of two arrays of real with the same size n. If you provide two arrays of real of different sizes, the missing values in the smaller are considered 0. The resulting array of real's size is 2 * n - 1.
The optional boolean parameter circular (default: true) specifies that the data are periodic. If circular is set to true, the resulting array of real's size is n.
set a to {1, 2, 3} as array of real
set b to {0, 1, 2} as array of real
(convolve a by b without circular) as list of real
-- {0.0, 1.0, 4.0, 7.0, 6.0}
correlate
Like convolve, but returns the cross-correlation of the two arrays of real.
set a to {1, 2, 3} as array of real
(correlate a to a without circular) as list of real
-- {-0.375, 0.25, 1.0, 0.25, -0.375}
|