Mercurial > hg > octave-lyh
changeset 3979:e0b7a493e5a8
[project @ 2002-07-10 17:45:34 by jwe]
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,36 @@ +2002-07-10 John W. Eaton <jwe@bevo.che.wisc.edu> + + * control/system/sysmult.m: Use varargin instead of old style varargs. + * control/system/sysadd.m: Likewise. + * control/system/sysgroup.m: Likewise. + * control/system/syssub.m: Likewise. + * elfun/gcd.m: Likewise. + * elfun/lcm.m: Likewise. + * general/common_size.m: Likewise. + * io/printf.m: Likewise. + * miscellaneous/menu.m: Likewise. + * miscellaneous/path.m: Likewise. + * plot/__errplot__.m: Likewise. + * plot/__plt__.m: Likewise. + * plot/axis.m: Likewise. + * plot/errorbar.m: Likewise. + * plot/mplot.m: Likewise. + * plot/loglog.m: Likewise. + * plot/plot.m: Likewise. + * plot/plot_border.m: Likewise. + * plot/semilogx.m: Likewise. + * plot/semilogy.m: Likewise. + * plot/xlabel.m: Likewise. + * plot/ylabel.m: Likewise. + * plot/zlabel.m: Likewise. + * statistics/base/ppplot.m: Likewise. + * statistics/base/qqplot.m: Likewise. + * statistics/tests/bartlett_test.m: Likewise. + * statistics/tests/kolmogorov_smirnov_test.m: Likewise. + * statistics/tests/kruskal_wallis_test.m: Likewise. + * strings/str2mat.m: Likewise. + * strings/strcat.m: Likewise. + 2002-06-27 Paul Kienzle <pkienzle@jazz.ncnr.nist.gov> * statistics/distributions/gamma_pdf.m: Avoid overflow in more cases.
--- a/scripts/control/system/sysadd.m +++ b/scripts/control/system/sysadd.m @@ -43,7 +43,7 @@ ## Created: July 1996 ## Updated for variable number of arguments July 1999 A. S. Hodel -function sys = sysadd (...) +function sys = sysadd (varargin) if(nargin < 1) usage("sysadd: sys = sysysadd(Gsys{,Hsys, ...})"); @@ -51,9 +51,8 @@ ## collect all arguments arglist = list(); - va_start(); for kk=1:nargin - arglist(kk) = va_arg(); + arglist(kk) = varargin{kk}; if(!is_struct(nth(arglist,kk))) error("sysadd: argument %d is not a data structure",kk); endif
--- a/scripts/control/system/sysgroup.m +++ b/scripts/control/system/sysgroup.m @@ -50,7 +50,7 @@ ## modified by John Ingram July 1996 ## A. S. Hodel: modified for variable number of arguments 1999 -function sys = sysgroup (...) +function sys = sysgroup (varargin) save_emp = empty_list_elements_ok; empty_list_elements_ok = 1; @@ -61,9 +61,8 @@ ## collect all arguments arglist = list(); - va_start(); for kk=1:nargin - arglist(kk) = va_arg(); + arglist(kk) = varargin{kk}; if(!is_struct(nth(arglist,kk))) error("sysgroup: argument %d is not a data structure",kk); endif
--- a/scripts/control/system/sysmult.m +++ b/scripts/control/system/sysmult.m @@ -36,7 +36,7 @@ ## Created: July 1996 ## updated for variable number of arguments by A. S. Hodel July 1999 -function sys = sysmult (...) +function sys = sysmult (varargin) if(nargin < 1) usage("sysmult: sys = sysmult(Asys{,Bsys,...})"); @@ -44,9 +44,8 @@ ## collect all arguments arglist = list(); - va_start(); for kk=1:nargin - arglist(kk) = va_arg(); + arglist(kk) = varargin{kk}; if(!is_struct(nth(arglist,kk))) error("sysadd: argument %d is not a data structure",kk); endif
--- a/scripts/control/system/syssub.m +++ b/scripts/control/system/syssub.m @@ -42,7 +42,7 @@ ## Created: July 1996 ## updated for variable numbers of input arguments by July 1999 A. S. Hodel -function sys = syssub (...) +function sys = syssub (varargin) if(nargin < 1) usage("syssub: sys = syssub(Gsys{,Hsys,...})"); @@ -50,9 +50,8 @@ ## collect all arguments arglist = list(); - va_start(); for kk=1:nargin - arglist(kk) = va_arg(); + arglist(kk) = varargin{kk}; if(!is_struct(nth(arglist,kk))) error("syssub: argument %d is not a data structure",kk); endif
--- a/scripts/elfun/gcd.m +++ b/scripts/elfun/gcd.m @@ -46,16 +46,16 @@ ## Created: 16 September 1994 ## Adapted-By: jwe -function [g, v] = gcd (a, ...) +function [g, v] = gcd (a, varargin) if (nargin == 0) usage ("[g, v] = gcd (a, ...)"); endif if (nargin > 1) - va_start; - for k = 2:nargin; - a = [a, (va_arg ())]; + k = 1; + for i = 2:nargin + a = [a, varargin{k++}]; endfor endif
--- a/scripts/elfun/lcm.m +++ b/scripts/elfun/lcm.m @@ -39,16 +39,16 @@ ## Created: 16 September 1994 ## Adapted-By: jwe -function l = lcm (a, ...) +function l = lcm (a, varargin) if (nargin == 0) usage ("lcm (a, ...)"); endif if (nargin > 1) - va_start; - for k = 2:nargin; - a = [a, (va_arg ())]; + k = 1; + for i = 2:nargin + a = [a, varargin{k++}]; endfor endif
--- a/scripts/general/common_size.m +++ b/scripts/general/common_size.m @@ -43,32 +43,26 @@ ## Created: 15 October 1994 ## Adapted-By: jwe -function [errorcode, ...] = common_size (...) +function [errorcode, varargout] = common_size (varargin) if (nargin < 2) error ("common_size: only makes sense if nargin >= 2"); endif - va_start (); - for k = 1 : nargin - s(k, :) = size (va_arg ()); + for i = 1 : nargin + s(i,:) = size (varargin{i}); endfor m = max (s); if (any (any ((s != 1)') & any ((s != ones (nargin, 1) * m)'))) errorcode = 1; - va_start (); - for k = 1 : nargin - vr_val (va_arg ()); - endfor + varargout = varargin; else errorcode = 0; - va_start (); - for k = 1 : nargin - if (prod (s(k, :)) == 1) - vr_val (va_arg () * ones (m)); - else - vr_val (va_arg ()); + for i = 1 : nargin + varargout{i} = varargin{i}; + if (prod (s(i,:)) == 1) + varargout{i} *= ones (m); endif endfor endif
--- a/scripts/io/printf.m +++ b/scripts/io/printf.m @@ -27,12 +27,12 @@ ## Author: jwe -function retval = printf (fmt, ...) +function retval = printf (fmt, varargin) retval = -1; if (nargin > 0) - retval = fprintf (stdout, fmt, all_va_args); + retval = fprintf (stdout, fmt, varargin{:}); else usage ("printf (fmt, ...)"); endif
--- a/scripts/miscellaneous/menu.m +++ b/scripts/miscellaneous/menu.m @@ -30,7 +30,7 @@ ## Author: jwe -function num = menu (t, ...) +function num = menu (t, varargin) if (nargin < 2) usage ("menu (title, opt1, ...)"); @@ -57,10 +57,9 @@ nopt = nargin - 1; while (1) - va_start (); for i = 1:nopt printf (" [%2d] ", i); - disp (va_arg ()); + disp (varargin{i}); endfor printf ("\n"); s = input ("pick a number, any number: ", "s");
--- a/scripts/miscellaneous/path.m +++ b/scripts/miscellaneous/path.m @@ -36,7 +36,7 @@ ## Author: jwe -function p = path (...) +function p = path (varargin) if (nargin == 0) if (nargout == 0) @@ -46,9 +46,9 @@ p = LOADPATH; endif else - p = va_arg (); + p = varargin{1}; for i = 2:nargin - p = sprintf ("%s:%s", p, va_arg ()); + p = sprintf ("%s:%s", p, varargin{i}); endfor LOADPATH = p; endif
--- a/scripts/plot/__errplot__.m +++ b/scripts/plot/__errplot__.m @@ -33,18 +33,18 @@ ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> ## Keywords: errorbar, plotting -function __errplot__ (...) +function __errplot__ (varargin) if (nargin < 3) # atleast two data arguments needed usage ("__errplot__ (arg1, ..., fmt)"); endif fstr = " "; - ndata = 0; + k = 1; while (nargin--) - a = va_arg (); + a = varargin{k++}; if (! isstr (a)) ndata++; eval (sprintf ("arg%d = a;", ndata));
--- a/scripts/plot/__plt__.m +++ b/scripts/plot/__plt__.m @@ -23,11 +23,11 @@ ## Author: jwe -function __plt__ (caller, ...) +function __plt__ (caller, varargin) if (nargin == 2) - __plt1__ (va_arg (), ""); + __plt1__ (varargin{1}, ""); elseif (nargin > 2) @@ -36,7 +36,8 @@ unwind_protect - x = va_arg (); + k = 1; + x = varargin{k++}; nargin = nargin - 2; x_set = 1; y_set = 0; @@ -46,7 +47,7 @@ while (nargin-- > 0) fmt = ""; - new = va_arg (); + new = varargin{k++}; if (isstr (new)) if (! x_set)
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -114,7 +114,7 @@ ## Author: jwe -function curr_axis = axis (ax, ...) +function curr_axis = axis (ax, varargin) ## This may not be correct if someone has used the gnuplot interface ## directly... @@ -259,7 +259,7 @@ endif if (nargin > 1) - axis(all_va_args); + axis (varargin{:}); endif endfunction
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -110,7 +110,7 @@ ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> ## Keywords: errorbar, plotting -function errorbar (...) +function errorbar (varargin) if (nargin < 2) usage ("errorbar (...)"); @@ -122,8 +122,9 @@ clg () endif hold ("on"); + k = 1; while (nargin) - a = va_arg (); + a = varargin{k++}; nargin--; if (is_vector (a)) a = a(:); @@ -138,7 +139,7 @@ fmt = " "; while (nargin) nargin--; - a = va_arg (); + a = varargin{k++}; if (isstr (a)) fmt = a; cmd = "__errplot__ (arg1";
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -28,7 +28,7 @@ ## Author: jwe -function loglog (...) +function loglog (varargin) ## XXX FIXME XXX -- these plot states should really just be set ## temporarily, probably inside an unwind_protect block, but there is @@ -38,6 +38,6 @@ gset logscale y; gset nopolar; - __plt__ ("loglog", all_va_args); + __plt__ ("loglog", varargin{:}); endfunction
--- a/scripts/plot/mplot.m +++ b/scripts/plot/mplot.m @@ -32,7 +32,7 @@ ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU> ## Adapted-By: jwe -function mplot (...) +function mplot (varargin) if (! gnuplot_has_multiplot) error ("mplot: gnuplot does not appear to support this feature"); @@ -51,7 +51,7 @@ gset nologscale; gset nopolar; - __plt__ ("plot", all_va_args); + __plt__ ("plot", varargin{:}); ## update the plot position
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -183,7 +183,7 @@ ## Author: jwe -function plot (...) +function plot (varargin) ## XXX FIXME XXX -- these plot states should really just be set ## temporarily, probably inside an unwind_protect block, but there is @@ -192,6 +192,6 @@ gset nologscale; gset nopolar; - __plt__ ("plot", all_va_args); + __plt__ ("plot", varargin{:}); endfunction
--- a/scripts/plot/plot_border.m +++ b/scripts/plot/plot_border.m @@ -51,7 +51,7 @@ ## Created: 3 July 95 ## Adapted-By: jwe -function plot_border (...) +function plot_border (varargin) if (! gnuplot_has_multiplot) error ("plot_border: gnuplot does not appear to support this feature"); @@ -64,11 +64,11 @@ all = 0; none = 1; - va_start (); + k = 1; while (nargin--) - arg = va_arg (); + arg = varargin{k++}; if (! isstr (arg)) error ("plot_border: input not a string");
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -28,7 +28,7 @@ ## Author: jwe -function semilogx (...) +function semilogx (varargin) ## XXX FIXME XXX -- these plot states should really just be set ## temporarily, probably inside an unwind_protect block, but there is @@ -38,6 +38,6 @@ gset nologscale y; gset nopolar; - __plt__ ("semilogx", all_va_args); + __plt__ ("semilogx", varargin{:}); endfunction
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -28,7 +28,7 @@ ## Author: jwe -function semilogy (...) +function semilogy (varargin) ## XXX FIXME XXX -- these plot states should really just be set ## temporarily, probably inside an unwind_protect block, but there is @@ -38,6 +38,6 @@ gset logscale y; gset nopolar; - __plt__ ("semilogy", all_va_args); + __plt__ ("semilogy", varargin{:}); endfunction
--- a/scripts/plot/xlabel.m +++ b/scripts/plot/xlabel.m @@ -30,8 +30,8 @@ ## Author: jwe -function xlabel (...) +function xlabel (varargin) - __axis_label__ ("xlabel", all_va_args); + __axis_label__ ("xlabel", varargin{:}); endfunction
--- a/scripts/plot/ylabel.m +++ b/scripts/plot/ylabel.m @@ -24,8 +24,8 @@ ## Author: jwe -function ylabel (...) +function ylabel (varargin) - __axis_label__ ("ylabel", all_va_args); + __axis_label__ ("ylabel", varargin{:}); endfunction
--- a/scripts/plot/zlabel.m +++ b/scripts/plot/zlabel.m @@ -26,8 +26,8 @@ ## Created: 3 July 95 ## Adapted-By: jwe -function zlabel (...) +function zlabel (varargin) - __axis_label__ ("zlabel", all_va_args); + __axis_label__ ("zlabel", varargin{:}); endfunction
--- a/scripts/statistics/base/ppplot.m +++ b/scripts/statistics/base/ppplot.m @@ -43,7 +43,7 @@ ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Perform a PP-plot (probability plot) -function [p, y] = ppplot (x, dist, ...) +function [p, y] = ppplot (x, dist, varargin) if (nargin < 1) usage ("ppplot (x, dist, params)"); @@ -64,7 +64,7 @@ if (nargin <= 2) y = feval (F, s); else - y = feval (F, s, all_va_args); + y = feval (F, s, varargin{:}); endif if (nargout == 0)
--- a/scripts/statistics/base/qqplot.m +++ b/scripts/statistics/base/qqplot.m @@ -45,7 +45,7 @@ ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Perform a QQ-plot (quantile plot) -function [q, s] = qqplot (x, dist, ...) +function [q, s] = qqplot (x, dist, varargin) if (nargin < 1) usage ("qqplot (x, dist, params)"); @@ -67,9 +67,9 @@ q = feval (f, t); q_label = f; else - param_string = sprintf ("%g", va_arg ()); + param_string = sprintf ("%g", varargin{1}); for k = 2 : (nargin - 2); - param_string = sprintf ("%s, %g", param_string, va_arg ()) + param_string = sprintf ("%s, %g", param_string, varargin{k}) endfor q = eval (sprintf ("%s (t, %s);", f, param_string)); q_label = sprintf ("%s with parameter(s) %s", f, param_string);
--- a/scripts/statistics/tests/bartlett_test.m +++ b/scripts/statistics/tests/bartlett_test.m @@ -35,7 +35,7 @@ ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Bartlett test for homogeneity of variances -function [pval, chisq, df] = bartlett_test (...) +function [pval, chisq, df] = bartlett_test (varargin) k = nargin; if (k < 2) @@ -44,9 +44,9 @@ f = zeros (k, 1); v = zeros (k, 1); - va_start (); + for i = 1 : k; - x = va_arg (); + x = varargin{i}; if (! is_vector (x)) error ("bartlett_test: all arguments must be vectors"); endif
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -50,7 +50,7 @@ ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: One-sample Kolmogorov-Smirnov test -function [pval, ks] = kolmogorov_smirnov_test (x, dist, ...) +function [pval, ks] = kolmogorov_smirnov_test (x, dist, varargin) if (nargin < 2) usage ("[pval, ks] = kolmogorov_smirnov_test (x, dist,, params, alt)"); @@ -71,7 +71,7 @@ else args = ""; for k = 1 : (nargin-2); - tmp = va_arg (); + tmp = varargin{k}; if isstr (tmp) alt = tmp; else
--- a/scripts/statistics/tests/kruskal_wallis_test.m +++ b/scripts/statistics/tests/kruskal_wallis_test.m @@ -38,7 +38,7 @@ ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Kruskal-Wallis test -function [pval, k, df] = kruskal_wallis_test (...) +function [pval, k, df] = kruskal_wallis_test (varargin) m = nargin; if (m < 2) @@ -47,9 +47,9 @@ n = []; p = []; - va_start; + for i = 1 : m; - x = va_arg (); + x = varargin{i}; if (! is_vector (x)) error ("kruskal_wallis_test: all arguments must be vectors"); endif
--- a/scripts/strings/str2mat.m +++ b/scripts/strings/str2mat.m @@ -32,7 +32,7 @@ ## Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> ## Adapted-By: jwe -function retval = str2mat (...) +function retval = str2mat (varargin) if (nargin == 0) usage ("str2mat (s1, ...)"); @@ -41,12 +41,10 @@ nc = 0; nr = 0; - va_start (); - nr = zeros (nargin, 1); nc = zeros (nargin, 1); for k = 1 : nargin - s = va_arg (); + s = varargin{k}; if (! isstr (s)) s = setstr (s); endif @@ -64,11 +62,9 @@ retval = setstr (ones (retval_nr, retval_nc) * toascii (" ")); - va_start (); - row_offset = 0; for k = 1 : nargin - s = va_arg (); + s = varargin{k}; if (! isstr (s)) s = setstr (s); endif
--- a/scripts/strings/strcat.m +++ b/scripts/strings/strcat.m @@ -33,7 +33,7 @@ ## Author: jwe -function st = strcat (s, t, ...) +function st = strcat (s, t, varargin) if (nargin > 1) save_empty_list_elements_ok = empty_list_elements_ok; @@ -45,8 +45,9 @@ error ("strcat: all arguments must be strings"); endif n = nargin - 2; + k = 1; while (n--) - tmp = va_arg (); + tmp = varargin{k++}; if (isstr (tmp)) tmpst = [tmpst, tmp]; else