changeset 10050:dc88a0b6472c

support old style jacobian for fsolve
author Jaroslav Hajek <highegg@gmail.com>
date Sat, 02 Jan 2010 21:55:17 +0100
parents 44e889c67abe
children 4e6b245d4eb7
files scripts/ChangeLog scripts/optimization/fsolve.m
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sat Jan 02 12:16:55 2010 -0500
+++ b/scripts/ChangeLog	Sat Jan 02 21:55:17 2010 +0100
@@ -1,3 +1,7 @@
+2010-01-02  Jaroslav Hajek  <highegg@gmail.com>
+
+	* optimization/fsolve.m: Support old style jacobian passing.
+
 2010-01-01  Jaroslav Hajek  <highegg@gmail.com>
 
 	* set/powerset.m: New function.
--- a/scripts/optimization/fsolve.m	Sat Jan 02 12:16:55 2010 -0500
+++ b/scripts/optimization/fsolve.m	Sat Jan 02 21:55:17 2010 +0100
@@ -136,6 +136,8 @@
 
   if (ischar (fcn))
     fcn = str2func (fcn, "global");
+  elseif (iscell (fcn))
+    fcn = @(x) make_fcn_jac (x, fcn{1}, fcn{2});
   endif
 
   xsiz = size (x0);
@@ -423,6 +425,13 @@
   endif
 endfunction
 
+function [fx, jx] = make_fcn_jac (x, fcn, fjac)
+  fx = fcn (x);
+  if (nargout == 2)
+    jx = fjac (x);
+  endif
+endfunction
+
 %!function retval = f (p) 
 %!  x = p(1);
 %!  y = p(2);