@@ -515,7 +515,7 @@ function dder3(
515
515
end
516
516
517
517
function Δ2! (Δ2:: Matrix{T} , λ:: Vector{T} , log_λ:: Vector{T} ) where {T <: Real }
518
- rteps = sqrt (eps (T))
518
+ thresh = cbrt (eps (T))
519
519
d = length (λ)
520
520
521
521
@inbounds for j in 1 : d
@@ -524,7 +524,7 @@ function Δ2!(Δ2::Matrix{T}, λ::Vector{T}, log_λ::Vector{T}) where {T <: Real
524
524
for i in 1 : (j - 1 )
525
525
λ_i = λ[i]
526
526
λ_ij = λ_i - λ_j
527
- if abs (λ_ij) < rteps
527
+ if abs (λ_ij) < thresh
528
528
Δ2[i, j] = 2 / (λ_i + λ_j)
529
529
else
530
530
Δ2[i, j] = (log_λ[i] - lλ_j) / λ_ij
@@ -540,17 +540,17 @@ end
540
540
541
541
function Δ3! (Δ3:: Array{T, 3} , Δ2:: Matrix{T} , λ:: Vector{T} ) where {T <: Real }
542
542
@assert issymmetric (Δ2) # must be symmetric (wrapper is less efficient)
543
- rteps = sqrt ( eps (T))
543
+ thresh = eps (T)^ ( 2 / 9 )
544
544
d = length (λ)
545
545
546
546
@inbounds for k in 1 : d, j in 1 : k, i in 1 : j
547
547
λ_j = λ[j]
548
548
λ_k = λ[k]
549
549
λ_jk = λ_j - λ_k
550
- if abs (λ_jk) < rteps
550
+ if abs (λ_jk) < thresh
551
551
λ_i = λ[i]
552
552
λ_ij = λ_i - λ_j
553
- if abs (λ_ij) < rteps
553
+ if abs (λ_ij) < thresh
554
554
t = abs2 (3 / (λ_i + λ_j + λ_k)) / - 2
555
555
else
556
556
t = (Δ2[i, j] - Δ2[j, k]) / λ_ij
@@ -661,7 +661,7 @@ function Δ4_ij!(
661
661
Δ3:: Array{T, 3} ,
662
662
λ:: Vector{T} ,
663
663
) where {T <: Real }
664
- rteps = sqrt ( eps (T))
664
+ thresh = eps (T)^ ( 4 / 27 )
665
665
d = length (λ)
666
666
λ_i = λ[i]
667
667
λ_j = λ[j]
@@ -672,11 +672,12 @@ function Δ4_ij!(
672
672
λ_ij = λ_i - λ_j
673
673
λ_ik = λ_i - λ_k
674
674
λ_il = λ_i - λ_l
675
- B_ik = (abs (λ_ik) < rteps )
676
- B_il = (abs (λ_il) < rteps )
675
+ B_ik = (abs (λ_ik) < thresh )
676
+ B_il = (abs (λ_il) < thresh )
677
677
678
- if (abs (λ_ij) < rteps) && B_ik && B_il
679
- t = λ_i^- 3 / 3
678
+ if (abs (λ_ij) < thresh) && B_ik && B_il
679
+ λ_mean = (λ_i + λ_j + λ_k + λ_l)/ 4
680
+ t = λ_mean^- 3 / 3
680
681
elseif B_ik && B_il
681
682
t = (Δ3[i, i, i] - Δ3[i, i, j]) / λ_ij
682
683
elseif B_il
0 commit comments