Mercurial > octave
diff scripts/ode/private/runge_kutta_23s.m @ 30893:e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
* accumarray.m, accumdim.m, quadl.m, quadv.m, randi.m, structfun.m,
__is_function__.m, uigetfile.m, uimenu.m, uiputfile.m, doc_cache_create.m,
colorspace_conversion_input_check.m, imageIO.m, argnames.m, vectorize.m,
vectorize.m, normest1.m, inputname.m, nthargout.m, display_info_file.m,
decic.m, ode15i.m, ode15s.m, ode23.m, ode23s.m, ode45.m, odeset.m,
check_default_input.m, integrate_adaptive.m, ode_event_handler.m,
runge_kutta_23.m, runge_kutta_23s.m, runge_kutta_45_dorpri.m,
runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m,
fminsearch.m, fminunc.m, fsolve.m, fzero.m, sqp.m, fplot.m, plotyy.m,
__bar__.m, __ezplot__.m, flat_entry.html, profexport.m, movfun.m, bicg.m,
bicgstab.m, cgs.m, eigs.m, gmres.m, pcg.m, __alltohandles__.m, __sprand__.m,
qmr.m, tfqmr.m, dump_demos.m:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 Apr 2022 18:14:56 -0700 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
line wrap: on
line diff
--- a/scripts/ode/private/runge_kutta_23s.m Mon Apr 04 11:22:26 2022 -0700 +++ b/scripts/ode/private/runge_kutta_23s.m Mon Apr 04 18:14:56 2022 -0700 @@ -24,10 +24,10 @@ ######################################################################## ## -*- texinfo -*- -## @deftypefn {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fun}, @var{t}, @var{x}, @var{dt}) -## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fun}, @var{t}, @var{x}, @var{dt}, @var{options}) -## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals}) -## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals}, @var{t_next}) +## @deftypefn {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fcn}, @var{t}, @var{x}, @var{dt}) +## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fcn}, @var{t}, @var{x}, @var{dt}, @var{options}) +## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fcn}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals}) +## @deftypefnx {} {[@var{t_next}, @var{x_next}] =} runge_kutta_23s (@var{fcn}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals}, @var{t_next}) ## @deftypefnx {} {[@var{t_next}, @var{x_next}, @var{x_est}] =} runge_kutta_23s (@dots{}) ## @deftypefnx {} {[@var{t_next}, @var{x_next}, @var{x_est}, @var{k_vals_out}] =} runge_kutta_23s (@dots{}) ## @@ -50,7 +50,7 @@ ## The optional fourth argument @var{options} specifies options for the ODE ## solver. It is a structure generated by @code{odeset}. In particular it ## contains the field @var{funarguments} with the optional arguments to be used -## in the evaluation of @var{fun}. +## in the evaluation of @var{fcn}. ## ## The optional fifth argument @var{k_vals_in} contains the Runge-Kutta ## evaluations of the previous step to use in a FSAL scheme. @@ -67,7 +67,7 @@ ## @seealso{runge_kutta_23} ## @end deftypefn -function [t_next, x_next, x_est, k] = runge_kutta_23s (fun, t, x, dt, +function [t_next, x_next, x_est, k] = runge_kutta_23s (fcn, t, x, dt, options = [], k_vals = [], t_next = t + dt) @@ -83,14 +83,14 @@ args = {}; endif - jacfun = false; + jacfcn = false; jacmat = false; if (! isempty (options.Jacobian)) if (ischar (options.Jacobian)) - jacfun = true; + jacfcn = true; jac = str2fun (options.Jacobian); elseif (is_function_handle (options.Jacobian)) - jacfun = true; + jacfcn = true; jac = options.Jacobian; elseif (ismatrix (options.Jacobian)) jacmat = true; @@ -110,15 +110,15 @@ ## Jacobian matrix, dfxpdp if (jacmat) J = jac; - elseif (jacfun) + elseif (jacfcn) J = jac (t, x); elseif (! jacpat) - J = __dfxpdp__ (x, @(a) feval (fun, t, a, args{:}), options.RelTol); + J = __dfxpdp__ (x, @(a) feval (fcn, t, a, args{:}), options.RelTol); elseif (jacpat) - J = __dfxpdp__ (x, @(a) feval (fun, t, a, args{:}), options.RelTol, pattern); + J = __dfxpdp__ (x, @(a) feval (fcn, t, a, args{:}), options.RelTol, pattern); endif - T = (feval (fun, t + .1 * dt, x) - feval (fun, t, x, args{:})) / (.1 * dt); + T = (feval (fcn, t + .1 * dt, x) - feval (fcn, t, x, args{:})) / (.1 * dt); ## Wolfbrandt coefficient if (isempty (options.Mass)) @@ -135,13 +135,13 @@ endif ## compute the slopes - F(:,1) = feval (fun, t, x, args{:}); + F(:,1) = feval (fcn, t, x, args{:}); if (issparse (W)) k(:,1) = Qw * (Uw \ (Lw \ (Pw * (Rw \ (F(:,1) + dt*d*T))))); else k(:,1) = Uw \ (Lw \ (Pw * (F(:,1) + dt*d*T))); endif - F(:,2) = feval (fun, t+a*dt, x+a*dt*k(:,1), args{:}); + F(:,2) = feval (fcn, t+a*dt, x+a*dt*k(:,1), args{:}); if (issparse (W)) k(:,2) = Uw * (Uw \ (Lw \ (Pw * (Rw \ (F(:,2) - M*k(:,1)))))) + k(:,1); else @@ -153,7 +153,7 @@ if (nargout >= 3) ## 3rd order, needed in error formula - F(:,3) = feval (fun, t+dt, x_next, args{:}); + F(:,3) = feval (fcn, t+dt, x_next, args{:}); if (issparse (W)) k(:,3) = Qw * (Uw \ (Lw \ (Pw * (Rw \ (F(:,3) - e32 * (M*k(:,2) - F(:,2)) - 2 * (M*k(:,1) - F(:,1)) + dt*d*T))))); else @@ -170,12 +170,12 @@ endfunction -function prt = __dfxpdp__ (p, func, rtol, pattern) +function prt = __dfxpdp__ (p, fcn, rtol, pattern) ## This subfunction was copied 2011 from the OF "optim" package ## "inst/private/__dfdp__.m". - f = func (p)(:); + f = fcn (p)(:); m = numel (f); n = numel (p); @@ -193,9 +193,9 @@ prt = pattern; # initialize Jacobian for j = find (any (pattern, 1)) ps(j) = p1(j); - tp1 = func (ps); + tp1 = fcn (ps); ps(j) = p2(j); - tp2 = func (ps); + tp2 = fcn (ps); pattern_nnz = find (pattern(:, j)); prt(pattern_nnz, j) = (tp1(pattern_nnz) - tp2(pattern_nnz)) / absdel(j); ps(j) = p(j); @@ -204,9 +204,9 @@ prt = zeros (m, n); # initialize Jacobian for j = 1:n ps(j) = p1(j); - tp1 = func (ps); + tp1 = fcn (ps); ps(j) = p2(j); - tp2 = func (ps); + tp2 = fcn (ps); prt(:, j) = (tp1(:) - tp2(:)) / absdel(j); ps(j) = p(j); endfor