diff liboctave/LSODE.cc @ 3955:dc970f5941ee

[project @ 2002-05-23 20:28:56 by jwe]
author jwe
date Thu, 23 May 2002 20:28:56 +0000
parents 8194e0b10a9a
children 5a848097fe4a
line wrap: on
line diff
--- a/liboctave/LSODE.cc	Thu May 23 18:40:13 2002 +0000
+++ b/liboctave/LSODE.cc	Thu May 23 20:28:56 2002 +0000
@@ -37,6 +37,18 @@
 #include "f77-fcn.h"
 #include "lo-error.h"
 
+void
+LSODE_options::set_integration_method (const std::string& val)
+{
+  if (val == "stiff" || val == "bdf")
+    x_integration_method = "stiff";
+  else if (val == "non-stiff" || val == "adams")
+    x_integration_method = "non-stiff";
+  else
+    (*current_liboctave_error_handler)
+      ("lsode_options: method must be \"stiff\", \"bdf\", \"non-stiff\", or \"adams\"");
+}
+
 typedef int (*lsode_fcn_ptr) (const int&, const double&, double*,
 			      double*, int&);
 
@@ -66,9 +78,7 @@
 
   istate = 1;
   itask = 1;
-
-  liw = 20 + n;
-  lrw = 22 + n * (9 + n);
+  iopt = 0;
 
   sanity_checked = 0;
 }
@@ -86,9 +96,7 @@
 
   istate = 1;
   itask = 1;
-
-  liw = 20 + n;
-  lrw = 22 + n * (9 + n);
+  iopt = 0;
 
   sanity_checked = 0;
 }
@@ -165,6 +173,24 @@
       istate = 1;
     }
 
+  if (integration_method () == "stiff")
+    {
+      if (jac)
+	method_flag = 21;
+      else
+	method_flag = 22;
+
+      liw = 20 + n;
+      lrw = 22 + n * (9 + n);
+    }
+  else
+    {
+      method_flag = 10;
+
+      liw = 20;
+      lrw = 22 + 16 * n;
+    }
+
   if (iwork.length () != liw)
     {
       iwork.resize (liw);
@@ -181,9 +207,6 @@
 	rwork.elem (i) = 0;
     }
 
-  int method_flag = jac ? 21 : 22;
-  int iopt = 0;
-
   integration_error = 0;
 
   double *xp = x.fortran_vec ();