Java Array Intersect arrayInterp(double[] inputArray, double index)

Here you can find the source of arrayInterp(double[] inputArray, double index)

Description

array Interp

License

Open Source License

Declaration

public static double arrayInterp(double[] inputArray, double index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double arrayInterp(double[] inputArray, double index) {
        int cap = inputArray.length - 1;
        if (index <= 0) {
            return inputArray[0];
        } else if (index >= cap) {
            return inputArray[cap];
        } else {//from w  ww  .  j av a2  s.co  m
            int first = (int) Math.floor(index);
            double offset = index - first;
            return offset * inputArray[first + 1] + (1 - offset) * inputArray[first];
        }
    }
}

Related

  1. arraysIntersect(Object[] array1, Object[] array2)
  2. byteIntersection(byte[] a, byte[] b)
  3. getArrayIntersection(int a[], int b[])
  4. getNonIntersection(int[] interval, int[] intervalToRemove)