8 #include <lifev/navier_stokes/function/bessel/bessel.hpp> 13 static std::complex<
double>
cii (0.0, 1.0);
14 static std::complex<
double>
czero (0.0, 0.0);
15 static std::complex<
double>
cone (1.0, 0.0);
17 double gamma (
double x);
19 int cbessik01 (std::complex<
double>z, std::complex<
double>& ci0, std::complex<
double>& ci1,
20 std::complex<
double>& ck0, std::complex<
double>& ck1, std::complex<
double>& ci0p,
21 std::complex<
double>& ci1p, std::complex<
double>& ck0p, std::complex<
double>& ck1p)
23 std::complex<
double> z1, z2, zr, zr2, cr, ca, cb, cs, ct, cw;
77 ck0 = std::complex<
double> (1e308, 0);
78 ck1 = std::complex<
double> (1e308, 0);
80 ci1p = std::complex<
double> (0.5, 0.0);
81 ck0p = std::complex<
double> (-1e308, 0);
82 ck1p = std::complex<
double> (-1e308, 0);
93 for (k = 1; k <= 50; k++)
95 cr *= 0.25 * z2 / (
double) (k * k);
97 if (std::abs (cr / ci0) <
eps)
104 for (k = 1; k <= 50; k++)
106 cr *= 0.25 * z2 / (
double) (k * (k + 1.0) );
108 if (std::abs (cr / ci1) <
eps)
129 ca = std::exp (z1) / std::sqrt (2.0 *
M_PI * z1);
132 for (k = 0; k < kz; k++)
134 ci0 += a[k] * std::pow (zr, k + 1.0);
138 for (k = 0; k < kz; k++)
140 ci1 += b[k] * std::pow (zr, k + 1.0);
147 ct = -log (0.5 * z1) -
el;
150 for (k = 1; k <= 50; k++)
153 cr *= 0.25 * z2 / (
double) (k * k);
154 cs += cr * (w0 + ct);
155 if (std::abs ( (cs - cw) / cs) <
eps)
168 for (k = 0; k < 10; k++)
170 ck0 += a1[k] * std::pow (zr2, k + 1.0);
174 ck1 = (1.0 / z1 - ci1 * ck0) / ci0;
179 ck0 += cii *
M_PI * ci0;
180 ck1 = -ck1 + cii *
M_PI * ci1;
182 else if (imag (z) > 0.0)
184 ck0 -= cii *
M_PI * ci0;
185 ck1 = -ck1 - cii *
M_PI * ci1;
190 ci1p = ci0 - 1.0 * ci1 / z;
192 ck1p = -ck0 - 1.0 * ck1 / z;
195 int cbessikna (
int n, std::complex<
double> z,
int& nm, std::complex<
double>* ci,
196 std::complex<
double>* ck, std::complex<
double>* cip, std::complex<
double>* ckp)
198 std::complex<
double> ci0, ci1, ck0, ck1, ckk, cf, cf1, cf2, cs;
205 for (k = 0; k <= n; k++)
208 ck[k] = std::complex<
double> (-1e308, 0);
210 ckp[k] = std::complex<
double> (1e308, 0);
213 cip[1] = std::complex<
double> (0.5, 0.0);
235 cf1 = std::complex<
double> (1.0e-100, 0.0);
236 for (k = m; k >= 0; k--)
238 cf = 2.0 * (k + 1.0) * cf1 / z + cf2;
247 for (k = 0; k <= nm; k++)
251 for (k = 2; k <= nm; k++)
253 if (std::abs (ci[k - 1]) > std::abs (ci[k - 2]) )
255 ckk = (1.0 / z - ci[k] * ck[k - 1]) / ci[k - 1];
259 ckk = (ci[k] * ck[k - 2] + 2.0 * (k - 1.0) / (z * z) ) / ci[k - 2];
263 for (k = 2; k <= nm; k++)
265 cip[k] = ci[k - 1] - (
double) k * ci[k] / z;
266 ckp[k] = -ck[k - 1] - (
double) k * ck[k] / z;
270 int cbessiknb (
int n, std::complex<
double> z,
int& nm, std::complex<
double>* ci,
271 std::complex<
double>* ck, std::complex<
double>* cip, std::complex<
double>* ckp)
273 std::complex<
double> z1, cbs, csk0, cf, cf0, cf1, ca0, cbkl;
274 std::complex<
double> cg, cg0, cg1, cs0, cs, cr;
282 for (k = 0; k <= n; k++)
285 ck[k] = std::complex<
double> (1e308, 0);
287 ckp[k] = std::complex<
double> (-1e308, 0);
289 ci[0] = std::complex<
double> (1.0, 0.0);
290 cip[1] = std::complex<
double> (0.5, 0.0);
314 cf1 = std::complex<
double> (1.0e-100, 0.0);
315 for (k = m; k >= 0; k--)
317 cf = 2.0 * (k + 1.0) * cf1 / z1 + cf0;
322 if ( (k != 0) && (k == 2 * (k >> 1) ) )
324 csk0 += 4.0 * cf / (
double) k;
330 cs0 = std::exp (z1) / (cbs - cf);
331 for (k = 0; k <= nm; k++)
337 ck[0] = - (log (0.5 * z1) +
el) * ci[0] + cs0 * csk0;
338 ck[1] = (1.0 / z1 - ci[1] * ck[0]) / ci[0];
342 ca0 = std::sqrt (M_PI_2 / z1) * std::exp (-z1);
359 for (l = 0; l < 2; l++)
364 for (k = 1; k <= kz; k++)
366 cr *= 0.125 * (vt - std::pow (2.0 * k - 1.0, 2.0) ) / ( (
double) k * z1);
374 for (k = 2; k <= nm; k++)
376 cg = 2.0 * (k - 1.0) * cg1 / z1 + cg0;
384 for (k = 0; k <= nm; k++)
388 ck[k] = fac * ck[k] + cii *
M_PI * ci[k];
392 ck[k] = fac * ck[k] - cii *
M_PI * ci[k];
400 for (k = 1; k <= nm; k++)
402 cip[k] = ci[k - 1] - (
double) k * ci[k] / z;
403 ckp[k] = -ck[k - 1] - (
double) k * ck[k] / z;
407 int cbessikv (
double v, std::complex<
double>z,
double& vm, std::complex<
double>* civ,
408 std::complex<
double>* ckv, std::complex<
double>* civp, std::complex<
double>* ckvp)
410 std::complex<
double> z1, z2, ca1, ca, cs, cr, ci0, cbi0, cf, cf1, cf2;
411 std::complex<
double> ct, cp, cbk0, ca2, cr1, cr2, csu, cws, cb;
412 std::complex<
double> cg0, cg1, cgk, cbk1, cvk;
413 double a0, v0, v0p, v0n, vt, w0, piv, gap (0), gan;
429 for (k = 0; k <= n; k++)
432 ckv[k] = std::complex<
double> (-1e308, 0);
434 ckvp[k] = std::complex<
double> (1e308, 0);
439 civp[1] = std::complex<
double> (0.5, 0.0);
470 ca1 = std::pow (0.5 * z1, v0) / gap;
474 for (k = 1; k <= 50; k++)
476 cr *= 0.25 * z2 / (k * (k + v0) );
478 if (std::abs (cr / ci0) <
eps)
487 ca = std::exp (z1) / std::sqrt (2.0 *
M_PI * z1);
490 for (k = 1; k <= kz; k++)
492 cr *= -0.125 * (vt - std::pow (2.0 * k - 1.0, 2.0) ) / ( (
double) k * z1);
507 cf1 = std::complex<
double> (1.0e-100, 0.0);
508 for (k = m; k >= 0; k--)
510 cf = 2.0 * (v0 + k + 1.0) * cf1 / z1 + cf2;
519 for (k = 0; k <= n; k++)
527 ct = -log (0.5 * z1) -
el;
531 for (k = 1; k <= 50; k++)
534 cr *= 0.25 * z2 / (
double) (k * k);
537 if ( (k >= 10) && (std::abs (cp / cs) <
eps) )
548 ca2 = 1.0 / (gan * std::pow (0.5 * z1, v0) );
549 ca1 = std::pow (0.5 * z1, v0) / gap;
554 for (k = 1; k <= 50; k++)
556 cr1 *= 0.25 * z2 / (k * (k - v0) );
557 cr2 *= 0.25 * z2 / (k * (k + v0) );
558 csu += ca2 * cr1 - ca1 * cr2;
559 if ( (k >= 10) && (std::abs ( (cws - csu) / csu) <
eps) )
565 cbk0 = csu * M_PI_2 / std::sin (piv);
570 cb = std::exp (-z1) * std::sqrt (M_PI_2 / z1);
573 for (k = 1; k <= kz; k++)
575 cr *= 0.125 * (vt - std::pow (2.0 * k - 1.0, 2.0) ) / ( (
double) k * z1);
580 cbk1 = (1.0 / z1 - civ[1] * cbk0) / civ[0];
585 for (k = 2; k <= n; k++)
587 cgk = 2.0 * (v0 + k - 1.0) * cg1 / z1 + cg0;
594 for (k = 0; k <= n; k++)
596 cvk = std::exp ( (k + v0) *
M_PI * cii);
599 ckv[k] = cvk * ckv[k] +
M_PI * cii * civ[k];
602 else if (imag (z) > 0.0)
604 ckv[k] = ckv[k] / cvk -
M_PI * cii * civ[k];
609 civp[0] = v0 * civ[0] / z + civ[1];
610 ckvp[0] = v0 * ckv[0] / z - ckv[1];
611 for (k = 1; k <= n; k++)
613 civp[k] = - (k + v0) * civ[k] / z + civ[k - 1];
614 ckvp[k] = - (k + v0) * ckv[k] / z - ckv[k - 1];
int msta1(double x, int mp)
static std::complex< double > cii(0.0, 1.0)
int cbessikna(int n, std::complex< double > z, int &nm, std::complex< double > *ci, std::complex< double > *ck, std::complex< double > *cip, std::complex< double > *ckp)
int msta2(double x, int n, int mp)
static std::complex< double > czero(0.0, 0.0)
int cbessiknb(int n, std::complex< double > z, int &nm, std::complex< double > *ci, std::complex< double > *ck, std::complex< double > *cip, std::complex< double > *ckp)
int cbessikv(double v, std::complex< double >z, double &vm, std::complex< double > *civ, std::complex< double > *ckv, std::complex< double > *civp, std::complex< double > *ckvp)
int cbessik01(std::complex< double >z, std::complex< double > &ci0, std::complex< double > &ci1, std::complex< double > &ck0, std::complex< double > &ck1, std::complex< double > &ci0p, std::complex< double > &ci1p, std::complex< double > &ck0p, std::complex< double > &ck1p)
static std::complex< double > cone(1.0, 0.0)