public class Convolution {
public static void main(String[] args) {
// TODO Auto-generated method stub
int [] x_data = new int [300];
for (int i = 0; i < x_data.length; ++i) {
x_data[i] = (int)(10 * Math.random() + 1);
}
int [] w = new int[] {2, 1, 3, 5,};
int [] reversed_w = new int[w.length];
int head = 0;
for(int i = w.length - 1; i >= 0; --i) {
reversed_w[head] = w[i];
++head;
}
int convolution_data_size = x_data.length - reversed_w.length + 1;
int[] convolution_data = new int[convolution_data_size];
for(int i = 0; i < convolution_data_size; ++i) {
int multiply_value = 0;
head = i;
for (int j = 0; j < reversed_w.length; ++j) {
multiply_value += x_data[head] * reversed_w[j];
++head;
}
convolution_data[i] = multiply_value;
}
for (int i : convolution_data) {
System.out.printf("%s \t", i);
}
}
}