Mercurial > hg > octave-nkf
changeset 3971:41e7fa40ff4c
[project @ 2002-07-02 23:46:48 by jwe]
author | jwe |
---|---|
date | Tue, 02 Jul 2002 23:46:49 +0000 |
parents | 4f884e25aab9 |
children | c21bb69ea262 |
files | aclocal.m4 configure.in doc/interpreter/basics.txi install-octave.in liboctave/ChangeLog liboctave/NLEqn.cc liboctave/NLEqn.h src/ChangeLog src/DLD-FUNCTIONS/fsolve.cc src/DLD-FUNCTIONS/lsode.cc src/defaults.cc src/toplev.cc |
diffstat | 12 files changed, 108 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/aclocal.m4 +++ b/aclocal.m4 @@ -402,7 +402,7 @@ else octave_possible_pagers="less more page pg" case "$canonical_host_type" in - *-*-cygwin32) + *-*-cygwin*) octave_possible_pagers="$octave_possible_pagers more.com" ;; esac
--- a/configure.in +++ b/configure.in @@ -22,7 +22,7 @@ ### 02111-1307, USA. AC_INIT -AC_REVISION($Revision: 1.360 $) +AC_REVISION($Revision: 1.361 $) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1077,7 +1077,7 @@ AC_CHECK_FUNCS(getrusage times) case "$canonical_host_type" in - *-*-cygwin32) + *-*-cygwin*) AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define if your struct rusage only has time information.]) ;; esac
--- a/doc/interpreter/basics.txi +++ b/doc/interpreter/basics.txi @@ -816,7 +816,7 @@ #! /bin/octave -qf printf ("%s", program_name); for i = 1:nargin - printf (" %s", argv(i,:)); + printf (" %s", argv{i}); endfor printf ("\n"); @end group
--- a/install-octave.in +++ b/install-octave.in @@ -305,7 +305,7 @@ fi case "$canonical_host_type" in - *-*-cygwin32) + *-*-cygwin*) if $alt_dir; then echo "*** You have specified an installation directory different" echo "*** from the default. For Octave to run properly, you must"
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2002-07-02 John W. Eaton <jwe@bevo.che.wisc.edu> + + * NLEqn.cc (NLEqn::error_message): New function. + * NLEqn.h (NLEqn::solution_state, NLEqn::solution_ok): New functions. + 2002-07-01 John W. Eaton <jwe@bevo.che.wisc.edu> * lo-utils.cc (octave_fgetl): New function.
--- a/liboctave/NLEqn.cc +++ b/liboctave/NLEqn.cc @@ -164,6 +164,8 @@ F77_XFCN (hybrj1, HYBRJ1, (hybrj1_fcn, n, px, pfvec, pfjac, n, tol, info, pwa, lwa)); + solution_status = info; + if (f77_exception_encountered) (*current_liboctave_error_handler) ("unrecoverable error in hybrj1"); } @@ -179,6 +181,8 @@ F77_XFCN (hybrd1, HYBRD1, (hybrd1_fcn, n, px, pfvec, tol, info, pwa, lwa)); + solution_status = info; + if (f77_exception_encountered) (*current_liboctave_error_handler) ("unrecoverable error in hybrd1"); } @@ -189,6 +193,50 @@ return retval; } +std::string +NLEqn::error_message (void) const +{ + std::string retval; + + std::string prefix; + + int info = solution_status; + if (info < 0) + info = -info; + + switch (info) + { + case 0: + retval = "improper input parameters"; + break; + + case 1: + retval = "solution converged within specified tolerance"; + break; + + case 2: + retval = "number of function calls exceeded limit"; + break; + + case 3: + retval = "no further improvement possible (tolerance may be too small)"; + break; + + case 4: + retval = "iteration is not making good progress"; + break; + + default: + retval = "unknown error state"; + break; + } + + if (solution_status < 0) + retval = std::string ("user requested termination: ") + retval; + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/NLEqn.h +++ b/liboctave/NLEqn.h @@ -75,13 +75,14 @@ public: NLEqn (void) - : NLFunc (), NLEqn_options (), x () { } + : NLFunc (), NLEqn_options (), x (), solution_status (0) { } NLEqn (const ColumnVector& xx, const NLFunc f) - : NLFunc (f), NLEqn_options (), x (xx) { } + : NLFunc (f), NLEqn_options (), x (xx), solution_status (0) { } NLEqn (const NLEqn& a) - : NLFunc (a.fun, a.jac), NLEqn_options (), x (a.x) { } + : NLFunc (a.fun, a.jac), NLEqn_options (), x (a.x), + solution_status (a.solution_status) { } NLEqn& operator = (const NLEqn& a) { @@ -91,6 +92,7 @@ NLEqn_options::operator = (a); x = a.x; + solution_status = a.solution_status; } return *this; } @@ -124,9 +126,16 @@ ColumnVector solve (int& info); - private: + int solution_state (void) const { return solution_status; } + + bool solution_ok (void) const { return solution_status == 1; } + + std::string error_message (void) const; + +private: ColumnVector x; + int solution_status; void error (const char* msg); };
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2002-07-02 John W. Eaton <jwe@bevo.che.wisc.edu> + + * defaults.cc (loadpath): Comment out previous change. + + * DLD-FUNCTIONS/fsolve.cc (Ffsolve): Return message too. Only + generate error if user is not at least requesting the info output. + + * DLD-FUNCTIONS/lsode.cc (Flsode): Fix typos in setting return value. + 2002-07-01 John W. Eaton <jwe@bevo.che.wisc.edu> * oct-stream.cc (printf_value_cache::double_value): If the current
--- a/src/DLD-FUNCTIONS/fsolve.cc +++ b/src/DLD-FUNCTIONS/fsolve.cc @@ -151,7 +151,7 @@ DEFUN_DLD (fsolve, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {[@var{x}, @var{info}] =} fsolve (@var{fcn}, @var{x0})\n\ +@deftypefn {Loadable Function} {[@var{x}, @var{info}, @var{msg}] =} fsolve (@var{fcn}, @var{x0})\n\ Given @var{fcn}, the name of a function of the form @code{f (@var{x})}\n\ and an initial starting point @var{x0}, @code{fsolve} solves the set of\n\ equations such that @code{f(@var{x}) == 0}.\n\ @@ -191,20 +191,30 @@ if (nargout > 2) warning ("fsolve: can't compute path output yet"); - NLFunc foo_fcn (fsolve_user_function); - NLEqn foo (x, foo_fcn); - foo.set_options (fsolve_opts); + NLFunc nleqn_fcn (fsolve_user_function); + NLEqn nleqn (x, nleqn_fcn); + nleqn.set_options (fsolve_opts); int info; - ColumnVector soln = foo.solve (info); + ColumnVector soln = nleqn.solve (info); - info = hybrd_info_to_fsolve_info (info); + if (! error_state) + { + std::string msg = nleqn.error_message (); + + retval(2) = msg; + retval(1) = static_cast<double> (hybrd_info_to_fsolve_info (info)); - retval.resize (nargout ? nargout : 1); - retval(0) = soln, 1; + if (nleqn.solution_ok ()) + retval(0) = soln; + else + { + retval(0) = Matrix (); - if (nargout > 1) - retval(1) = static_cast<double> (info); + if (nargout < 2) + error ("fsolve: %s", msg.c_str ()); + } + } } else print_usage ("fsolve");
--- a/src/DLD-FUNCTIONS/lsode.cc +++ b/src/DLD-FUNCTIONS/lsode.cc @@ -290,10 +290,10 @@ retval(1) = static_cast<double> (ode.integration_state ()); if (ode.integration_ok ()) - retval = output; + retval(0) = output; else { - output = Matrix (); + retval(0) = Matrix (); if (nargout < 2) {
--- a/src/defaults.cc +++ b/src/defaults.cc @@ -415,9 +415,11 @@ } else { - if (! (s[0] == ':' || s[s.length () - 1] == ':' - || s.find ("::") != NPOS)) - warning ("LOADPATH will ignore default load path"); + // I'm not sure whether this causes more problems that it + // solves... + // if (! (s[0] == ':' || s[s.length () - 1] == ':' + // || s.find ("::") != NPOS)) + // warning ("LOADPATH will ignore default load path"); Vload_path = s;
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -826,7 +826,7 @@ @end example\n\ \n\ @noindent\n\ -@code{argv} would be a list of strings with the elements\n\ +@code{argv} would be a cell array of strings with the elements\n\ @code{--no-line-editing} and @code{--silent}.\n\ \n\ If you write an executable Octave script, @code{argv} will contain the\n\