Skip to content

Commit 6f3556e

Browse files
committed
expose quadratic form structure explicitly
1 parent f20e897 commit 6f3556e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/trustRegion.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@ function retrospective_step!(cache::TrustRegionCache)
365365
@unpack H, g, step_size = cache
366366

367367
return -(get_loss(fu_prev) - get_loss(fu)) /
368-
(step_size' * g + step_size' * H * step_size / 2)
368+
(dot(step_size, g) + dot(step_size, H, step_size) / 2)
369369
end
370370

371371
function trust_region_step!(cache::TrustRegionCache)
372372
@unpack fu_new, step_size, g, H, loss, max_trust_r, radius_update_scheme = cache
373373
cache.loss_new = get_loss(fu_new)
374374

375375
# Compute the ratio of the actual reduction to the predicted reduction.
376-
cache.r = -(loss - cache.loss_new) / (step_size' * g + step_size' * H * step_size / 2)
376+
cache.r = -(loss - cache.loss_new) / (dot(step_size, g) + dot(step_size, H, step_size) / 2)
377377
@unpack r = cache
378378

379379
if radius_update_scheme === RadiusUpdateSchemes.Simple

0 commit comments

Comments
 (0)