From 4edf33c84ed846438c625863ca5ddb62c44391ac Mon Sep 17 00:00:00 2001 From: naoaki Date: Mon, 16 Feb 2009 12:11:44 +0000 Subject: [PATCH] Code simplification. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@40 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc --- lib/lbfgs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/lbfgs.c b/lib/lbfgs.c index 948c9bc..21436d1 100644 --- a/lib/lbfgs.c +++ b/lib/lbfgs.c @@ -668,11 +668,9 @@ static int line_search_backtracking_owlqn( return LBFGSERR_INVALIDPARAMETERS; } + /* Choose the orthant for the new point. */ for (i = 0;i < n;++i) { - wp[i] = xp[i]; - if (wp[i] == 0.) { - wp[i] = -gp[i]; - } + wp[i] = (xp[i] == 0.) ? -gp[i] : wp[i]; } for (;;) { @@ -1496,6 +1494,7 @@ static void owlqn_direction( /* Take the left partial derivative. */ d[i] = -g[i] + c; } else { + /* The gradient is in the range of [-C, C]. */ d[i] = 0.; } }