- 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:
		@@ -74,6 +74,8 @@ enum {
 | 
			
		||||
    LBFGSFALSE = 0,
 | 
			
		||||
    /** True value. */
 | 
			
		||||
    LBFGSTRUE,
 | 
			
		||||
    /** */
 | 
			
		||||
    LBFGS_ALREADY_MINIMIZED,
 | 
			
		||||
 | 
			
		||||
    /** Unknown error. */
 | 
			
		||||
    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__))
 | 
			
		||||
    n = round_out_variables(n);
 | 
			
		||||
#endif/*defined(USE_SSE)*/
 | 
			
		||||
    return vecalloc(sizeof(lbfgsfloatval_t) * n);
 | 
			
		||||
    return (lbfgsfloatval_t*)vecalloc(sizeof(lbfgsfloatval_t) * n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
        step = 1.0 / sqrt(vecdot(d, d, n))
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user