S[i] = (vy_[i+1] - vy_[i])/dx[i];
}
// first derivative approximation
if (da==CubicInterpolation.DerivativeApprox.Spline) {
final TridiagonalOperator L = new TridiagonalOperator(n);
for (int i=1; i<n-1; ++i) {
L.setMidRow(i, dx[i], 2.0*(dx[i]+dx[i-1]), dx[i-1]);
tmp[i] = 3.0*(dx[i]*S[i-1] + dx[i-1]*S[i]);
}
// left boundary condition
switch (leftType) {
case NotAKnot:
// ignoring end condition value
L.setFirstRow(dx[1]*(dx[1]+dx[0]),
(dx[0]+dx[1])*(dx[0]+dx[1]));
tmp[0] = S[0]*dx[1]*(2.0*dx[1]+3.0*dx[0]) +
S[1]*dx[0]*dx[0];
break;
case FirstDerivative:
L.setFirstRow(1.0, 0.0);
tmp[0] = leftValue;
break;
case SecondDerivative:
L.setFirstRow(2.0, 1.0);
tmp[0] = 3.0*S[0] - leftValue*dx[0]/2.0;
break;
case Periodic:
case Lagrange:
// ignoring end condition value
throw new LibraryException("this end condition is not implemented yet");
default:
throw new LibraryException("unknown end condition");
}
// right boundary condition
switch (rightType) {
case NotAKnot:
// ignoring end condition value
L.setLastRow(-(dx[n-2]+dx[n-3])*(dx[n-2]+dx[n-3]),
-dx[n-3]*(dx[n-3]+dx[n-2]));
tmp[n-1] = -S[n-3]*dx[n-2]*dx[n-2] -
S[n-2]*dx[n-3]*(3.0*dx[n-2]+2.0*dx[n-3]);
break;
case FirstDerivative:
L.setLastRow(0.0, 1.0);
tmp[n-1] = rightValue;
break;
case SecondDerivative:
L.setLastRow(1.0, 2.0);
tmp[n-1] = 3.0*S[n-2] + rightValue*dx[n-2]/2.0;
break;
case Periodic:
case Lagrange:
// ignoring end condition value
throw new LibraryException("this end condition is not implemented yet");
default:
throw new LibraryException("unknown end condition");
}
// solve the system
tmp = L.solveFor(tmp);
} else { // local schemes
if (n==2) {
tmp[0] = tmp[1] = S[0];
} else {
switch (da) {