Mercurial > hg > octave-lyh
diff src/DLD-FUNCTIONS/lsode.cc @ 10154:40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Jan 2010 17:33:41 -0500 |
parents | 2cd940306a06 |
children | d0ce5e973937 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/lsode.cc +++ b/src/DLD-FUNCTIONS/lsode.cc @@ -74,26 +74,26 @@ octave_value_list tmp = lsode_fcn->do_multi_index_op (1, args); if (error_state) - { - gripe_user_supplied_eval ("lsode"); - return retval; - } + { + gripe_user_supplied_eval ("lsode"); + return retval; + } if (tmp.length () > 0 && tmp(0).is_defined ()) - { - if (! warned_fcn_imaginary && tmp(0).is_complex_type ()) - { - warning ("lsode: ignoring imaginary part returned from user-supplied function"); - warned_fcn_imaginary = true; - } + { + if (! warned_fcn_imaginary && tmp(0).is_complex_type ()) + { + warning ("lsode: ignoring imaginary part returned from user-supplied function"); + warned_fcn_imaginary = true; + } - retval = ColumnVector (tmp(0).vector_value ()); + retval = ColumnVector (tmp(0).vector_value ()); - if (error_state || retval.length () == 0) - gripe_user_supplied_eval ("lsode"); - } + if (error_state || retval.length () == 0) + gripe_user_supplied_eval ("lsode"); + } else - gripe_user_supplied_eval ("lsode"); + gripe_user_supplied_eval ("lsode"); } return retval; @@ -113,26 +113,26 @@ octave_value_list tmp = lsode_jac->do_multi_index_op (1, args); if (error_state) - { - gripe_user_supplied_eval ("lsode"); - return retval; - } + { + gripe_user_supplied_eval ("lsode"); + return retval; + } if (tmp.length () > 0 && tmp(0).is_defined ()) - { - if (! warned_jac_imaginary && tmp(0).is_complex_type ()) - { - warning ("lsode: ignoring imaginary part returned from user-supplied jacobian function"); - warned_jac_imaginary = true; - } + { + if (! warned_jac_imaginary && tmp(0).is_complex_type ()) + { + warning ("lsode: ignoring imaginary part returned from user-supplied jacobian function"); + warned_jac_imaginary = true; + } - retval = tmp(0).matrix_value (); + retval = tmp(0).matrix_value (); - if (error_state || retval.length () == 0) - gripe_user_supplied_eval ("lsode"); - } + if (error_state || retval.length () == 0) + gripe_user_supplied_eval ("lsode"); + } else - gripe_user_supplied_eval ("lsode"); + gripe_user_supplied_eval ("lsode"); } return retval; @@ -294,143 +294,143 @@ octave_value f_arg = args(0); if (f_arg.is_cell ()) - { - Cell c = f_arg.cell_value (); - if (c.length() == 1) - f_arg = c(0); - else if (c.length() == 2) - { - if (c(0).is_function_handle () || c(0).is_inline_function ()) - lsode_fcn = c(0).function_value (); - else - { - fcn_name = unique_symbol_name ("__lsode_fcn__"); - fname = "function y = "; - fname.append (fcn_name); - fname.append (" (x, t) y = "); - lsode_fcn = extract_function - (c(0), "lsode", fcn_name, fname, "; endfunction"); - } - - if (lsode_fcn) - { - if (c(1).is_function_handle () || c(1).is_inline_function ()) - lsode_jac = c(1).function_value (); - else - { - jac_name = unique_symbol_name ("__lsode_jac__"); - jname = "function jac = "; - jname.append(jac_name); - jname.append (" (x, t) jac = "); - lsode_jac = extract_function - (c(1), "lsode", jac_name, jname, "; endfunction"); + { + Cell c = f_arg.cell_value (); + if (c.length() == 1) + f_arg = c(0); + else if (c.length() == 2) + { + if (c(0).is_function_handle () || c(0).is_inline_function ()) + lsode_fcn = c(0).function_value (); + else + { + fcn_name = unique_symbol_name ("__lsode_fcn__"); + fname = "function y = "; + fname.append (fcn_name); + fname.append (" (x, t) y = "); + lsode_fcn = extract_function + (c(0), "lsode", fcn_name, fname, "; endfunction"); + } + + if (lsode_fcn) + { + if (c(1).is_function_handle () || c(1).is_inline_function ()) + lsode_jac = c(1).function_value (); + else + { + jac_name = unique_symbol_name ("__lsode_jac__"); + jname = "function jac = "; + jname.append(jac_name); + jname.append (" (x, t) jac = "); + lsode_jac = extract_function + (c(1), "lsode", jac_name, jname, "; endfunction"); - if (!lsode_jac) - { - if (fcn_name.length()) - clear_function (fcn_name); - lsode_fcn = 0; - } - } - } - } - else - LSODE_ABORT1 ("incorrect number of elements in cell array"); - } + if (!lsode_jac) + { + if (fcn_name.length()) + clear_function (fcn_name); + lsode_fcn = 0; + } + } + } + } + else + LSODE_ABORT1 ("incorrect number of elements in cell array"); + } if (!lsode_fcn && ! f_arg.is_cell()) - { - if (f_arg.is_function_handle () || f_arg.is_inline_function ()) - lsode_fcn = f_arg.function_value (); - else - { - switch (f_arg.rows ()) - { - case 1: - do - { - fcn_name = unique_symbol_name ("__lsode_fcn__"); - fname = "function y = "; - fname.append (fcn_name); - fname.append (" (x, t) y = "); - lsode_fcn = extract_function - (f_arg, "lsode", fcn_name, fname, "; endfunction"); - } - while (0); - break; + { + if (f_arg.is_function_handle () || f_arg.is_inline_function ()) + lsode_fcn = f_arg.function_value (); + else + { + switch (f_arg.rows ()) + { + case 1: + do + { + fcn_name = unique_symbol_name ("__lsode_fcn__"); + fname = "function y = "; + fname.append (fcn_name); + fname.append (" (x, t) y = "); + lsode_fcn = extract_function + (f_arg, "lsode", fcn_name, fname, "; endfunction"); + } + while (0); + break; - case 2: - { - string_vector tmp = f_arg.all_strings (); + case 2: + { + string_vector tmp = f_arg.all_strings (); - if (! error_state) - { - fcn_name = unique_symbol_name ("__lsode_fcn__"); - fname = "function y = "; - fname.append (fcn_name); - fname.append (" (x, t) y = "); - lsode_fcn = extract_function - (tmp(0), "lsode", fcn_name, fname, "; endfunction"); + if (! error_state) + { + fcn_name = unique_symbol_name ("__lsode_fcn__"); + fname = "function y = "; + fname.append (fcn_name); + fname.append (" (x, t) y = "); + lsode_fcn = extract_function + (tmp(0), "lsode", fcn_name, fname, "; endfunction"); - if (lsode_fcn) - { - jac_name = unique_symbol_name ("__lsode_jac__"); - jname = "function jac = "; - jname.append(jac_name); - jname.append (" (x, t) jac = "); - lsode_jac = extract_function - (tmp(1), "lsode", jac_name, jname, - "; endfunction"); + if (lsode_fcn) + { + jac_name = unique_symbol_name ("__lsode_jac__"); + jname = "function jac = "; + jname.append(jac_name); + jname.append (" (x, t) jac = "); + lsode_jac = extract_function + (tmp(1), "lsode", jac_name, jname, + "; endfunction"); - if (!lsode_jac) - { - if (fcn_name.length()) - clear_function (fcn_name); - lsode_fcn = 0; - } - } - } - } - break; + if (!lsode_jac) + { + if (fcn_name.length()) + clear_function (fcn_name); + lsode_fcn = 0; + } + } + } + } + break; - default: - LSODE_ABORT1 - ("first arg should be a string or 2-element string array"); - } - } - } + default: + LSODE_ABORT1 + ("first arg should be a string or 2-element string array"); + } + } + } if (error_state || ! lsode_fcn) - LSODE_ABORT (); + LSODE_ABORT (); ColumnVector state (args(1).vector_value ()); if (error_state) - LSODE_ABORT1 ("expecting state vector as second argument"); + LSODE_ABORT1 ("expecting state vector as second argument"); ColumnVector out_times (args(2).vector_value ()); if (error_state) - LSODE_ABORT1 ("expecting output time vector as third argument"); + LSODE_ABORT1 ("expecting output time vector as third argument"); ColumnVector crit_times; int crit_times_set = 0; if (nargin > 3) - { - crit_times = ColumnVector (args(3).vector_value ()); + { + crit_times = ColumnVector (args(3).vector_value ()); - if (error_state) - LSODE_ABORT1 ("expecting critical time vector as fourth argument"); + if (error_state) + LSODE_ABORT1 ("expecting critical time vector as fourth argument"); - crit_times_set = 1; - } + crit_times_set = 1; + } double tzero = out_times (0); ODEFunc func (lsode_user_function); if (lsode_jac) - func.set_jacobian_function (lsode_user_jacobian); + func.set_jacobian_function (lsode_user_jacobian); LSODE ode (state, tzero, func); @@ -438,32 +438,32 @@ Matrix output; if (crit_times_set) - output = ode.integrate (out_times, crit_times); + output = ode.integrate (out_times, crit_times); else - output = ode.integrate (out_times); + output = ode.integrate (out_times); if (fcn_name.length()) - clear_function (fcn_name); + clear_function (fcn_name); if (jac_name.length()) - clear_function (jac_name); + clear_function (jac_name); if (! error_state) - { - std::string msg = ode.error_message (); + { + std::string msg = ode.error_message (); - retval(2) = msg; - retval(1) = static_cast<double> (ode.integration_state ()); + retval(2) = msg; + retval(1) = static_cast<double> (ode.integration_state ()); - if (ode.integration_ok ()) - retval(0) = output; - else - { - retval(0) = Matrix (); + if (ode.integration_ok ()) + retval(0) = output; + else + { + retval(0) = Matrix (); - if (nargout < 2) - error ("lsode: %s", msg.c_str ()); - } - } + if (nargout < 2) + error ("lsode: %s", msg.c_str ()); + } + } } else print_usage ();