From: <cd...@us...> - 2011-02-06 10:00:20
|
Revision: 8091 http://octave.svn.sourceforge.net/octave/?rev=8091&view=rev Author: cdf Date: 2011-02-06 10:00:14 +0000 (Sun, 06 Feb 2011) Log Message: ----------- fixed initial condition and coding style Modified Paths: -------------- trunk/octave-forge/extra/ocs/inst/tst/tst_daspk.m Modified: trunk/octave-forge/extra/ocs/inst/tst/tst_daspk.m =================================================================== --- trunk/octave-forge/extra/ocs/inst/tst/tst_daspk.m 2011-02-06 09:58:08 UTC (rev 8090) +++ trunk/octave-forge/extra/ocs/inst/tst/tst_daspk.m 2011-02-06 10:00:14 UTC (rev 8091) @@ -1,4 +1,4 @@ -## Copyright (C) 2006,2007,2008 Carlo de Falco +## Copyright (C) 2006,2007,2008,2011 Carlo de Falco ## ## This file is part of: ## OCS - A Circuit Simulator for Octave @@ -62,74 +62,74 @@ ## ## @end deftypefn -function [out] = tst_daspk (outstruct,x,t,tol,maxit,\ - pltvars,verbosity,daspkopts,dae_fun) +function [out] = tst_daspk (outstruct, x, t, tol, maxit, pltvars, verbosity, daspkopts, dae_fun) ## FIXME: add input check! if ((nargin < 6) || (nargin > 9)) - error("tst_daspk: wrong number of input parameters."); + error ("tst_daspk: wrong number of input parameters."); endif - if ~exist("verbosity") - verbosity = [0,0]; - elseif length(verbosity)<2 - verbosity(2) =0; + if (! exist ("verbosity")) + verbosity = [0, 0]; + elseif (length (verbosity) < 2) + verbosity(2) = 0; endif - if(verbosity(1)) - fprintf(1,"initial value:\n"); + if (verbosity(1)) + fprintf (1, "initial value:\n"); endif - daspk_options("print initial condition info",1); - daspk_options("maximum order",2); - daspk_options("initial step size",t(2)-t(1)); - daspk_options("relative tolerance",1e-3); + daspk_options ("print initial condition info",1); + daspk_options ("maximum order",2); + daspk_options ("initial step size",t(2)-t(1)); + daspk_options ("relative tolerance",1e-3); - if ( nargin > 8 ) - for ii = 1:2:length(daspkopts) - daspk_options (daspkopts{ii},daspkopts{ii+1}); + if (nargin > 8) + for ii = 1:2:length (daspkopts) + daspk_options (daspkopts{ii}, daspkopts{ii+1}); endfor endif - [A0,B,C] = asm_initialize_system(outstruct,x); + [A0, B, C] = asm_initialize_system (outstruct, x); - if nargin > 9 - JAC = @(x) dae_fun{1}(outstruct,x,t(1),B); - RES = @(x) dae_fun{2}(outstruct,x,t(1),B,C); - [x,ii,resnrm] = nls_newton_raphson(x,RES,JAC,tol,maxit,verbosity); + if (nargin > 9) + JAC = @(x) dae_fun{1} (outstruct, x, t(1), B); + RES = @(x) dae_fun{2} (outstruct, x, t(1), B, C); + [x, ii, resnrm] = nls_newton_raphson (x, RES, JAC, tol, maxit, verbosity); else - [out(:,1),ii] = nls_stationary(outstruct,x,tol,maxit); + [out(:,1), ii] = nls_stationary (outstruct, x, tol, maxit); endif - if nargin > 9 - JAC = @(x) dae_fun{3}(outstruct,x,t(1),B); - RES = @(x) dae_fun{4}(outstruct,x,t(1),B,C); + if (nargin > 9) + JAC = @(x) dae_fun{3} (outstruct, x, t(1), B); + RES = @(x) dae_fun{4} (outstruct, x, t(1), B, C); else - JAC = @(x,xdot,t,c) TSTDASPKFUNJAC(outstruct,x,xdot,A0,B,t,c); - RES = @(x,xdot,t) TSTDASPKFUNRES(outstruct,x,xdot,A0,B,C,t); + JAC = @(x,xdot,t,c) TSTDASPKFUNJAC (outstruct, x, xdot, A0, B, t, c); + RES = @(x,xdot,t) TSTDASPKFUNRES (outstruct, x, xdot, A0, B, C, t); endif - [out, xdot, istate, msg] = daspk ({RES,JAC}, x, zeros(size(x)), t); + [out, xdot, istate, msg] = daspk ({RES,JAC}, out(:,1), zeros (size (x)), t); - out = out'; - if verbosity(2) - utl_plot_by_name(t,out,outstruct,pltvars) + out = out.'; + if (verbosity(2)) + utl_plot_by_name (t, out, outstruct, pltvars) endif endfunction ## Jacobian for transient problem -function lhs = TSTDASPKFUNJAC(outstruct,x,xdot,A0,B,t,c) +function lhs = TSTDASPKFUNJAC (outstruct, x, xdot, A0, B, t, c) - [A1,Jac,res] = asm_build_system(outstruct,x,t); - lhs = ( c*(A0+A1) + B + Jac); + [A1, Jac, res] = asm_build_system (outstruct, x, t); + lhs = (c*(A0+A1) + B + Jac); endfunction + ## Residual for transient problem -function rhs = TSTDASPKFUNRES(outstruct,x,xdot,A0,B,C,t) +function rhs = TSTDASPKFUNRES (outstruct, x, xdot, A0, B, C, t) - [A1,Jac,res] = asm_build_system(outstruct,x,t); + [A1, Jac, res] = asm_build_system (outstruct, x, t); rhs = (A0+A1)*xdot + B*x + C + res; endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |