double W2::operator()(double x, double k) const throw() { if(x < 0.0 || x - b > eps) { return 0.0; } const double z = std::min(2.0 * x, 2.0*(b - x)); double result = 0.; // k != 0.0 /* * The cube root of epsilon of my machine is approximately 6e-06 * The equation gets unstable approximately when k < 1e-06 probably due to * the k^3 in the divisor. Can't say for sure. Just an educated guess. */ if(fabs(k) > cbrt(eps)) { if(x-.5*z < C[0]) { if(x+.5*z < C[0]) { // Left slope result = I(A_l, B_l, z, x, k); } else if(x < C[0]) { // Both slopes, X on left slope result = (I(A_l, B_l, 2.*(C[0] - x), x, k) + I_lr(z, x, k) - I_lr(2.*(C[0] - x), x, k)); } else { // Both slopes, X on right slope result = (I(A_r, B_r, 2.*(x - C[0]), x, k) + I_lr(z, x, k) - I_lr(2.*(x - C[0]), x, k)); } } else { // Right slope result = I(A_r, B_r, z, x, k); } } else { // k == 0 if((x - 0.5 * z) < C[0]) { if((x + 0.5 * z) < C[0]) { // Left slope result = I_0(A_l, B_l, z, x); } else if(x < C[0]) { // Both slopes, X on left slope result = (I_0(A_l, B_l, 2.*(C[0] - x), x) + I_lr_0(z, x) - I_lr_0(2.*(C[0] - x), x)); } else { // Both slopes, X on right slope result = (I_0(A_r, B_r, 2.*(x - C[0]), x) + I_lr_0(z, x) - I_lr_0(2.*(x - C[0]), x)); } } else { // Right slope result = I_0(A_r, B_r, z, x); } } return result * N_sqr; }
// -1.0 <= t <= 1.0 double kaiser(double t, double beta=8.0) { return I_0(beta*sqrt(1.0 - t*t)) / I_0(beta); }