changeset 6382:f74e71ef6612

[project @ 2007-03-05 21:29:40 by jwe]
author jwe
date Mon, 05 Mar 2007 21:29:40 +0000
parents 8a844b3d10b1
children 65e9cf5c7718
files scripts/ChangeLog scripts/optimization/sqp.m
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Mar 05 18:41:57 2007 +0000
+++ b/scripts/ChangeLog	Mon Mar 05 21:29:40 2007 +0000
@@ -1,3 +1,8 @@
+2007-03-05  John W. Eaton  <jwe@octave.org>
+
+	* optimization/sqp.m: Defer first call to obj_hess until after
+	calling obj_fun.
+
 2007-03-02  Bob Weigel <rweigel@gmu.edu>
 
 	* specfun/nchoosek.m: Fix nargin check.
--- a/scripts/optimization/sqp.m	Mon Mar 05 18:41:57 2007 +0000
+++ b/scripts/optimization/sqp.m	Mon Mar 05 21:29:40 2007 +0000
@@ -179,8 +179,6 @@
 
     n = length (x);
 
-    B = eye (n, n);
-
     ## Evaluate objective function, constraints, and gradients at initial
     ## value of x.
     ##
@@ -200,7 +198,6 @@
 	  if (length (objf) > 2)
 	    obj_hess = objf{3};
 	    have_hess = 1;
-	    B = feval (obj_hess, x);
 	  endif
 	endif
       else
@@ -257,6 +254,12 @@
 
     c = feval (obj_grd, x);
 
+    if (have_hess)
+      B = feval (obj_hess, x);
+    else
+      B = eye (n, n);
+    endif
+
     ce = feval (ce_fun, x);
     F = feval (ce_grd, x);