59 std::complex<double> f(z);
60 std::complex<double> C(f);
61 std::complex<double> D(0.0);
62 std::complex<double> delta;
70 if ((D.real() == 0.0) && (D.imag() == 0.0))
76 while (
abs(1.0 - delta) >
eps);
103 std::complex<double>
sum(0.0);
104 std::complex<double> term(z);
105 std::complex<double> z2(z*z);
107 for (
int n = 0; (n < 3) || (abs(term) >
abs(sum) * tiny); n++) {
108 sum += term /
static_cast<double>(2 * n + 1);
109 term *= -z2 /
static_cast<double>(n + 1);
130 int n0 = 2 *
static_cast<int>(z.imag() / (2 * h) + 0.5);
132 std::complex<double> z0(0.0, n0 * h);
133 std::complex<double> zp(z - z0);
134 std::complex<double>
sum(0.0, 0.0);
138 for (
int np = -35; np <= 35; np += 2) {
139 std::complex<double> t(zp.real(), zp.imag() - np * h);
140 std::complex<double> b(
exp(t * t) / static_cast<double>(np + n0));
144 sum *= 2.0 *
exp(-z * z) /
pi;
146 return std::complex<double>(-sum.imag(), sum.real());
154 std::complex<double>
erf(
const std::complex<double>& z)
171 double Y, A, B, X, Z, W, WI, SN, SD, F, Z2, SIGMA;
172 double A1 = -.5751703, A2 = -1.896513, A3 = -.5496261E-1;
173 double B0 = -.1137730, B1 = -3.293474, B2 = -2.374996, B3 = -1.187515;
174 double C0 = -.1146666, C1 = -.1314774, C2 = -.2368201, C3 = .5073975e-1;
175 double D0 = -44.27977, D1 = 21.98546, D2 = -7.586103;
176 double E0 = -.5668422E-1, E1 = .3937021, E2 = -.3166501, E3 = .6208963E-1;
177 double F0 = -6.266786, F1 = 4.666263, F2 = -2.962883;
178 double G0 = .1851159E-3, G1 = -.2028152E-2, G2 = -.1498384, G3 = .1078639E-1;
179 double H0 = .9952975E-1, H1 = .5211733, H2 = -.6888301E-1;
184 it_error_if(X < -1 || X > 1,
"erfinv : argument out of bounds");
193 SN = ((G3 * WI + G2) * WI + G1) * WI;
194 SD = ((WI + H2) * WI + H1) * WI + H0;
195 F = W + W * (G0 + SN / SD);
198 SN = ((E3 * W + E2) * W + E1) * W;
199 SD = ((W + F2) * W + F1) * W + F0;
200 F = W + W * (E0 + SN / SD);
204 SN = ((C3 * W + C2) * W + C1) * W;
205 SD = ((W + D2) * W + D1) * W + D0;
206 F = W + W * (C0 + SN / SD);
211 F = Z + Z * (B0 + A1 * Z2 / (B1 + Z2 + A2 / (B2 + Z2 + A3 / (B3 + Z2))));
219 return (0.5 * ::
erfc(x / 1.41421356237310));
224 vec
erf(
const vec &x) {
return apply_function<double>(
::erf, x); }
225 mat
erf(
const mat &x) {
return apply_function<double>(
::erf, x); }
228 return apply_function<std::complex<double> >(
erf, x);
232 return apply_function<std::complex<double> >(
erf, x);
240 vec
erfc(
const vec &x) {
return apply_function<double>(
::erfc, x); }
241 mat
erfc(
const mat &x) {
return apply_function<double>(
::erfc, x); }
244 vec
Qfunc(
const vec &x) {
return apply_function<double>(
Qfunc, x); }
245 mat
Qfunc(
const mat &x) {
return apply_function<double>(
Qfunc, x); }