diff scripts/ode/odeset.m @ 20636:6e81f4b37e13

Performance improvements for ODE functions. * odeget.m: Place code for "fast" extraction of values at start of code before any other input validation. * odeset.m: Combine special input processing for nargin == 0 into one block of code. * integrate_adaptive.m, integrate_const.m: Use in-place operator "+= 1" rather than "++" because it is faster.
author Rik <rik@octave.org>
date Mon, 19 Oct 2015 08:22:23 -0700
parents 80e630b37ba1
children 516bb87ea72e
line wrap: on
line diff
--- a/scripts/ode/odeset.m	Sun Oct 18 09:55:41 2015 -0700
+++ b/scripts/ode/odeset.m	Mon Oct 19 08:22:23 2015 -0700
@@ -47,12 +47,6 @@
 
 function odestruct = odeset (varargin)
 
-  ## Special calling syntax to display defaults
-  if (nargin == 0 && nargout == 0)
-    print_options ();
-    return;
-  endif
-
   ## Column vector of all possible ODE options
   persistent options = {"AbsTol"; "BDF"; "Events"; "InitialSlope";
                         "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
@@ -61,13 +55,19 @@
                         "NonNegative"; "NormControl"; "OutputFcn"; "OutputSel";
                         "Refine"; "RelTol"; "Stats"; "Vectorized"};
 
+  if (nargin == 0)
+    ## Special calling syntax to display defaults
+    if (nargout == 0)
+      print_options ();
+    else
+      odestruct = cell2struct (cell (numel (options), 1), options);
+    endif
+    return;
+  endif
+
   ## initialize output
   odestruct = cell2struct (cell (numel (options), 1), options);
 
-  if (nargin == 0)
-    return;
-  endif
-
   if (isstruct (varargin{1}))
     oldstruct = varargin{1};