Remove completely unused classes

This commit is contained in:
Fabian Becker 2015-12-17 21:10:36 +01:00
parent ba9fc8fe89
commit 7615196d2b
9 changed files with 0 additions and 1018 deletions

View File

@ -4,9 +4,6 @@ import Jama.Matrix;
import eva2.optimization.tools.DoubleArrayComparator; import eva2.optimization.tools.DoubleArrayComparator;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.Pair; import eva2.tools.Pair;
import eva2.tools.math.interpolation.BasicDataSet;
import eva2.tools.math.interpolation.InterpolationException;
import eva2.tools.math.interpolation.SplineInterpolation;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -1099,29 +1096,6 @@ public final class Mathematics {
} }
} }
/**
* Computes a spline interpolation of the two point (x0,f0) and (x1,f1).
*
* @param x
* @param x0
* @param x1
* @param f0
* @param f1
* @return If an error with the spline occurs, a linear interpolation will
* be returned.
*/
public static double splineInterpolation(double x, double x0, double x1,
double f0, double f1) {
try {
double[] t = {x0, x1}, f = {f0, f1};
SplineInterpolation spline = new SplineInterpolation(
new BasicDataSet(t, f, 1));
return spline.getY(x);
} catch (InterpolationException e) {
e.printStackTrace();
}
return linearInterpolation(x, x0, x1, f0, f1);
}
/** /**
* This computes the submatrix of the given matrix as a result by scraching * This computes the submatrix of the given matrix as a result by scraching

View File

@ -1,23 +0,0 @@
package eva2.tools.math.interpolation;
/**
* The minimal set of functions which should implemented in a data modifier for
* <code>AbstractDataSet</code>.
*/
public abstract class AbstractDataModifier {
/**
* Modifies the X data.
*/
public abstract void modifyX(double[] setX);
/**
* Modifies the Y data.
*/
public abstract void modifyY(double[] setY);
/**
* Modifies the data.
*/
public abstract void modify(double[] setX, double[] setY);
}

View File

@ -1,84 +0,0 @@
package eva2.tools.math.interpolation;
public abstract class AbstractDataSet {
/**
* double array of X data.
*
* @see #yDoubleData
*/
protected double[] xDoubleData = {-1, 1};
/**
* double array of Y data.
*
* @see #xDoubleData
*/
protected double[] yDoubleData = {1, 1};
/**
* Returns the length of the data set
*
* @return the length of the data set
*/
public int getLength() {
return xDoubleData.length;
}
/**
* Returns an array of the X data
*
* @return the array of the X data
*/
public double[] getXData() {
return xDoubleData;
}
/**
* Returns an array of the Y data
*
* @return the array of the Y data
*/
public double[] getYData() {
return yDoubleData;
}
/**
* Returns the X label of the data set
*
* @return the X label of the data set
*/
public abstract String getXLabel();
/**
* Returns the Y label of the data set
*
* @return the Y label of the data set
*/
public abstract String getYLabel();
/**
* Modifies the X data.
*
* @param modifier the data modifier
*/
public void modifyXData(AbstractDataModifier modifier) {
modifier.modifyX(xDoubleData);
}
/**
* Modifies the Y data.
*
* @param modifier the data modifier
*/
public void modifyYData(AbstractDataModifier modifier) {
modifier.modifyY(yDoubleData);
}
/**
* Modifies the data.
*
* @param modifier the data modifier
*/
public void modifyData(AbstractDataModifier modifier) {
modifier.modify(xDoubleData, yDoubleData);
}
}

View File

@ -1,50 +0,0 @@
package eva2.tools.math.interpolation;
/**
* The minimum wrapper class for an <code>AbstractDataSet</code>.
*/
public class BasicDataSet extends AbstractDataSet {
protected int dataType = -1;
protected String xLabel = null;
protected String yLabel = null;
public BasicDataSet() {
this(null, null, null, null);
}
public BasicDataSet(
double[] xDoubleData,
double[] yDoubleData,
int dataType) {
this(xDoubleData, yDoubleData, null, null);
}
public BasicDataSet(
double[] xDoubleData,
double[] yDoubleData,
String xLabel,
String yLabel) {
this.xDoubleData = xDoubleData;
this.yDoubleData = yDoubleData;
this.xLabel = xLabel;
this.yLabel = yLabel;
}
public int getDataType() {
return dataType;
}
@Override
public String getXLabel() {
return xLabel;
}
@Override
public String getYLabel() {
return yLabel;
}
public String getAdditionalInformation(String parm1) {
return "";
}
}

