lib/mopti/scaled_conjugate_gradient.rb in mopti-0.2.2 vs lib/mopti/scaled_conjugate_gradient.rb in mopti-0.2.3
- old
+ new
@@ -106,27 +106,27 @@
end
kappa = d.dot(d)
break if kappa < 1e-16
sigma = SIGMA_INIT / Math.sqrt(kappa)
- x_plus = x + sigma * d
+ x_plus = x + (sigma * d)
j_plus = jacb(x_plus, @args)
n_jev += 1
theta = d.dot(j_plus - j_next) / sigma
end
- delta = theta + beta * kappa
+ delta = theta + (beta * kappa)
if delta <= 0
delta = beta * kappa
# TODO: Investigate the cause of the type error.
# Cannot assign a value of type `::Complex` to a variable of type `::Float`
# beta -= theta / kappa
beta = (beta - (theta / kappa)).to_f
end
alpha = -mu / delta
- x_next = x + alpha * d
+ x_next = x + (alpha * d)
f_next = func(x_next, @args)
n_fev += 1
delta = 2 * (f_next - f_prev) / (alpha * mu)
if delta >= 0
@@ -163,10 +163,10 @@
d = -j_next
beta = 1.0
n_successes = 0
elsif success
gamma = (j_prev - j_next).dot(j_next) / mu
- d = -j_next + gamma * d
+ d = -j_next + (gamma * d)
end
end
end
SIGMA_INIT = 1e-4