You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -438,64 +438,61 @@ besselk_power_series_cutoff(nu, x::Float32) = x < 10.0f0 || nu > 1.65f0*x - 8.0f
438
438
"""
439
439
besselk_asymptoticexp(v, x, order)
440
440
441
-
Computes the asymptotic expansion of K_ν w.r.t. argument. Accurate for large x, and faster than uniform asymptotic expansion for small to small-ish orders. The default order of the expansion is 10.
441
+
Computes the asymptotic expansion of K_ν w.r.t. argument. Accurate for large x, and faster than uniform asymptotic expansion for small to small-ish orders. The default order of the expansion in `Bessels.besselk` is 10.
442
442
"""
443
-
functionbesselk_asymptoticexp(v, x::T) where T
444
-
_besselk_asymptoticexp(v, float(x), 10)
445
-
end
446
-
besselk_asexp_cutoff(nu, x) = (nu <20.0) && (x >25.0)
443
+
besselk_asexp_cutoff(nu, x::T) where T = (nu <20.0) && (x >ASEXP_CUTOFF(T))
447
444
448
445
# Compute the function for (_v, _v+1), where _v = v-floor(v), and then do
449
446
# forward recursion. If the argument is really large, this should be faster than
450
447
# the uniform asymptotic expansion and plenty accurate.
451
-
function_besselk_asymptoticexp(v, x::T, order) where T
452
-
_v = v -floor(v)
453
-
(kv, kvp1) =_besselk_as_pair(_v, x, order)
454
-
v == _v &&return kv
455
-
_v +=one(v)
456
-
twodx =T(2)*inv(x)
457
-
while _v < v
458
-
(kv, kvp1) = (kvp1, muladd(kvp1, twodx*_v, kv))
459
-
_v +=one(_v)
460
-
end
461
-
kvp1
448
+
functionbesselk_asymptoticexp(v, x::T, order) where T
449
+
_v = v -floor(v)
450
+
(kv, kvp1) =_besselk_as_pair(_v, x, order)
451
+
v == _v &&return kv
452
+
_v +=one(v)
453
+
twodx =T(2)*inv(x)
454
+
while _v < v
455
+
(kv, kvp1) = (kvp1, muladd(kvp1, twodx*_v, kv))
456
+
_v +=one(_v)
457
+
end
458
+
kvp1
462
459
end
463
460
464
461
# For now, no exponential improvement. It requires the exponential integral
465
462
# function, which would either need to be lifted from SpecialFunctions.jl or
466
463
# re-implemented. And with an order of, like, 10, this seems to be pretty
467
464
# accurate and still faster than the uniform asymptotic expansion.
0 commit comments