Skip to content

Commit cb5e6bf

Browse files
committed
better type stability
1 parent 3564ab7 commit cb5e6bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/NumericalCalculations.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ function _solveLambdaNumeric( fcttype::Union{F,<:Mixture{N_,F,S,T}},
103103
return sum(residual.^2)
104104
end
105105

106-
alg = islen1 ? Optim.BFGS() : Optim.NelderMead()
106+
# separate statements to try improve type-stability
107+
r = if islen1
108+
Optim.optimize(cost, X0c, Optim.BFGS())
109+
else
110+
Optim.optimize(cost, X0c, Optim.NelderMead())
111+
end
107112

108-
r = Optim.optimize(cost, X0c, alg)
109-
110113
return exp(M, ϵ, hat(M, ϵ, r.minimizer))
111114

112115
end

0 commit comments

Comments
 (0)