From 83a802b87c844b48d73366679b46f4939dcf64de Mon Sep 17 00:00:00 2001 From: naoaki Date: Mon, 16 Feb 2009 13:58:47 +0000 Subject: [PATCH] Removed the unused code. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@47 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc --- lib/lbfgs.c | 139 ------------------------------------------------ sample/sample.c | 4 +- 2 files changed, 2 insertions(+), 141 deletions(-) diff --git a/lib/lbfgs.c b/lib/lbfgs.c index 51e90f3..21f81b1 100644 --- a/lib/lbfgs.c +++ b/lib/lbfgs.c @@ -196,23 +196,6 @@ static lbfgsfloatval_t owlqn_x1norm( const int n ); -static lbfgsfloatval_t owlqn_g2norm( - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t c, - const int start, - const int n - ); - -static void owlqn_direction( - lbfgsfloatval_t* d, - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t c, - const int start, - const int n - ); - static void owlqn_pseudo_gradient( lbfgsfloatval_t* pg, const lbfgsfloatval_t* x, @@ -223,15 +206,6 @@ static void owlqn_pseudo_gradient( const int end ); -static lbfgsfloatval_t owlqn_direction_line( - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t* s, - const lbfgsfloatval_t c, - const int start, - const int n - ); - static void owlqn_project( lbfgsfloatval_t* d, const lbfgsfloatval_t* sign, @@ -1306,74 +1280,6 @@ static lbfgsfloatval_t owlqn_x1norm( return norm; } -static lbfgsfloatval_t owlqn_g2norm( - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t c, - const int start, - const int n - ) -{ - int i; - lbfgsfloatval_t d = 0.; - lbfgsfloatval_t norm = 0.; - - for (i = 0;i < start;++i) { - norm += g[i] * g[i]; - } - - for (i = start;i < n;++i) { - d = g[i]; - if (x[i] < 0.) { - d -= c; - } else if (0. < x[i]) { - d += c; - } - norm += d * d; - } - - return sqrt(norm); -} - -static void owlqn_direction( - lbfgsfloatval_t* d, - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t c, - const int start, - const int n - ) -{ - int i; - - /* Compute the negative of gradients. */ - for (i = 0;i < start;++i) { - d[i] = -g[i]; - } - - /* Compute the negative of psuedo-gradients. */ - for (i = start;i < n;++i) { - if (x[i] < 0.) { - /* Differentiable. */ - d[i] = -g[i] + c; - } else if (0. < x[i]) { - /* Differentiable. */ - d[i] = -g[i] - c; - } else { - if (g[i] < -c) { - /* Take the right partial derivative. */ - d[i] = -g[i] - c; - } else if (c < g[i]) { - /* Take the left partial derivative. */ - d[i] = -g[i] + c; - } else { - /* The gradient is in the range of [-C, C]. */ - d[i] = 0.; - } - } - } -} - static void owlqn_pseudo_gradient( lbfgsfloatval_t* pg, const lbfgsfloatval_t* x, @@ -1417,51 +1323,6 @@ static void owlqn_pseudo_gradient( } } - -static lbfgsfloatval_t owlqn_direction_line( - const lbfgsfloatval_t* x, - const lbfgsfloatval_t* g, - const lbfgsfloatval_t* s, - const lbfgsfloatval_t c, - const int start, - const int n - ) -{ - int i; - lbfgsfloatval_t d = 0.; - - /* Compute the negative of gradients. */ - for (i = 0;i < start;++i) { - d += s[i] * g[i]; - } - - /* Use psuedo-gradients for orthant-wise updates. */ - for (i = start;i < n;++i) { - /* Notice that: - (-s[i] < 0) <==> (g[i] < -param->orthantwise_c) - (-s[i] > 0) <==> (param->orthantwise_c < g[i]) - as the result of the lbfgs() function for orthant-wise updates. - */ - if (s[i] != 0.) { - if (x[i] < 0.) { - /* Differentiable. */ - d += s[i] * (g[i] - c); - } else if (0. < x[i]) { - /* Differentiable. */ - d += s[i] * (g[i] + c); - } else if (s[i] < 0.) { - /* Take the left partial derivative. */ - d += s[i] * (g[i] - c); - } else if (0. < s[i]) { - /* Take the right partial derivative. */ - d += s[i] * (g[i] + c); - } - } - } - - return d; -} - static void owlqn_project( lbfgsfloatval_t* d, const lbfgsfloatval_t* sign, diff --git a/sample/sample.c b/sample/sample.c index 4e707a3..2641f75 100644 --- a/sample/sample.c +++ b/sample/sample.c @@ -64,8 +64,8 @@ int main(int argc, char *argv) /* Initialize the parameters for the L-BFGS optimization. */ lbfgs_parameter_init(¶m); - param.orthantwise_c = 1; - /* param.linesearch = LBFGS_LINESEARCH_BACKTRACKING_STRONG; */ + //param.orthantwise_c = 1; + param.linesearch = LBFGS_LINESEARCH_BACKTRACKING_STRONG; /* Start the L-BFGS optimization; this will invoke the callback functions