Skip to content

Commit b8da355

Browse files
committed
Move previous keyword parameters to function body
1 parent a4c7154 commit b8da355

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

ext/SpecialFunctionsChainRulesCoreExt.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,13 @@ end
440440
return dan * Xpp + an * dXpp + dbn * Xp + bn * dXp
441441
end
442442

443-
function _beta_inc_grad(a::T, b::T, x::T; maxapp::Int=200, minapp::Int=3, err::T=eps(T)*T(1e4)) where {T}
443+
function _beta_inc_grad(a::T, b::T, x::T) where {T}
444+
445+
# 0) Previously keyword arguments:
446+
maxapp=200
447+
minapp=3
448+
ϵ=eps(T)*T(1e4)
449+
444450
# Compute I_x(a,b) and partial derivatives (∂I/∂a, ∂I/∂b, ∂I/∂x)
445451
# using a differentiated continued fraction with convergence control.
446452
oneT = one(T)
@@ -450,16 +456,13 @@ function _beta_inc_grad(a::T, b::T, x::T; maxapp::Int=200, minapp::Int=3, err::T
450456
isone(x) && return oneT, zeroT, zeroT, zeroT
451457
iszero(x) && return zeroT, zeroT, zeroT, zeroT
452458

453-
# 2) Get tolerence
454-
ϵ = err
455-
456-
logbetapq = logbeta(a,b) # Time-consuming step; symetric in a,b
457459

458460
# 3) Precompute log(x) and log(1-x) once at original x
459461
logx = log(x)
460462
log1mx = log1p(-x)
461463

462464
# 3a) Non-boundary path: precompute ∂I/∂x at original (a,b,x) via stable log form
465+
logbetapq = logbeta(a,b) # Time-consuming step; symetric in a,b
463466
dx = exp((a - oneT) * logx + (b - oneT) * log1mx - logbetapq)
464467

465468
# 4) Optional tail-swap for symmetry and improved CF convergence:

0 commit comments

Comments
 (0)