Mercurial > hg > octave-nkf
changeset 2797:f81117f4754d
[project @ 1997-03-07 07:01:08 by jwe]
author | jwe |
---|---|
date | Fri, 07 Mar 1997 07:01:09 +0000 |
parents | 74bc1ede3c3d |
children | d477bceb9e2a |
files | src/ChangeLog src/dassl.cc src/fsolve.cc src/lsode.cc src/npsol.cc src/qpsol.cc src/quad.cc |
diffstat | 7 files changed, 101 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +Fri Mar 7 00:56:16 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + + * dassl.cc (show_dassl_option): For values that are determined + automatically, return a string instead of a magic value (-1.0). + * fsolve.cc (show_fsolve_option): Likewise. + * lsode.cc (show_lsode_option): Likewise. + * npsol.cc (show_npsol_option): Likewise. + * qpsol.cc (show_qpsol_option): Likewise. + + * variables.cc (extract_function): New function. + * dassl.cc (Fdassl): Use it instead of is_valid_function. + * fsolve.cc (Ffsolve): Likewise. + * npsol.cc (Fnpsol): Likewise. + * qpsol.cc (Fqpsol): Likewise. + * quad.cc (Fquad): Likewise. + Thu Mar 6 20:07:24 1997 John W. Eaton <jwe@bevo.che.wisc.edu> * sighandlers.cc (my_friendly_exit, octave_new_handler,
--- a/src/dassl.cc +++ b/src/dassl.cc @@ -126,7 +126,11 @@ return retval; } - dassl_fcn = is_valid_function (args(0), "dassl", 1); + dassl_fcn = extract_function + (args(0), "dassl", "__dassl_fcn__", + "function res = __dassl_fcn__ (x, xdot, t) res = ", + "; endfunction"); + if (! dassl_fcn) return retval; @@ -300,7 +304,7 @@ static octave_value_list show_dassl_option (const string& keyword) { - octave_value_list retval; + octave_value retval; DASSL_OPTIONS *list = dassl_option_table; @@ -309,7 +313,13 @@ if (keyword_almost_match (list->kw_tok, list->min_len, keyword, list->min_toks_to_match, MAX_TOKENS)) { - return (dassl_opts.*list->d_get_fcn) (); + double val = (dassl_opts.*list->d_get_fcn) (); + if (val < 0.0) + retval = "computed automatically"; + else + retval = val; + + return retval; } list++; }
--- a/src/fsolve.cc +++ b/src/fsolve.cc @@ -143,7 +143,9 @@ return retval; } - fsolve_fcn = is_valid_function (args(0), "fsolve", 1); + fsolve_fcn = extract_function (args(0), "fsolve", "__fsolve_fcn__", + "function y = __fsolve_fcn__ (x) y = ", + "; endfunction"); if (! fsolve_fcn) return retval; @@ -261,7 +263,7 @@ static octave_value_list show_fsolve_option (const string& keyword) { - octave_value_list retval; + octave_value retval; NLEQN_OPTIONS *list = fsolve_option_table; @@ -270,7 +272,13 @@ if (keyword_almost_match (list->kw_tok, list->min_len, keyword, list->min_toks_to_match, MAX_TOKENS)) { - return (fsolve_opts.*list->d_get_fcn) (); + double val = (fsolve_opts.*list->d_get_fcn) (); + if (val < 0.0) + retval = "computed automatically"; + else + retval = val; + + return retval; } list++; }
--- a/src/lsode.cc +++ b/src/lsode.cc @@ -58,7 +58,7 @@ if (nstates > 1) { Matrix m (nstates, 1); - for (int i = 0; i < nstates; i++) + for (int i = 0; i < nstates; i++) m (i, 0) = x (i); octave_value state (m); args(0) = state; @@ -114,7 +114,11 @@ return retval; } - lsode_fcn = is_valid_function (args(0), "lsode", 1); + lsode_fcn = extract_function + (args(0), "lsode", "__lsode_fcn__", + "function xdot = __lsode_fcn__ (x, t) xdot = ", + "; endfunction"); + if (! lsode_fcn) return retval; @@ -280,7 +284,7 @@ static octave_value_list show_lsode_option (const string& keyword) { - octave_value_list retval; + octave_value retval; LSODE_OPTIONS *list = lsode_option_table; @@ -289,7 +293,13 @@ if (keyword_almost_match (list->kw_tok, list->min_len, keyword, list->min_toks_to_match, MAX_TOKENS)) { - return (lsode_opts.*list->d_get_fcn) (); + double val = (lsode_opts.*list->d_get_fcn) (); + if (val < 0.0) + retval = "computed automatically"; + else + retval = val; + + return retval; } list++; }
--- a/src/npsol.cc +++ b/src/npsol.cc @@ -305,7 +305,11 @@ return retval; } - npsol_objective = is_valid_function (args(1), "npsol", 1); + npsol_objective = extract_function + (args(1), "npsol", "__npsol_obj__", + "function phi = __npsol_obj__ (x) phi = ", + "; endfunction"); + if (! npsol_objective) return retval; @@ -362,7 +366,10 @@ npsol_constraints = 0; if (nargin == 5 || nargin == 7 || nargin == 8 || nargin == 10) - npsol_constraints = is_valid_function (args(nargin-2), "npsol", 0); + npsol_constraints = extract_function + (args(nargin-2), "npsol", "__npsol_constr__", + "function y = __npsol_constr__ (x) y = ", + "; endfunction"); if (nargin == 7 || nargin == 5) { @@ -745,7 +752,7 @@ static octave_value_list show_npsol_option (const string& keyword) { - octave_value_list retval; + octave_value retval; NPSOL_OPTIONS *list = npsol_option_table; @@ -755,9 +762,23 @@ list->min_toks_to_match, MAX_TOKENS)) { if (list->d_get_fcn) - return (npsol_opts.*list->d_get_fcn) (); + { + double val = (npsol_opts.*list->d_get_fcn) (); + if (val < 0.0) + retval = "computed automatically"; + else + retval = val; + } else - return (double) (npsol_opts.*list->i_get_fcn) (); + { + int val = (npsol_opts.*list->i_get_fcn) (); + if (val < 0) + retval = "depends on problem size"; + else + retval = val; + } + + return retval; } list++; }
--- a/src/qpsol.cc +++ b/src/qpsol.cc @@ -386,7 +386,7 @@ static octave_value_list show_qpsol_option (const string& keyword) { - octave_value_list retval; + octave_value retval; QPSOL_OPTIONS *list = qpsol_option_table; @@ -396,9 +396,23 @@ list->min_toks_to_match, MAX_TOKENS)) { if (list->d_get_fcn) - return (qpsol_opts.*list->d_get_fcn) (); + { + double val = (qpsol_opts.*list->d_get_fcn) (); + if (val < 0.0) + retval = "computed automatically"; + else + retval = val; + } else - return (double) (qpsol_opts.*list->i_get_fcn) (); + { + int val = (qpsol_opts.*list->i_get_fcn) (); + if (val < 0) + retval = "depends on problem size"; + else + retval = val; + } + + return retval; } list++; }
--- a/src/quad.cc +++ b/src/quad.cc @@ -120,7 +120,9 @@ return retval; } - quad_fcn = is_valid_function (args(0), "quad", 1); + quad_fcn = extract_function (args(0), "quad", "__quad_fcn__", + "function y = __quad_fcn__ (x) y = ", + "; endfunction"); if (! quad_fcn) return retval; @@ -337,7 +339,7 @@ static octave_value_list show_quad_option (const string& keyword) { - octave_value_list retval; + octave_value retval; QUAD_OPTIONS *list = quad_option_table;