Java Utililty Methods Array Interpolate

List of utility methods to do Array Interpolate

Description

The list of methods to do Array Interpolate are organized into topic(s).

Method

doubleinterpolate(int[] data, double x)
Returns the value of specified decimal index.
if (data.length == 0)
    return 0;
if (x > data.length - 1)
    return data[data.length];
if (x < 0)
    return data[0];
int dx = (int) x;
return data[dx] + (data[dx + 1] - (double) data[dx]) * (x - dx);
...
double[]interpolate_linear(int[] x, double[] y, int[] xi)
interpolatlinear
assert (x.length == y.length);
double[] yi = new double[xi.length];
int i, j;
boolean bFound;
double alpha;
for (i = 0; i < xi.length; i++) {
    bFound = false;
    for (j = 0; j < x.length - 1; j++) {
...
int[]interpolateArray(int[] array, int interval)
interpolate Array
int newSize = array.length / interval;
int[] list = new int[newSize];
for (int i = 0; i < newSize; i++) {
    int index = i * interval;
    list[i] = array[index];
return list;
voidinterpolateColor(float[] result, float[] color0, float[] color1, double s)
Computes (1-s) color0 + s color1 and places the result in result.
float a = (float) (1 - s);
float b = (float) (s);
result[0] = a * color0[0] + b * color1[0];
result[1] = a * color0[1] + b * color1[1];
result[2] = a * color0[2] + b * color1[2];
int[]interpolateLinear(int[] v1, int[] v2, double t)
interpolate Linear
int[] result = new int[v1.length];
for (int i = 0; i < result.length; i++) {
    result[i] = (int) Math.round(v2[i] * t + v1[i] * (1 - t));
return result;
int[]interpolateLinear(int[] vec, int start, int end)
Given an array of integers, compute a series of integers as a linear interpolation between two values.
double step;
int length = vec.length;
int ret[] = new int[vec.length];
if (start < end) {
    step = (double) (end - start) / (double) length;
    for (int i = 0; i < length; i++) {
        if (vec[i] != 0) {
            ret[i] = start + (int) (i * step);
...
double[]interpolateNonZeroValues(double[] contour)
To interpolate Zero values with respect to NonZero values
for (int i = 0; i < contour.length; i++) {
    if (contour[i] == 0) {
        int index = findNextIndexNonZero(contour, i);
        if (index == -1) {
            for (int j = (i == 0 ? 1 : i); j < contour.length; j++) {
                contour[j] = contour[j - 1];
            break;
...