1-D Gaussian kernel.

@param size Kernel size (should be odd), [3, 101].
@return Returns 1-D Gaussian kernel of the specified size.
439229
public double[] Kernel1D(int size) {
        if (((size % 2) == 0) || (size < 3) || (size > 101)) {
            try {
                throw new Exception("Wrong size");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        int r = size / 2;
        // kernel
        double[] kernel = new double[size];

        // compute kernel
        for (int x = -r, i = 0; i < size; x++, i++) {
            kernel[i] = Function1D(x);
        }

        return kernel;
    }
327027
public static AreaI area(final AreaSizeI size)
  {
    Objects.requireNonNull(size, "Size");
    return AreaI.of(0, size.sizeX(), 0, size.sizeY());
  }
540386
public static LongTuple zero(int size)
    {
        if (size >= 0 && size < ZERO_POOL_SIZE)
        {
            return ZEROS[size];
        }
        return createZero(size);
    }
925695
public static ImmutableMatrix identity(final int size) {
		if (size <= 0) throw new IllegalArgumentException("Invalid size");
		return create(new ImmutableData(size, size) {
			@Override
			public double getQuick(int row, int col) {
				return row == col ? 1 : 0;
			}
		});
	}
219029
public static <K, V> HashMap<K, V> newHashMap(int size) {
		return newHashMap(size, false);
	}
936819
public static String getApproximateSize(long size) {
		if(size==1) return "1 byte";
		if(size<1024) return new StringBuilder().append((int)size).append(" bytes").toString();
		String unitName;
		long unitSize;
		if(size<(1024*1024)) {
			unitName=" k";
			unitSize=1024;
		} else if(size<((long)1024*1024*1024)) {
			unitName=" M";
			unitSize=1024*1024;
		} else if(size<((long)1024*1024*1024*1024)) {
			unitName=" G";
			unitSize=(long)1024*1024*1024;
		} else {
			unitName=" T";
			unitSize=(long)1024*1024*1024*1024;
		}
		long whole=size/unitSize;
		if(whole<100) {
			int fraction=(int)(((size%unitSize)*10)/unitSize);
			return new StringBuilder().append(whole).append('.').append(fraction).append(unitName).toString();
		} else return new StringBuilder().append(whole).append(unitName).toString();
	}
1107637
public long getFirst(long size)
    {
        if (first<0)
        {
            long tf=size-last;
            if (tf<0)
                tf=0;
            return tf;
        }
        return first;
    }
19358
public int alloc(int size) {
        int index = n;
        int len = array.length;
        if (n + size >= len) {
            byte[] aux = new byte[len + blockSize];
            System.arraycopy(array, 0, aux, 0, len);
            array = aux;
        }
        n += size;
        return index;
    }
1348573
public static ByteBuffer sliceAndSkip(ByteBuffer buffer, int size) {
        ByteBuffer buf = buffer.slice().order(ByteOrder.LITTLE_ENDIAN);
        ByteBuffer slice = (ByteBuffer) ((Buffer) buf).limit(buf.position() + size);
        skip(buffer, size);
        return slice;
    }
1158312
private static void compute(Kernel kernel, int[] in, int[] out, int width, int height, boolean alpha, int edge)
    {
        final float[] matrix = kernel.getMatrix();
        final int cols = kernel.getWidth();
        final int cols2 = cols / 2;

        for (int y = 0; y < height; y++)
        {
            int index = y;
            final int ioffset = y * width;
            for (int x = 0; x < width; x++)
            {
                compute(matrix, in, out, x, index, ioffset, cols2, width, alpha, edge);
                index += height;
            }
        }
    }
1304838
private static Kernel createKernel(float radius, int width, int height)
    {
        final int r = (int) Math.ceil(radius);
        final int rows = r * 2 + 1;
        final float[] matrix = new float[rows];
        final float sigma = radius / 3;
        final float sigma22 = 2 * sigma * sigma;
        final float sigmaPi2 = (float) (2 * Math.PI * sigma);
        final float sqrtSigmaPi2 = (float) Math.sqrt(sigmaPi2);
        final float radius2 = radius * radius;
        float total = 0.0F;
        int index = 0;

        for (int row = -r; row <= r; row++)
        {
            final float distance = row * (float) row;
            if (distance > radius2)
            {
                matrix[index] = 0;
            }
            else
            {
                matrix[index] = (float) Math.exp(-distance / sigma22) / sqrtSigmaPi2;
            }
            total += matrix[index];
            index++;
        }
        for (int i = 0; i < rows; i++)
        {
            matrix[i] /= total;
        }

        final float[] data = new float[width * height];
        System.arraycopy(matrix, 0, data, 0, rows);

        return new Kernel(rows, data);
    }
1025943
public static List<Integer> getRandomIntegers(final int start, final int end, final int size) {
        if (size > (end - start + 1)) {
            throw new IllegalArgumentException("The specified size more then (end - start + 1)!");
        }

        final List<Integer> integers = genIntegers(start, end);
        final List<Integer> ret = new ArrayList<Integer>();

        int remainsSize;
        int index;

        while (ret.size() < size) {
            remainsSize = integers.size();
            index = (int) (Math.random() * (remainsSize - 1));
            final Integer i = integers.get(index);

            ret.add(i);
            integers.remove(i);
        }

        return ret;
    }
1120572
public static <E> Matcher<Iterable<E>> hasSize(final int size) {
        checkArgument(size >= 0, "Size cannot be negative");

        return new IsIterableWithSize(size);
    }
565089
private static float[][] generateGaussianBlurKernels(int level) {
		float[][] pascalsTriangle = generatePascalsTriangle(level);
		float[][] gaussianTriangle = new float[pascalsTriangle.length][];
		for (int i = 0; i < gaussianTriangle.length; i++) {
			float total = 0.0f;
			gaussianTriangle[i] = new float[pascalsTriangle[i].length];
			for (int j = 0; j < pascalsTriangle[i].length; j++)
				total += pascalsTriangle[i][j];
			float coefficient = 1 / total;
			for (int j = 0; j < pascalsTriangle[i].length; j++)
				gaussianTriangle[i][j] = coefficient * pascalsTriangle[i][j];
		}
		return gaussianTriangle;
	}

	/**
	 * Generate Pascal's triangle
	 * 
	 * @param level The level of the triangle to generate
	 * @return The Pascal's triangle kernel
	 */
	private static float[][] generatePascalsTriangle(int level) {
		if (level < 2) level = 2;
		float[][] triangle = new float[level][];
		triangle[0] = new float[1];
		triangle[1] = new float[2];
		triangle[0][0] = 1.0f;
		triangle[1][0] = 1.0f;
		triangle[1][1] = 1.0f;
		for (int i = 2; i < level; i++) {
			triangle[i] = new float[i + 1];
			triangle[i][0] = 1.0f;
			triangle[i][i] = 1.0f;
			for (int j = 1; j < triangle[i].length - 1; j++)
				triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
		}
		return triangle;
	}
}
524188
def blk_coverage_1d(blk, size):
    
    rem = size % blk
    maxpix = size - rem
    return maxpix, rem
385785
List<String> argNames(int size) {
        List<String> argNames = new ArrayList<>();
        for (int i = 0 ; i < size ; i++) {
            argNames.add(StubKind.FACTORY_METHOD_ARG.format(i));
        }
        return argNames;
    }
656500
public static AreaL area(final AreaSizeL size)
  {
    Objects.requireNonNull(size, "Size");
    return AreaL.of(0L, size.sizeX(), 0L, size.sizeY());
  }