- Make sure that the initial gradients are non-zero.
- Added a necessary cast. git-svn-id: file:///home/svnrepos/software/liblbfgs/trunk@12 ecf4c44f-38d1-4fa4-9757-a0b4dd0349fc
This commit is contained in:
parent
85faeef0f4
commit
36c6eaa158
@ -74,6 +74,8 @@ enum {
|
|||||||
LBFGSFALSE = 0,
|
LBFGSFALSE = 0,
|
||||||
/** True value. */
|
/** True value. */
|
||||||
LBFGSTRUE,
|
LBFGSTRUE,
|
||||||
|
/** */
|
||||||
|
LBFGS_ALREADY_MINIMIZED,
|
||||||
|
|
||||||
/** Unknown error. */
|
/** Unknown error. */
|
||||||
LBFGSERR_UNKNOWNERROR = -1024,
|
LBFGSERR_UNKNOWNERROR = -1024,
|
||||||
|
11
lib/lbfgs.c
11
lib/lbfgs.c
@ -184,7 +184,7 @@ lbfgsfloatval_t* lbfgs_malloc(int n)
|
|||||||
#if defined(USE_SSE) && (defined(__SSE__) || defined(__SSE2__))
|
#if defined(USE_SSE) && (defined(__SSE__) || defined(__SSE2__))
|
||||||
n = round_out_variables(n);
|
n = round_out_variables(n);
|
||||||
#endif/*defined(USE_SSE)*/
|
#endif/*defined(USE_SSE)*/
|
||||||
return vecalloc(sizeof(lbfgsfloatval_t) * n);
|
return (lbfgsfloatval_t*)vecalloc(sizeof(lbfgsfloatval_t) * n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lbfgs_free(lbfgsfloatval_t *x)
|
void lbfgs_free(lbfgsfloatval_t *x)
|
||||||
@ -354,6 +354,15 @@ int lbfgs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Make sure that the gradients are not zero.
|
||||||
|
*/
|
||||||
|
vecnorm(&gnorm, g, n);
|
||||||
|
if (gnorm == 0.) {
|
||||||
|
ret = LBFGS_ALREADY_MINIMIZED;
|
||||||
|
goto lbfgs_exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Compute the initial step:
|
/* Compute the initial step:
|
||||||
step = 1.0 / sqrt(vecdot(d, d, n))
|
step = 1.0 / sqrt(vecdot(d, d, n))
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user