41 using namespace fspecial;
54 #ifndef HAVE_CXX_COMPLEX_NORM
63 nr_double_t r =
real (z);
64 nr_double_t
i =
imag (z);
69 #ifndef HAVE_CXX_COMPLEX_POLAR
77 return rect (mag *
cos (ang), mag *
sin (ang));
81 #ifndef HAVE_CXX_COMPLEX_POLAR_COMPLEX
94 #ifndef HAVE_CXX_COMPLEX_COS
101 nr_double_t r =
real (z);
102 nr_double_t
i =
imag (z);
107 #ifndef HAVE_CXX_COMPLEX_ACOS
114 nr_double_t r =
real (z);
115 nr_double_t
i =
imag (z);
120 if (r * i < 0.0) y = -y;
121 return rect (0, -1.0) *
log (z + y);
126 #ifndef HAVE_CXX_COMPLEX_COSH
133 nr_double_t r =
real (z);
134 nr_double_t
i =
imag (z);
139 #ifndef HAVE_CXX_COMPLEX_ACOSH
146 return log (z +
sqrt (z * z - 1.0));
150 #ifndef HAVE_CXX_COMPLEX_EXP
157 nr_double_t mag =
exp (
real (z));
173 #ifndef HAVE_CXX_COMPLEX_LOG
180 nr_double_t phi =
arg (z);
185 #ifndef HAVE_CXX_COMPLEX_LOG10
192 nr_double_t phi =
arg (z);
197 #ifndef HAVE_CXX_COMPLEX_LOG2
204 nr_double_t phi =
arg (z);
209 #ifndef HAVE_CXX_COMPLEX_POW
237 return exp (z2 *
log (z1));
241 #ifndef HAVE_CXX_COMPLEX_SIN
248 nr_double_t r =
real (z);
249 nr_double_t
i =
imag (z);
254 #ifndef HAVE_CXX_COMPLEX_ASIN
261 nr_double_t r =
real (z);
262 nr_double_t
i =
imag (z);
267 #ifndef HAVE_CXX_COMPLEX_SINH
274 nr_double_t r =
real (z);
275 nr_double_t
i =
imag (z);
280 #ifndef HAVE_CXX_COMPLEX_ASINH
287 return log (z +
sqrt (z * z + 1.0));
291 #ifndef HAVE_CXX_COMPLEX_SQRT
301 nr_double_t r =
real (z);
302 nr_double_t
i =
imag (z);
307 nr_double_t phi =
arg (z);
308 return polar (
sqrt (fabs (z)), phi / 2.0);
311 if (r == 0.0 && i == 0.0) {
314 nr_double_t
x = fabs (r);
315 nr_double_t y = fabs (i);
318 nr_double_t
t = y /
x;
321 nr_double_t
t = x / y;
327 nr_double_t vi = (i >= 0) ? k : -k;
335 #ifndef HAVE_CXX_COMPLEX_TAN
342 nr_double_t r = 2.0 *
real (z);
343 nr_double_t
i = 2.0 *
imag (z);
348 #ifndef HAVE_CXX_COMPLEX_ATAN
359 #ifndef HAVE_CXX_COMPLEX_ATAN2
370 return real (x) > 0.0 ? a : -a;
374 #ifndef HAVE_CXX_COMPLEX_TANH
381 nr_double_t r = 2.0 *
real (z);
382 nr_double_t
i = 2.0 *
imag (z);
383 return 1.0 - 2.0 / (
polar (
exp (r), i) + 1.0);
387 #ifndef HAVE_CXX_COMPLEX_ATANH
394 return 0.5 *
log ( 2.0 / (1.0 - z) - 1.0);
404 nr_double_t r = 2.0 *
real (z);
405 nr_double_t
i = 2.0 *
imag (z);
425 return log ((1.0 +
sqrt (1.0 - z * z)) / z);
434 nr_double_t r = 2.0 *
real (z);
435 nr_double_t
i = 2.0 *
imag (z);
436 return 1.0 + 2.0 / (
polar (
exp (r), i) - 1.0);
445 return 0.5 *
log (2.0 / (z - 1.0) + 1.0);
466 return (z - zref) / (z + zref);
475 return (1.0 - y * zref) / (1.0 + y * zref);
484 return zref * (1.0 + r) / (1.0 - r);
493 return (1.0 - r) / (1.0 + r) / zref;
496 #ifndef HAVE_CXX_COMPLEX_FLOOR
511 #ifndef HAVE_CXX_COMPLEX_FMOD
566 if (z == 0)
return 0;
600 nr_double_t
c =
norm (a);
601 nr_double_t d =
norm (b);
603 return abs (a) *
sqrt (1 + d / c);
607 return abs (b) *
sqrt (1 + c / d);
628 if (z == 0)
return 1;
652 nr_double_t
x =
real (z);
653 nr_double_t y =
imag (z);
688 nr_double_t r =
real (z);
689 nr_double_t
i =
imag (z);
690 return rect (r * r - i * i, 2 * r * i);
702 nr_double_t
x =
real (z);
703 nr_double_t y =
imag (z);
845 return z1 - z2 *
floor (z1 / z2);
852 return z1 - r2 *
floor (z1 / r2);
859 return r1 - z2 *
floor (r1 / z2);