Skip to content

Commit

Permalink
Improve choosing dividing-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Aug 3, 2017
1 parent c2fece2 commit 4910adf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/genz-malik.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,17 @@ error `E` (via the given `norm`), and the suggested coordinate `k` ∈ `1:n`
to subdivide next.
"""
function (g::GenzMalik{n,T})(f, a::SVector{n}, b::SVector{n}, norm=vecnorm) where {n,T}
c = (a+b)*T(0.5)
Δ = (b-a)*T(0.5)
V = abs(prod))
c = T(0.5).*(a.+b)
Δ = T(0.5).*abs.(b.-a)
V = prod(Δ)

f₁ = f(c)

f₂ = zero(f₁)
f₃ = zero(f₁)
kdivide = 1
maxdivdiff = zero(norm(f₁))
ε = eps(typeof(maxdivdiff))
twelvef₁ = 12f₁
for i = 1:n
p₂ = Δ .* g.p[1][i]
Expand All @@ -135,9 +136,11 @@ function (g::GenzMalik{n,T})(f, a::SVector{n}, b::SVector{n}, norm=vecnorm) wher
# fourth divided difference: f₃ᵢ-2f₁ - 7*(f₂ᵢ-2f₁),
# where 7 = (λ₃/λ₂)^2 [see van Dooren and de Ridder]
divdiff = norm(f₃ᵢ + twelvef₁ - 7*f₂ᵢ)
if divdiff > maxdivdiff
if = divdiff - maxdivdiff) > ε
kdivide = i
maxdivdiff = divdiff
elseif abs(δ) < ε && Δ[i] > Δ[kdivide]
kdivide = i
end
end

Expand Down

0 comments on commit 4910adf

Please sign in to comment.