changeset 8016:dca99c492134

fsolve.cc: make override_options work
author John W. Eaton <jwe@octave.org>
date Thu, 07 Aug 2008 01:16:50 -0400
parents 30629059b72d
children 260294a5520f
files src/ChangeLog src/DLD-FUNCTIONS/fsolve.cc
diffstat 2 files changed, 59 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Aug 06 22:23:54 2008 +0200
+++ b/src/ChangeLog	Thu Aug 07 01:16:50 2008 -0400
@@ -1,3 +1,10 @@
+2008-08-07  John W. Eaton  <jwe@octave.org>
+
+	* DLD-FUNCTIONS/fsolve.cc (override_options): Don't fail if
+	options_map does not contain an expected keyword.
+	Fix typo in warning identifier.
+	(make_unimplemented_options): Use CamelCase names here.
+
 2008-08-06  Soren Hauberg  <hauberg@gmail.com>
 
 	* error.cc (Ferror): Update format of error messages in exmple.
--- a/src/DLD-FUNCTIONS/fsolve.cc	Wed Aug 06 22:23:54 2008 +0200
+++ b/src/DLD-FUNCTIONS/fsolve.cc	Thu Aug 07 01:16:50 2008 -0400
@@ -209,28 +209,28 @@
     {
       initialized = true;
 
-      options.insert ("largescale");
-      options.insert ("derivativecheck");
-      options.insert ("diagnostics");
-      options.insert ("diffmaxchange");
-      options.insert ("diffminchange");
-      options.insert ("display");
-      options.insert ("funvalcheck");
-      options.insert ("jacobian");
-      options.insert ("maxfunevals");
-      options.insert ("maxiter");
-      options.insert ("outputfcn");
-      options.insert ("plotfcns");
-      options.insert ("tolfun");
-      options.insert ("tolx");
-      options.insert ("typicalx");
-      options.insert ("jacobmult");
-      options.insert ("jacobpattern");
-      options.insert ("maxpcgiter");
-      options.insert ("precondbandwidth");
-      options.insert ("tolpcg");
-      options.insert ("nonleqnalgorithm");
-      options.insert ("linesearchtype");
+      options.insert ("Largescale");
+      options.insert ("DerivativeCheck");
+      options.insert ("Diagnostics");
+      options.insert ("DiffMaxChange");
+      options.insert ("DiffMinChange");
+      options.insert ("Display");
+      options.insert ("FunValCheck");
+      options.insert ("Jacobian");
+      options.insert ("MaxFunEvals");
+      options.insert ("MaxIter");
+      options.insert ("OutputFcn");
+      options.insert ("PlotFcns");
+      options.insert ("TolFun");
+      options.insert ("TolX");
+      options.insert ("TypicalX");
+      options.insert ("JacobMult");
+      options.insert ("JacobPattern");
+      options.insert ("MaxPCGIter");
+      options.insert ("PrecondBandwidth");
+      options.insert ("TolPCG");
+      options.insert ("NonlEqnAlgorithm");
+      options.insert ("LineSearchType");
     }
 
   return options;
@@ -244,28 +244,32 @@
   for (octave_idx_type i = 0; i < keys.length (); i++)
     {
       std::string key = keys(i);
-      std::transform (key.begin (), key.end (), key.begin (), tolower);
 
-      if (key == "tolx")
+      // FIXME -- we should be using case-insensitive comparisons.
+
+      if (key == "TolX")
 	{
-	  Cell c = option_map.contents (key);
+	  if (option_map.contains (key))
+	    {
+	      Cell c = option_map.contents (key);
 
-	  if (c.numel () == 1)
-	    {
-	      octave_value val = c(0);
+	      if (c.numel () == 1)
+		{
+		  octave_value val = c(0);
 
-	      if (! val.is_empty ())
-		{
-		  double dval = val.double_value ();
+		  if (! val.is_empty ())
+		    {
+		      double dval = val.double_value ();
 
-		  if (! error_state)
-		    opts.set_tolerance (dval);
-		  else
-		    gripe_wrong_type_arg ("fsolve", val);
+		      if (! error_state)
+			opts.set_tolerance (dval);
+		      else
+			gripe_wrong_type_arg ("fsolve", val);
+		    }
 		}
+	      else
+		error ("fsolve: invalid value for %s option", key.c_str ());
 	    }
-	  else
-	    error ("fsolve: invalid value for %s option", key.c_str ());
 	}
       else
 	{
@@ -274,16 +278,19 @@
 
 	  if (unimplemented_options.find (key) != unimplemented_options.end ())
 	    {
-	      Cell c = option_map.contents (key);
-
-	      if (c.numel () == 1)
+	      if (option_map.contains (key))
 		{
-		  octave_value val = c(0);
+		  Cell c = option_map.contents (key);
+
+		  if (c.numel () == 1)
+		    {
+		      octave_value val = c(0);
 
-		  if (! val.is_empty ())
-		    warning_with_id ("Octave:fsolve-unimplemented option",
-				     "fsolve: option `%s' not implemented",
-				     key.c_str ());
+		      if (! val.is_empty ())
+			warning_with_id ("Octave:fsolve-unimplemented-option",
+					 "fsolve: option `%s' not implemented",
+					 key.c_str ());
+		    }
 		}
 	    }
 	}