[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fsolve Patch for Function Handles
From: |
Todd Neal |
Subject: |
fsolve Patch for Function Handles |
Date: |
Sun, 6 Feb 2005 17:52:01 -0500 |
User-agent: |
Mutt/1.4.1i |
I was looking at the following page
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/fsolve.html
and couldn't get this example to work in Octave:
octave:1> x0=2
x0 = 2
octave:2> x = fsolve(@(x)sin(x.*x),x0)
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 3
I checked and fsolve was not handling parameters that were function
handles correctly, I modified it and it seems to work fine.
octave:1> x0=2
x0 = 2
octave:2> x = fsolve(@(x)sin(x.*x),x0)
x = 1.7725
I haven't looked at the code to Octave much in depth so there may
be a better way to do this or other repercussions from this patch.
Todd
*** a/fsolve.cc 17 Nov 2003 20:19:07 -0000 1.25
--- b/fsolve.cc 6 Feb 2005 22:40:10 -0000
*************** parameters for @code{fsolve}.\n\
*** 261,266 ****
--- 261,270 ----
octave_value f_arg = args(0);
+ if (f_arg.is_function_handle()) {
+ fsolve_fcn = f_arg.function_value();
+ }
+
switch (f_arg.rows ())
{
case 1:
- fsolve Patch for Function Handles,
Todd Neal <=