Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { public static double[] triangleKernel(int length, int size) { if (size <= 0) { return null; } double[] triangleKernel = new double[length]; Arrays.fill(triangleKernel, 0); triangleKernel[0] = 1; for (int i = 1; i <= size; i++) { triangleKernel[length - i] = 1 - (double) i / (double) size; triangleKernel[i] = 1 - (double) i / (double) size; } return triangleKernel; } }