convolution function

Float64List convolution(
  1. List<double> a,
  2. List<double> b
)

Returns the linear convolution of real arrays a and b.

a and b will be zero padded until they're the same length, and the resulting array will also be this length.

Returns the result as a newly allocated Float64List, and doesn't modify the input arrays. Also allocates 2 Float64x2Lists along the way.

If your input arrays are very different lengths, a naive convolution may be faster than this FFT based algorithm.

Implementation

Float64List convolution(List<double> a, List<double> b) {
  final n = math.max(a.length, b.length);
  return Float64List.sublistView(circularConvolution(a, b, n << 1), 0, n);
}