From 9187e047751a804a8651a437f7358df63c5fa55e Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Thu, 30 Jan 2014 20:46:13 +0100 Subject: [PATCH] Performance tweaks: switching to mixed bessel functions --- Core/Tools/inc/MathFunctions.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Core/Tools/inc/MathFunctions.h b/Core/Tools/inc/MathFunctions.h index 9f302033a5f..90f0dd75f5c 100644 --- a/Core/Tools/inc/MathFunctions.h +++ b/Core/Tools/inc/MathFunctions.h @@ -176,17 +176,30 @@ inline double MathFunctions::Bessel_C1(double value) inline complex_t MathFunctions::Bessel_J0(const complex_t &value) { - return crbond_bessel_J0(value); + if(std::imag(value) < Numeric::double_epsilon) { + return complex_t(Bessel_J0(std::real(value)), 0.0); + } else { + return crbond_bessel_J0(value); + } } inline complex_t MathFunctions::Bessel_J1(const complex_t &value) { - return crbond_bessel_J1(value); + if(std::imag(value) < Numeric::double_epsilon) { + return complex_t(Bessel_J1(std::real(value)), 0.0); + } else { + return crbond_bessel_J1(value); + } } inline complex_t MathFunctions::Bessel_C1(const complex_t &value) { - return (std::abs(value) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(value)/value : 0.5); + if(std::imag(value) < Numeric::double_epsilon) { + double xv = std::real(value); + return (std::abs(xv) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(xv)/xv : 0.5); + } else { + return (std::abs(value) > Numeric::double_epsilon ? MathFunctions::Bessel_J1(value)/value : 0.5); + } } -- GitLab