public static double[] interpolations(double[] x, double[] y, double[] z) {
double[] interV = new double[z.length];
UnivariateInterpolator interpolator = new LinearInterpolator();
UnivariateFunction function = interpolator.interpolate(x, y);
for (int i = 0; i < z.length; i++) {
interV[i] = function.value(z[i]);
}
return interV;
}
public static void (String[] args) {
double[] x = new double[] {1, 3, 5, 7, 9};
double[] y = new double[] {0.1, 0.5, 2.2, 1.2, 3.1};
double[] z = new double[] {2, 4, 6, 8};
double[] v = interpolations(x, y, z);
System.out.println(Arrays.toString(v));
}
近期评论