diff src/lsode.cc @ 519:b9284136189a

[project @ 1994-07-19 14:40:20 by jwe]
author jwe
date Tue, 19 Jul 1994 14:42:19 +0000
parents 309fc59f66ee
children c07674bbc3b1
line wrap: on
line diff
--- a/src/lsode.cc
+++ b/src/lsode.cc
@@ -35,25 +35,11 @@
 #include "error.h"
 #include "utils.h"
 #include "pager.h"
-#include "f-lsode.h"
+#include "defun-dld.h"
 
 // Global pointer for user defined function required by lsode.
 static tree_fvc *lsode_fcn;
 
-#ifdef WITH_DLD
-Octave_object
-builtin_lsode_2 (const Octave_object& args int nargout)
-{
-  return lsode (args, nargout);
-}
-
-Octave_object
-builtin_lsode_options_2 (const Octave_object& args, int nargout)
-{
-  return lsode_options (args, nargout);
-}
-#endif
-
 static ODE_options lsode_opts;
 
 ColumnVector
@@ -83,7 +69,7 @@
       args(1) = state;
     }
 
-  if (lsode_fcn != (tree_fvc *) NULL)
+  if (lsode_fcn)
     {
       Octave_object tmp = lsode_fcn->eval (0, 1, args);
 
@@ -107,18 +93,28 @@
   return retval;
 }
 
-Octave_object
-lsode (const Octave_object& args, int nargout)
+DEFUN_DLD ("lsode", Flsode, Slsode, 6, 1,
+  "lsode (F, X0, T_OUT, T_CRIT)\n\
+\n\
+The first argument is the name of the function to call to\n\
+compute the vector of right hand sides.  It must have the form\n\
+\n\
+  xdot = f (x, t)\n\
+\n\
+where xdot and x are vectors and t is a scalar.\n")
 {
-// Assumes that we have been given the correct number of arguments.
-
   Octave_object retval;
 
   int nargin = args.length ();
 
+  if (nargin < 4 || nargin > 5 || nargout > 1)
+    {
+      print_usage ("lsode");
+      return retval;
+    }
+
   lsode_fcn = is_valid_function (args(1), "lsode", 1);
-  if (lsode_fcn == (tree_fvc *) NULL
-      || takes_correct_nargs (lsode_fcn, 3, "lsode", 1) != 1)
+  if (! lsode_fcn || takes_correct_nargs (lsode_fcn, 3, "lsode", 1) != 1)
     return retval;
 
   ColumnVector state = args(2).to_vector ();
@@ -169,39 +165,39 @@
 static ODE_OPTIONS lsode_option_table [] =
 {
   { "absolute tolerance",
-    { "absolute", "tolerance", NULL, NULL, },
+    { "absolute", "tolerance", 0, 0, },
     { 1, 0, 0, 0, }, 1,
     ODE_options::set_absolute_tolerance,
     ODE_options::absolute_tolerance, },
 
   { "initial step size",
-    { "initial", "step", "size", NULL, },
+    { "initial", "step", "size", 0, },
     { 1, 0, 0, 0, }, 1,
     ODE_options::set_initial_step_size,
     ODE_options::initial_step_size, },
 
   { "maximum step size",
-    { "maximum", "step", "size", NULL, },
+    { "maximum", "step", "size", 0, },
     { 2, 0, 0, 0, }, 1,
     ODE_options::set_maximum_step_size,
     ODE_options::maximum_step_size, },
 
   { "minimum step size",
-    { "minimum", "step", "size", NULL, },
+    { "minimum", "step", "size", 0, },
     { 2, 0, 0, 0, }, 1,
     ODE_options::set_minimum_step_size,
     ODE_options::minimum_step_size, },
 
   { "relative tolerance",
-    { "relative", "tolerance", NULL, NULL, },
+    { "relative", "tolerance", 0, 0, },
     { 1, 0, 0, 0, }, 1,
     ODE_options::set_relative_tolerance,
     ODE_options::relative_tolerance, },
 
-  { NULL,
-    { NULL, NULL, NULL, NULL, },
+  { 0,
+    { 0, 0, 0, 0, },
     { 0, 0, 0, 0, }, 0,
-    NULL, NULL, },
+    0, 0, },
 };
 
 static void
@@ -219,7 +215,7 @@
   ODE_OPTIONS *list = lsode_option_table;
 
   char *keyword;
-  while ((keyword = list->keyword) != (char *) NULL)
+  while ((keyword = list->keyword) != 0)
     {
       output_buf.form ("  %-40s ", keyword);
 
@@ -242,7 +238,7 @@
 {
   ODE_OPTIONS *list = lsode_option_table;
 
-  while (list->keyword != (char *) NULL)
+  while (list->keyword != 0)
     {
       if (keyword_almost_match (list->kw_tok, list->min_len, keyword,
 				list->min_toks_to_match, MAX_TOKENS))
@@ -257,15 +253,20 @@
   warning ("lsode_options: no match for `%s'", keyword);
 }
 
-Octave_object
-lsode_options (const Octave_object& args, int nargout)
+DEFUN_DLD ("lsode_options", Flsode_options, Slsode_options, -1, 1,
+  "lsode_options (KEYWORD, VALUE)\n\
+\n\
+Set or show options for lsode.  Keywords may be abbreviated\n\
+to the shortest match.")
 {
   Octave_object retval;
 
   int nargin = args.length ();
 
   if (nargin == 1)
-    print_lsode_option_list ();
+    {
+      print_lsode_option_list ();
+    }
   else if (nargin == 3)
     {
       if (args(1).is_string_type ())