View File

@ -1,14 +0,0 @@
package eva2.tools.math.interpolation;
/**
* Exception for interpolation error.
*/
public class InterpolationException extends Exception {
public InterpolationException() {
super();
}
public InterpolationException(String s) {
super(s);
}
}

View File

@ -1,522 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Filename: $RCSfile: LinearInterpolation.java,v $
// Purpose: Some interpolation stuff.
// Language: Java
// Compiler: JDK 1.4
// Authors: Joerg K. Wegner
// Original author: Charles S. Stanton
// Version: $Revision: 1.1 $
// $Date: 2003/07/22 19:25:23 $
// $Author: wegnerj $
//
// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
//
///////////////////////////////////////////////////////////////////////////////
package eva2.tools.math.interpolation;
/**
* Defines the routines for the spline interpolation of data.
*/
public class LinearInterpolation {
AbstractDataSet abstractDataSet = null;
private double[] x, y;
//vectors of x,y
private double sumX = 0;
private double sumY = 0;
private double sumXY = 0;
private double sumXsquared = 0;
private double sumYsquared = 0;
private double Sxx, Sxy, Syy, n;
private double a = 0, b = 0;
//coefficients of regression
private int dataLength;
private double[][] residual;
// residual[0][i] = x[i], residual[1][i]= residual
private double maxAbsoluteResidual = 0.0;
private double SSR = 0.0;
//regression sum of squares
private double SSE = 0.0;
//error sum of squares
private double minX = Double.POSITIVE_INFINITY;
private double maxX = Double.NEGATIVE_INFINITY;
private double minY = Double.POSITIVE_INFINITY;
private double maxY = Double.NEGATIVE_INFINITY;
//MISC
String xName, yName;
double aCILower, aCIUpper, bCILower, bCIUpper; //confidence interval
double t, bSE, aSE;
double MSE, F;
static double[] t025 =
{
Double.NaN,
12.706,
4.303,
3.182,
2.776,
2.571,
2.447,
2.365,
2.306,
2.262,
2.228,
2.201,
2.179,
2.160,
2.145,
2.131,
2.120,
2.110,
2.101,
2.093,
2.086,
2.080,
2.075,
2.069,
2.064,
2.060,
2.056,
2.052,
2.048,
2.045,
1.960};
/*------------------------------------------------------------------------*
* constructor
*------------------------------------------------------------------------*/
/**
* Initializes this class.
*/
public LinearInterpolation() throws InterpolationException {
this.abstractDataSet = null;
}
/**
* Constructor for regression calculator.
*
* @param x is the array of x data
* @param y is the array of y data
*/
public LinearInterpolation(double[] x, double[] y) {
this.x = x;
this.y = y;
if (x.length != y.length) {
System.out.println("x, y vectors must be of same length");
} else {
dataLength = x.length;
doStatistics();
}
}
/**
* Initializes this class and calculates the second derivative of the spline.
*
* @param abstractDataSet the <code>AbstractDataSet</code>
*/
public LinearInterpolation(AbstractDataSet abstractDataSet)
throws InterpolationException {
this.setAbstractDataSet(abstractDataSet);
}
public void setAbstractDataSet(AbstractDataSet abstractDataSet)
throws InterpolationException {
this.abstractDataSet = abstractDataSet;
x = abstractDataSet.getXData();
y = abstractDataSet.getYData();
if (x.length != y.length) {
System.out.println("x, y vectors must be of same length");
} else {
dataLength = x.length;
doStatistics();
}
}
/**
* Find the p value for a given value of F.
* Requires the COLT high performance library:
* http://hoschek.home.cern.ch/hoschek/colt/
*
* @param fValue the value for the CDF
* @return The P value
*/
// public double getP(double fValue) {
// double answer;
// double y1;
// double y2;
// //nu1 = 1;
// //x2 =1
// double nu2 = n - 2;
// y1 = nu2 / (nu2 + fValue);
// y2 = 0.0;
// answer = Gamma.incompleteBeta(nu2 / 2.0, 1 / 2.0, y1)
// - Gamma.incompleteBeta(nu2 / 2.0, 1 / 2.0, y2);
// return answer;
// }
/*
* Here are the accessor methods
*
*/
/**
* Gets the intercept of the regression line.
*
* @return The intercept.
*/
public double getIntercept() {
return a;
}
/**
* Gets the Slope of the regression line.
*
* @return The slope.
*/
public double getSlope() {
return b;
}
/**
* Gets the residuals of the regression.
*
* @return The residuals.
*/
public double[][] getResiduals() {
return residual;
}
/**
* Gets the x data for the regression.
*
* @return The array of x values.
*/
public double[] getDataX() {
return x;
}
/**
* Gets the y data for the regression.
*
* @return The array of y values.
*/
public double[] getDataY() {
return y;
}
/**
* Gets the minimum of the x values.
*
* @return The minimum.
*/
public double getMinX() {
return minX;
}
/**
* Gets the maximum of the x values.
*
* @return The maximum.
*/
public double getMaxX() {
return maxX;
}
/**
* Gets the minimum of the y values.
*
* @return The minumum.
*/
public double getMinY() {
return minY;
}
/**
* Gets the maximum of the y values.
*
* @return The maximum.
*/
public double getMaxY() {
return maxY;
}
/**
* Gets the maximum absolute residual.
*
* @return The maximum.
*/
public double getMaxAbsoluteResidual() {
return maxAbsoluteResidual;
}
/**
* Gets the sum of the square x deviations from mean of x.
*
* @return The Sxx value
*/
public double getSxx() {
return Sxx;
}
/**
* Gets the sum of the square y deviations from mean of y.
*
* @return The Syy value
*/
public double getSyy() {
return Syy;
}
/**
* Gets SSR = Sxy * Sxy / Sxx;
*
* @return The SSR value
*/
public double getSSR() {
return SSR;
}
/**
* Gets SSE = Syy - SSR.
*
* @return The SSE value
*/
public double getSSE() {
return SSE;
}
/**
* Gets the mean square error MSE.
*
* @return The MSE value
*/
public double getMSE() {
return SSE / (n - 2);
}
/**
* Gets the mean XBar of x.
*
* @return The XBar value
*/
public double getXBar() {
return sumX / n;
}
/**
* Gets the mean YBar of y.
*
* @return The YBar value
*/
public double getYBar() {
return sumY / n;
}
/**
* Gets the sample size.
*
* @return The sample size.
*/
public int getDataLength() {
return x.length;
}
/**
* Gets the Pearson R statistic of the regression.
*
* @return The PearsonR value
*/
public double getPearsonR() {
return Sxy / Math.sqrt(Sxx * Syy);
}
/**
* Gets the sum of the x squared values.
*
* @return The sum of the x squared values.
*/
public double getSumXSquared() {
return sumXsquared;
}
/**
* reset data to 0
*/
public void reset() {
x = new double[0];
y = new double[0];
dataLength = 0;
n = 0.0;
residual = new double[0][0];
sumX = 0;
sumXsquared = 0;
sumY = 0;
sumYsquared = 0;
sumXY = 0;
}
/**
* Adds a new point to the regression (for interactive use).
*
* @param xValue The new x value
* @param yValue The new y value
*/
public void addPoint(double xValue, double yValue) {
dataLength++;
double[] xNew = new double[dataLength];
double[] yNew = new double[dataLength];
System.arraycopy(x, 0, xNew, 0, dataLength - 1);
System.arraycopy(y, 0, yNew, 0, dataLength - 1);
xNew[dataLength - 1] = xValue;
yNew[dataLength - 1] = yValue;
x = xNew;
y = yNew;
updateStatistics(xValue, yValue);
}
private void doStatistics() {
//Find sum of squares for x,y and sum of xy
for (int i = 0; i < dataLength; i++) {
minX = Math.min(minX, x[i]);
maxX = Math.max(maxX, x[i]);
minY = Math.min(minY, y[i]);
maxY = Math.max(maxY, y[i]);
sumX += x[i];
sumY += y[i];
sumXsquared += x[i] * x[i];
sumYsquared += y[i] * y[i];
sumXY += x[i] * y[i];
}
//Caculate regression coefficients
n = (double) dataLength;
Sxx = sumXsquared - sumX * sumX / n;
Syy = sumYsquared - sumY * sumY / n;
Sxy = sumXY - sumX * sumY / n;
b = Sxy / Sxx;
a = (sumY - b * sumX) / n;
SSR = Sxy * Sxy / Sxx;
SSE = Syy - SSR;
calculateResiduals();
}
private void calculateResiduals() {
residual = new double[2][dataLength];
maxAbsoluteResidual = 0.0;
for (int i = 0; i < dataLength; i++) {
residual[0][i] = x[i];
residual[1][i] = y[i] - (a + b * x[i]);
maxAbsoluteResidual =
Math.max(maxAbsoluteResidual, Math.abs(y[i] - (a + b * x[i])));
}
}
//update statistics for a single additional data point
private void updateStatistics(double xValue, double yValue) {
//Find sum of squares for x,y and sum of xy
n++;
sumX += xValue;
sumY += yValue;
sumXsquared += xValue * xValue;
sumYsquared += yValue * yValue;
sumXY += xValue * yValue;
//Caculate regression coefficients
n = (double) dataLength;
Sxx = sumXsquared - sumX * sumX / n;
Syy = sumYsquared - sumY * sumY / n;
Sxy = sumXY - sumX * sumY / n;
b = Sxy / Sxx;
a = (sumY - b * sumX) / n;
SSR = Sxy * Sxy / Sxx;
SSE = Syy - SSR;
calculateResiduals();
}
/**
* regression line y = a + bx.
*
* @param x
* @return double
* @throws InterpolationException
*/
public double getY(double x) throws InterpolationException {
return a + b * x;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(1000);
sb.append("Regression Statistics for " + yName + " = a + b*" + xName);
sb.append("");
sb.append("Sample Statistics");
int n = this.getDataLength();
sb.append("Sample size n = " + n);
sb.append("Mean of " + yName + " Y bar = " + this.getYBar());
sb.append("s_Y");
sb.append("= " + Math.sqrt(this.getSyy() / ((float) (n - 1))));
sb.append("Pearson correlation R = " + this.getPearsonR());
sb.append("");
sb.append("Coefficient Estimates");
a = this.getIntercept();
b = this.getSlope();
sb.append("a = " + a);
sb.append("b = " + b);
sb.append("");
sb.append("95% Confidence Intervals");
if (n > 32) {
t = t025[30];
} else if (n > 2) {
t = t025[n - 2];
} else {
t = Double.NaN;
}
MSE = this.getMSE();
if (n > 2) {
bSE = Math.sqrt(MSE / this.getSxx());
} else {
bSE = Double.NaN;
}
aSE = bSE * Math.sqrt(this.getSumXSquared() / n);
aCILower = a - t * aSE;
aCIUpper = a + t * aSE;
sb.append("a : (" + aCILower + ", " + aCIUpper + ")");
bCILower = b - t * bSE;
bCIUpper = b + t * bSE;
sb.append("b : (" + bCILower + ", " + bCIUpper + ")");
sb.append("");
sb.append("Analysis of Variance");
sb.append("Source Degrees Freedom Sum of Squares");
sb.append("");
SSR = this.getSSR();
//allow one degree of freedom for mean
sb.append(
"model 1 "
+ SSR);
sb.append(
"error "
+ (n - 2)
+ " "
+ this.getSSE());
sb.append(
"total(corrected) "
+ (n - 1)
+ " "
+ this.getSyy());
sb.append("");
sb.append("MSE =" + MSE);
F = SSR / MSE;
sb.append("F = " + F + " ");
//sb.append("p = " + this.getP(F));
return sb.toString();
}
}
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -1,53 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Filename: $RCSfile: PolynomialInterpolationResult.java,v $
// Purpose: Some interpolation stuff.
// Language: Java
// Compiler: JDK 1.4
// Authors: Joerg K. Wegner
// Version: $Revision: 1.1 $
// $Date: 2003/07/22 19:25:36 $
// $Author: wegnerj $
//
// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
//
///////////////////////////////////////////////////////////////////////////////
package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
* The result data for a polynomial interpolation.
*/
public class PolynomialInterpolationResult {
/*-------------------------------------------------------------------------*
* public member variables
*-------------------------------------------------------------------------*/
public double y = Double.NaN;
public double yError = Double.NaN;
/*------------------------------------------------------------------------*
* constructor
*------------------------------------------------------------------------*/
public PolynomialInterpolationResult() {
y = Double.NaN;
yError = Double.NaN;
}
public PolynomialInterpolationResult(double y, double yError) {
this.y = y;
this.yError = yError;
}
}
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -1,245 +0,0 @@
package eva2.tools.math.interpolation;
/**
* Defines the routines for the spline interpolation of data.
*/
public class SplineInterpolation {
AbstractDataSet abstractDataSet = null;
double[] secondDerivative = null;
double[] xArray = null;
double[] yArray = null;
boolean ascendingData = true;
/**
* Initializes this class.
*/
public SplineInterpolation() throws InterpolationException {
}
/**
* Initializes this class and calculates the second derivative of the spline.
*
* @param abstractDataSet the <code>AbstractDataSet</code>
*/
public SplineInterpolation(AbstractDataSet abstractDataSet)
throws InterpolationException {
this.setAbstractDataSet(abstractDataSet);
}
/**
* Sets the new <code>AbstractDataSet</code> and calculates the second
* derivative of the spline.
*
* @param abstractDataSet the <code>AbstractDataSet</code>
*/
public void setAbstractDataSet(AbstractDataSet abstractDataSet)
throws InterpolationException {
this.abstractDataSet = abstractDataSet;
double[] x = abstractDataSet.getXData();
double[] y = abstractDataSet.getYData();
boolean ascending = false;
int n = x.length;
xArray = new double[n];
yArray = new double[n];
xArray[n - 1] = x[0];
yArray[n - 1] = y[0];
for (int i = 0; i < n - 1; i++) {
xArray[i] = x[n - i - 1];
yArray[i] = y[n - i - 1];
if (x[i] < x[i + 1]) {
//if(descending)throw new InterpolationException("The x values must be"+
// " in continous ascending/descending order.");
ascending = true;
}
}
ascendingData = ascending;
if (ascendingData) {
xArray = abstractDataSet.getXData();
yArray = abstractDataSet.getYData();
}
this.secondDerivative =
spline(
xArray,
yArray,
(yArray[1] - yArray[0]) / (xArray[1] - xArray[0]),
(yArray[n - 1] - yArray[n - 2]) / (xArray[1] - xArray[n - 2]));
}
/**
* Uses the spline with the calculated second derivative values to calculate
* the <code>y</code> value. This algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery,
* "Numerical Recipes in C - The Art of Scientific Computing", Second Edition,
* Cambridge University Press,
* ISBN 0-521-43108-5,
* chapter 5, pages 173-176.</a><br>
*/
public double getY(double x) throws InterpolationException {
return splineInterpolation(xArray, yArray, secondDerivative, x);
}
public double getDerivative(double x) throws InterpolationException {
return splineInterpolatedDerivative(
xArray,
yArray,
secondDerivative,
x);
}
/**
* Calculates the second derivative of the data. It's important that the
* x<sub>i</sub> values of the function y<sub>i</sub>=f(x<sub>i</sub>) are
* in ascending order, as x<sub>0</sub>&lt;x<sub>1</sub>&lt;x<sub>2</sub>&lt;... .
* This algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery,
* "Numerical Recipes in C - The Art of Scientific Computing", Second Edition,
* Cambridge University Press,
* ISBN 0-521-43108-5,
* chapter 3, pages 113-116.</a><br>
*/
public double[] spline(double[] x, double[] y, double yp0, double ypn)
throws InterpolationException {
if (x[0] > x[1]) {
throw new InterpolationException(
"The x values must be" + " in ascending order.");
}
int n = x.length;
double[] y2 = new double[n];
double[] u = new double[n - 1];
int i, k;
double p, qn, sig, un;
if (yp0 > 0.99e30) {
y2[0] = u[0] = 0.0;
} else {
y2[0] = -0.5;
u[0] =
(3.0 / (x[1] - x[0])) * ((y[1] - y[0]) / (x[1] - x[0]) - yp0);
}
for (i = 2; i <= n - 1; i++) {
sig = (x[i - 1] - x[i - 2]) / (x[i] - x[i - 2]);
p = sig * y2[i - 2] + 2.0;
y2[i - 1] = (sig - 1.0) / p;
u[i - 1] =
(y[i] - y[i - 1]) / (x[i] - x[i - 1])
- (y[i - 1] - y[i - 2]) / (x[i - 1] - x[i - 2]);
u[i - 1] =
(6.0 * u[i - 1] / (x[i] - x[i - 2]) - sig * u[i - 2]) / p;
}
if (ypn > 0.99e30) {
qn = un = 0.0;
} else {
qn = 0.5;
un =
(3.0 / (x[n - 1] - x[n - 2]))
* (ypn - (y[n - 1] - y[n - 2]) / (x[n - 1] - x[n - 2]));
}
y2[n - 1] = (un - qn * u[n - 2]) / (qn * y2[n - 2] + 1.0);
for (k = n - 1; k >= 1; k--) {
y2[k - 1] = y2[k - 1] * y2[k] + u[k - 1];
}
return y2;
}
/**
* Calculates the second derivative of the data. This algorithm
* was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery,
* "Numerical Recipes in C - The Art of Scientific Computing", Second Edition,
* Cambridge University Press,
* ISBN 0-521-43108-5,
* chapter 3, pages 113-116.</a><br>
*/
public double splineInterpolation(
double[] xa,
double[] ya,
double[] y2a,
double x)
throws InterpolationException {
int n = xa.length;
if (n != ya.length || n != y2a.length) {
throw new InterpolationException("Arrays have different lengths.");
}
double y;
int klo, khi, k;
double h, b, a;
klo = 0;
khi = n - 1;
while (khi - klo > 1) {
k = (khi + klo) >> 1;
if (xa[k] > x) {
khi = k;
} else {
klo = k;
}
}
h = xa[khi] - xa[klo];
if (h == 0.0) {
throw new InterpolationException("Two identical x values. The values must be distinct.");
}
a = (xa[khi] - x) / h;
b = (x - xa[klo]) / h;
y =
a * ya[klo]
+ b * ya[khi]
+ ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi])
* (h * h)
/ 6.0;
return y;
}
/**
* Calculates the second derivative of the data. This algorithm
* was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery,
* "Numerical Recipes in C - The Art of Scientific Computing", Second Edition,
* Cambridge University Press,
* ISBN 0-521-43108-5,
* chapter 3, pages 113-116.</a><br>
*/
public double splineInterpolatedDerivative(
double[] xa,
double[] ya,
double[] y2a,
double x)
throws InterpolationException {
int n = xa.length;
if (n != ya.length || n != y2a.length) {
throw new InterpolationException("Arrays have different lengths.");
}
double dydx;
int klo, khi, k;
double h, b, a;
klo = 0;
khi = n - 1;
while (khi - klo > 1) {
k = (khi + klo) >> 1;
if (xa[k] > x) {
khi = k;
} else {
klo = k;
}
}
h = xa[khi] - xa[klo];
if (h == 0.0) {
throw new InterpolationException("Two identical x values. The values must be distinct.");
}
a = (xa[khi] - x) / h;
b = (x - xa[klo]) / h;
dydx =
(ya[khi] - ya[klo]) / h
- ((3 * (a * a) - 1) * h * y2a[klo]) / 6.0
+ ((3 * (b * b) - 1) * h * y2a[khi]) / 6.0;
return dydx;
}
}

View File

@ -1 +0,0 @@
package eva2.tools.math.interpolation;