}
return new DoubleMatrix1D(res);
}
private DoubleMatrix2D getInverseTridiagonalMatrix(final double[] deltaX) {
final InverseTridiagonalMatrixCalculator invertor = new InverseTridiagonalMatrixCalculator();
final int n = deltaX.length + 1;
final double[] a = new double[n];
final double[] b = new double[n - 1];
final double[] c = new double[n - 1];
for (int i = 1; i < n - 1; i++) {
a[i] = (deltaX[i - 1] + deltaX[i]) / 3.0;
b[i] = deltaX[i] / 6.0;
c[i - 1] = deltaX[i - 1] / 6.0;
}
// Boundary condition
if (_leftNatural) {
a[0] = 1.0;
b[0] = 0.0;
} else {
a[0] = -deltaX[0] / 3.0;
b[0] = deltaX[0] / 6.0;
}
if (_rightNatural) {
a[n - 1] = 1.0;
c[n - 2] = 0.0;
} else {
a[n - 1] = deltaX[n - 2] / 3.0;
c[n - 2] = deltaX[n - 2] / 6.0;
}
final TridiagonalMatrix tridiagonal = new TridiagonalMatrix(a, b, c);
return invertor.evaluate(tridiagonal);
}