using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskExamples
{
    class Example24
    {
        static float[] ParallelConvolution(float[] input, float[] kernel)
        {
            float[] output = new float[input.Length];
            Parallel.For(0, input.Length, i =>
            {
                float total = 0;
                for (int k = 0; k < Math.Min(kernel.Length, i + 1); ++k)
                {
                    total += input[i - k] * kernel[k];
                }
                output[i] = total;
            });

            return output;
        }
    }
}
