Mercurial > hg > octave-lojdl
changeset 14379:d738c29a2528 gui
Merge default onto gui
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 16 Feb 2012 21:47:16 -0500 |
parents | 75cb16d1292b (current diff) dbc99d17f0ad (diff) |
children | 80e8c03548a4 |
files | NEWS configure.ac scripts/deprecated/autocor.m scripts/deprecated/autocov.m scripts/deprecated/betai.m scripts/deprecated/cellidx.m scripts/deprecated/clg.m scripts/deprecated/cquad.m scripts/deprecated/dispatch.m scripts/deprecated/fstat.m scripts/deprecated/gammai.m scripts/deprecated/glpkmex.m scripts/deprecated/intwarning.m scripts/deprecated/is_duplicate_entry.m scripts/deprecated/is_global.m scripts/deprecated/krylovb.m scripts/deprecated/perror.m scripts/deprecated/replot.m scripts/deprecated/saveimage.m scripts/deprecated/strerror.m scripts/deprecated/values.m scripts/deprecated/weibcdf.m scripts/deprecated/weibinv.m scripts/deprecated/weibpdf.m scripts/deprecated/weibrnd.m scripts/plot/__gnuplot_drawnow__.m scripts/plot/spinmap.m |
diffstat | 696 files changed, 6802 insertions(+), 6941 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -3,6 +3,39 @@ ** A new GUI is now available with Octave. +Summary of important user-visible changes for version 3.8: +--------------------------------------------------------- + + ** Other new functions added in 3.8.0: + + colorcube + lines + rgbplot + + ** Deprecated functions. + + The following functions were deprecated in Octave 3.4 and have been + removed from Octave 3.8. + + autocor dispatch is_global strerror + autocov fstat krylovb values + betai gammai perror + cellidx glpkmex replot + cquad is_duplicate_entry saveimage + + The following functions have been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8): + + <none yet> + + The following keywords have been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8): + + static + + Summary of important user-visible changes for version 3.6: --------------------------------------------------------- @@ -710,9 +743,9 @@ be removed from Octave 3.8 (or whatever version is the second major release after 3.4): - autocor cellidx gammai krylovb saveimage - autocov dispatch glpkmex perror strerror - betai fstat is_global replot values + autocor cellidx gammai is_global replot values + autocov dispatch glpkmex krylovb saveimage + betai fstat intwarning perror strerror Summary of important user-visible changes for version 3.2: ---------------------------------------------------------
--- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ EXTERN_CFLAGS="$CFLAGS" EXTERN_CXXFLAGS="$CXXFLAGS" -AC_INIT([GNU Octave], [3.6.0], [http://octave.org/bugs.html], [octave]) +AC_INIT([GNU Octave], [3.7.0+], [http://octave.org/bugs.html], [octave]) dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION" @@ -649,7 +649,7 @@ OCTAVE_CHECK_LIBRARY(qhull, QHull, [Qhull library not found -- this will result in loss of functionality of some geometry functions.], - [qhull/libqhull.h libqhull.h qhull/qhull.h qhull.h], [qh_qhull], [], [], + [libqhull/libqhull.h qhull/libqhull.h libqhull.h qhull/qhull.h qhull.h], [qh_qhull], [], [], [warn_qhull= OCTAVE_CHECK_QHULL_VERSION OCTAVE_CHECK_QHULL_OK([TEXINFO_QHULL="@set HAVE_QHULL" @@ -2140,7 +2140,7 @@ AC_CHECK_FUNCS(basename canonicalize_file_name \ chmod dup2 endgrent endpwent execvp expm1 expm1f fork \ getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \ - getppid getpwent getpwuid getuid getwd _kbhit \ + getppid getpwent getpwuid getuid getwd _kbhit kill \ lgamma lgammaf lgamma_r lgammaf_r localtime_r log1p log1pf \ mkstemp pipe putenv \ realpath resolvepath rindex roundl select setgrent setlocale \
--- a/doc/interpreter/doccheck/aspell-octave.en.pws +++ b/doc/interpreter/doccheck/aspell-octave.en.pws @@ -120,6 +120,7 @@ chol Cholesky cholmod +chrominance cindex circ circshift @@ -138,6 +139,7 @@ collectoutput colorbar colormap +ColorOrder colperm Comint Commandline
--- a/doc/interpreter/grammar.txi +++ b/doc/interpreter/grammar.txi @@ -46,12 +46,12 @@ @item @code{endif} @tab @code{endmethods} @tab @code{endparfor} @item @code{endproperties} @tab @code{endswitch} @tab @code{endwhile} @item @code{enumeration} @tab @code{events} @tab @code{for} -@item @code{function} @tab @code{get} @tab @code{global} -@item @code{if} @tab @code{methods} @tab @code{otherwise} -@item @code{parfor} @tab @code{persistent} @tab @code{properties} -@item @code{return} @tab @code{set} @tab @code{static} -@item @code{switch} @tab @code{try} @tab @code{until} -@item @code{unwind_protect} @tab @code{unwind_protect_cleanup} @tab @code{while} +@item @code{function} @tab @code{global} @tab @code{if} +@item @code{methods} @tab @code{otherwise} @tab @code{parfor} +@item @code{persistent} @tab @code{properties} @tab @code{return} +@item @code{static} @tab @code{switch} @tab @code{try} +@item @code{until} @tab @code{unwind_protect} @tab @code{unwind_protect_cleanup} +@item @code{while} @end multitable The function @code{iskeyword} can be used to quickly check whether an
--- a/doc/interpreter/image.txi +++ b/doc/interpreter/image.txi @@ -127,10 +127,14 @@ @DOCSTRING(colormap) +@DOCSTRING(rgbplot) + @DOCSTRING(autumn) @DOCSTRING(bone) +@DOCSTRING(colorcube) + @DOCSTRING(cool) @DOCSTRING(copper) @@ -145,6 +149,8 @@ @DOCSTRING(jet) +@DOCSTRING(lines) + @DOCSTRING(ocean) @DOCSTRING(pink) @@ -166,9 +172,9 @@ An additional colormap is @code{gmap40}. This code map contains only colors with integer values of the red, green and blue components. This is a workaround for a limitation of gnuplot 4.0, that does not allow the color -of line or patch objects to be set, and so @code{gmap40} is useful for gnuplot -4.0 users, and in particular in conjunction with the @var{bar}, -@var{barh} or @var{contour} functions. +of line or patch objects to be set. @code{gmap40} is chiefly useful to gnuplot +4.0 users, and particularly in conjunction with the @var{bar}, @var{surf}, +and @var{contour} functions. @DOCSTRING(gmap40)
--- a/liboctave/caseless-str.h +++ b/liboctave/caseless-str.h @@ -23,6 +23,7 @@ #if !defined (octave_caseless_str_h) #define octave_caseless_str_h 1 +#include <cctype> #include <string> class caseless_str : public std::string
--- a/liboctave/regexp.h +++ b/liboctave/regexp.h @@ -33,7 +33,9 @@ #include "base-list.h" #include "str-vec.h" -class regexp +class +OCTAVE_API +regexp { public:
--- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -937,7 +937,13 @@ octave_cv_lib_qhull_version, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> -#if defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) +#if defined (HAVE_LIBQHULL_LIBQHULL_H) +# include <libqhull/libqhull.h> +# include <libqhull/qset.h> +# include <libqhull/geom.h> +# include <libqhull/poly.h> +# include <libqhull/io.h> +#elif defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) # if defined (HAVE_QHULL_LIBQHULL_H) # include <qhull/libqhull.h> # else @@ -974,7 +980,13 @@ octave_cv_lib_qhull_ok, [ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> -#if defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) +#if defined (HAVE_LIBQHULL_LIBQHULL_H) +# include <libqhull/libqhull.h> +# include <libqhull/qset.h> +# include <libqhull/geom.h> +# include <libqhull/poly.h> +# include <libqhull/io.h> +#elif defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) # if defined (HAVE_QHULL_LIBQHULL_H) # include <qhull/libqhull.h> # else
--- a/scripts/audio/wavread.m +++ b/scripts/audio/wavread.m @@ -244,6 +244,7 @@ endif endfunction -## Mark file as being tested. Tests for wavread/wavwrite pair are in -## wavwrite.m + +## Mark file as tested. Tests for wavread/wavwrite pair are in wavwrite.m. %!assert(1) +
deleted file mode 100644 --- a/scripts/deprecated/autocor.m +++ /dev/null @@ -1,59 +0,0 @@ -## Copyright (C) 1995-2012 Friedrich Leisch -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} autocor (@var{x}, @var{h}) -## Return the autocorrelations from lag 0 to @var{h} of vector @var{x}. -## If @var{h} is omitted, all autocorrelations are computed. -## If @var{x} is a matrix, the autocorrelations of each column are -## computed. -## The particular algorithm used is from the field of statistics and -## differs from the definition used in signal processing. -## @end deftypefn - -## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> -## Description: Compute autocorrelations - -## Deprecated in version 3.4 - -function retval = autocor (X, h) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "autocor is obsolete and will be removed from a future version of Octave; See the Octave-Forge signal package and the function xcor for a replacement"); - endif - - - if (nargin == 1) - retval = autocov (X); - elseif (nargin == 2) - retval = autocov (X, h); - else - print_usage (); - endif - - if (min (retval (1,:)) != 0) - retval = retval ./ (ones (rows (retval), 1) * retval(1,:)); - endif - -endfunction - - -
deleted file mode 100644 --- a/scripts/deprecated/autocov.m +++ /dev/null @@ -1,62 +0,0 @@ -## Copyright (C) 1995-2012 Friedrich Leisch -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} autocov (@var{x}, @var{h}) -## Return the autocovariances from lag 0 to @var{h} of vector @var{x}. -## If @var{h} is omitted, all autocovariances are computed. -## If @var{x} is a matrix, the autocovariances of each column are -## computed. -## The particular algorithm used is from the field of statistics and -## differs from the definition used in signal processing. -## @end deftypefn - -## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> -## Description: Compute autocovariances - -## Deprecated in version 3.4 - -function retval = autocov (X, h) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "autocov is obsolete and will be removed from a future version of Octave; See the Octave-Forge signal package and the function xcov for a replacement"); - endif - - [n, c] = size (X); - - if (isvector (X)) - n = length (X); - c = 1; - X = reshape (X, n, 1); - endif - - X = center (X); - - if (nargin == 1) - h = n - 1; - endif - - retval = zeros (h + 1, c); - - for i = 0 : h - retval(i+1, :) = diag (X(i+1:n, :).' * conj (X(1:n-i, :))).' / n; - endfor - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/betai.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 1994-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} betai (@var{a}, @var{b}, @var{x}) -## This function is provided for compatibility with older versions of -## Octave. New programs should use betainc instead. -## -## @code{betai (@var{a}, @var{b}, @var{x})} is the same as -## @code{betainc (@var{x}, @var{a}, @var{b})}. -## @end deftypefn - -## Author: jwe -## Created: 30 Jan 1998 - -## Deprecated in version 3.4 - -function retval = betai (a, b, x) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "betai is obsolete and will be removed from a future version of Octave; please use betainc instead"); - endif - - if (nargin == 3) - retval = betainc (x, a, b); - else - print_usage (); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/cellidx.m +++ /dev/null @@ -1,108 +0,0 @@ -## Copyright (C) 2000-2012 Auburn University. All rights reserved. -## -## This file is part of Octave. -## -## Octave program is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{idxvec}, @var{errmsg}] =} cellidx (@var{listvar}, @var{strlist}) -## Return indices of string entries in @var{listvar} that match strings -## in @var{strlist}. -## -## Both @var{listvar} and @var{strlist} may be passed as strings or -## string matrices. If they are passed as string matrices, each entry -## is processed by @code{deblank} prior to searching for the entries. -## -## The first output is the vector of indices in @var{listvar}. -## -## If @var{strlist} contains a string not in @var{listvar}, then -## an error message is returned in @var{errmsg}. If only one output -## argument is requested, then @var{cellidx} prints @var{errmsg} to the -## screen and exits with an error. -## @end deftypefn - -## deprecated in version 3.4 - -function [idxvec,errmsg] = cellidx (listvar, strlist) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "cellidx is obsolete and will be removed from a future version of Octave; use ismember instead"); - endif - - if (nargin != 2) - print_usage (); - endif - - if (ischar (strlist)) - tmp = strlist; - strlist = {}; - for kk = 1:rows(tmp) - strlist{kk} = deblank (tmp(kk,:)); - endfor - endif - - if (ischar (listvar)) - tmp = listvar; - listvar = {}; - for kk = 1:rows(tmp) - listvar{kk} = deblank (tmp(kk,:)); - endfor - endif - - ## initialize size of idxvec (for premature return) - idxvec = zeros (length(strlist), 1); - - errmsg = ""; - if (! iscellstr (listvar)) - errmsg = "listvar must be a list of strings"; - elseif (! iscellstr (strlist)) - errmsg = "strlist must be a list of strings"; - endif - - if (length (errmsg)) - if (nargout < 2) - error (errmsg); - else - return; - endif - endif - - nsigs = length(listvar); - for idx = 1:length(strlist) - signame = strlist{idx}; - for jdx = 1:nsigs - if (strcmp (signame, listvar{jdx})) - if (idxvec(idx) != 0) - warning ("Duplicate signal name %s (%d,%d)\n", - listvar{jdx}, jdx, idxvec(idx)); - else - idxvec(idx) = jdx; - endif - endif - endfor - if (idxvec(idx) == 0) - errmsg = sprintf ("Did not find %s", signame); - if (nargout == 1) - error (errmsg); - else - break; - endif - endif - endfor - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/clg.m +++ /dev/null @@ -1,40 +0,0 @@ -## Copyright (C) 2006-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} clg () -## This function has been deprecated. Use clf instead. -## @end deftypefn - -## Author: jwe - -## Deprecated in version 3.0 -## Matlab still has this function, so don't remove just yet. - -function clg () - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "clg is obsolete and will be removed from a future version of Octave, please use clf instead"); - endif - - clf (); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/cquad.m +++ /dev/null @@ -1,39 +0,0 @@ -## Copyright (C) 2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{int}, @var{err}, @var{nr_points}] =} cquad (@var{f}, @var{a}, @var{b}, @var{tol}) -## @deftypefnx {Function File} {[@var{int}, @var{err}, @var{nr_points}] =} cquad (@var{f}, @var{a}, @var{b}, @var{tol}, @var{sing}) -## This function is an alias for compatibility with older versions of -## Octave. New programs should use @code{quadcc} instead. -## @seealso{quadcc} -## @end deftypefn - -## Deprecated in version 3.4 - -function retval = cquad (varargin) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "cquad has been renamed to quadcc and this alias will be removed from a future version of Octave; please use quadcc instead"); - endif - - retval = quadcc (varargin{:}); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/dispatch.m +++ /dev/null @@ -1,103 +0,0 @@ -## Copyright (C) 2010-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Loadable Function} {} dispatch (@var{f}, @var{r}, @var{type}) -## -## Replace the function @var{f} with a dispatch so that function @var{r} -## is called when @var{f} is called with the first argument of the named -## @var{type}. If the type is @var{any} then call @var{r} if no other type -## matches. The original function @var{f} is accessible using -## @code{builtin (@var{f}, @dots{})}. -## -## If @var{r} is omitted, clear dispatch function associated with @var{type}. -## -## If both @var{r} and @var{type} are omitted, list dispatch functions -## for @var{f}. -## @seealso{builtin} -## @end deftypefn - -## Deprecated in version 3.4 - -function varargout = dispatch (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "dispatch is obsolete and will be removed from a future version of Octave; please use classes instead"); - endif - - varargout = cell (nargout, 1); - [ varargout{:} ] = __dispatch__ (varargin{:}); - -endfunction - - -%!test # builtin function replacement -%! dispatch('sin','length','string') -%! assert(sin("abc"),3) -%! assert(sin(0),0,10*eps); - -%!test # 'any' function -%! dispatch('sin','exp','any') -%! assert(sin(0),1,eps); -%! assert(sin("abc"),3); - -%!test # 'builtin' function -%! assert(builtin('sin',0),0,eps); -%! builtin('eval','x=1;'); -%! assert(x,1); - -%!test # clear function mapping -%! dispatch('sin','string') -%! dispatch('sin','any') -%! assert(sin(0),0,10*eps); - -%!test # oct-file replacement -%! dispatch('fft','length','string') -%! assert(fft([1,1]),[2,0]); -%! assert(fft("abc"),3) -%! dispatch('fft','string'); - -%!test # m-file replacement -%! dispatch('hamming','length','string') -%! assert(hamming(1),1) -%! assert(hamming("abc"),3) -%! dispatch('hamming','string') - -%!test # override preloaded builtin -%! evalin('base','cos(1);'); -%! dispatch('cos','length','string') -%! evalin('base','assert(cos("abc"),3)'); -%! evalin('base','assert(cos(0),1,eps)'); -%! dispatch('cos','string') - -%!test # override pre-loaded oct-file -%! evalin('base','qr(1);'); -%! dispatch('qr','length','string') -%! evalin('base','assert(qr("abc"),3)'); -%! evalin('base','assert(qr(1),1)'); -%! dispatch('qr','string'); - -%!test # override pre-loaded m-file -%! evalin('base','hanning(1);'); -%! dispatch('hanning','length','string') -%! evalin('base','assert(hanning("abc"),3)'); -%! evalin('base','assert(hanning(1),1)'); -%! dispatch('hanning','string');
deleted file mode 100644 --- a/scripts/deprecated/fstat.m +++ /dev/null @@ -1,35 +0,0 @@ -## Copyright (C) 2010-2012 VZLU Prague -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{info}, @var{err}, @var{msg}] =} fstat (fid) -## This function has been deprecated. Use stat instead. -## @end deftypefn - -## Deprecated in version 3.4 - -function [info, err, msg] = fstat (fid) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "fstat is obsolete and will be removed from a future version of Octave, please use stat instead"); - endif - - [info, err, msg] = stat (fid); -endfunction
deleted file mode 100644 --- a/scripts/deprecated/gammai.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 1994-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} gammai (@var{a}, @var{x}) -## This function is provided for compatibility with older versions of -## Octave. New programs should use @code{gammainc} instead. -## -## @code{gammai (@var{a}, @var{x})} is the same as -## @code{gammainc (@var{x}, @var{a})}. -## @end deftypefn - -## Author: jwe -## Created: 30 Jan 1998 - -## Deprecated in version 3.4 - -function retval = gammai (a, x) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "gammai is obsolete and will be removed from a future version of Octave; please use gammainc instead"); - endif - - if (nargin == 2) - retval = gammainc (x, a); - else - print_usage (); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/glpkmex.m +++ /dev/null @@ -1,117 +0,0 @@ -## Copyright (C) 2005-2012 Nicolo' Giorgetti -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{xopt}, @var{fmin}, @var{status}, @var{extra}] =} glpkmex (@var{sense}, @var{c}, @var{A}, @var{b}, @var{ctype}, @var{lb}, @var{ub}, @var{vartype}, @var{param}, @var{lpsolver}, @var{save_pb}) -## This function is provided for compatibility with the old @sc{matlab} -## interface to the GNU @sc{glpk} library. For Octave code, you should use -## the @code{glpk} function instead. -## @seealso{glpk} -## @end deftypefn - -function [xopt, fopt, status, extra] = glpkmex (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "glpkmex is obsolete and will be removed from a future version of Octave; please use glpk instead"); - endif - - ## If there is no input output the version and syntax - if (nargin < 4 || nargin > 11) - print_usage (); - return; - endif - - ## reorder args: - ## - ## glpkmex glpk - ## - ## 1 sense c - ## 2 c a - ## 3 a b - ## 4 b lb - ## 5 ctype ub - ## 6 lb ctype - ## 7 ub vartype - ## 8 vartype sense - ## 9 param param - ## 10 lpsolver - ## 11 savepb - - sense = varargin{1}; - c = varargin{2}; - a = varargin{3}; - b = varargin{4}; - - nx = length (c); - - if (nargin > 4) - ctype = varargin{5}; - else - ctype = repmat ("U", nx, 1); - endif - - if (nargin > 5) - lb = varargin{6}; - else - lb = repmat (-Inf, nx, 1); - endif - - if (nargin > 6) - ub = varargin{7}; - else - ub = repmat (Inf, nx, 1); - endif - - if (nargin > 7) - vartype = varargin{8}; - else - vartype = repmat ("C", nx, 1); - endif - - if (nargin > 8) - param = varargin{9}; - else - param = struct (); - endif - - if (nargin > 9 && ! isfield (param, "lpsolver")) - param.lpsolver = varargin{10}; - endif - - if (nargin > 10 && ! isfield (param, "save")) - param.save = varargin{11}; - endif - - if (nargout == 0) - glpk (c, a, b, lb, ub, ctype, vartype, sense, param); - elseif (nargout == 1) - xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); - elseif (nargout == 2) - [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param); - elseif (nargout == 3) - [xopt, fopt, status] = ... - glpk (c, a, b, lb, ub, ctype, vartype, sense, param); - else - [xopt, fopt, status, extra] = ... - glpk (c, a, b, lb, ub, ctype, vartype, sense, param); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/intwarning.m +++ /dev/null @@ -1,133 +0,0 @@ -## Copyright (C) 2008-2012 David Bateman -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} intwarning (@var{action}) -## @deftypefnx {Function File} {} intwarning (@var{s}) -## @deftypefnx {Function File} {@var{s} =} intwarning (@dots{}) -## Control the state of the warning for integer conversions and math -## operations. -## -## @table @asis -## @item "query" -## With an output argument, return the current state of the integer -## conversion and math warnings. With no output arguments, print the -## current state. -## @c Set example in small font to prevent overfull line -## -## @smallexample -## @group -## intwarning ("query") -## The state of warning "Octave:int-convert-nan" is "off" -## The state of warning "Octave:int-convert-non-int-val" is "off" -## The state of warning "Octave:int-convert-overflow" is "off" -## The state of warning "Octave:int-math-overflow" is "off" -## @end group -## @end smallexample -## -## @item "on" -## @itemx "off" -## Turn integer conversion and math warnings on (or off). If there is -## no output argument, then nothing is printed. Otherwise the original -## state of the state of the integer conversion and math warnings is -## returned in a structure array. -## @end table -## -## The original state of the integer warnings can be restored by passing -## the structure array returned by @code{intwarning} to a later call to -## @code{intwarning}. For example: -## -## @example -## @group -## s = intwarning ("off"); -## @dots{} -## intwarning (s); -## @end group -## @end example -## @seealso{warning} -## @end deftypefn - -## Deprecated in v. 3.4 - -function y = intwarning (x) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "intwarning is obsolete and will be removed from a future version of Octave; integer math no longer produces warnings -- supply your own checks if you need those"); - endif - - return; - - if (nargin != 1) - print_usage (); - else - if (nargout > 0) - y = warning("query", "Octave:int-convert-nan"); - y = [y; warning("query", "Octave:int-convert-non-int-val")]; - y = [y; warning("query", "Octave:int-convert-overflow")]; - y = [y; warning("query", "Octave:int-math-overflow")]; - endif - if (ischar (x)) - if (strcmpi (x, "query")) - if (nargout == 0) - __print_int_warn_state__ ("Octave:int-convert-nan"); - __print_int_warn_state__ ("Octave:int-convert-non-int-val"); - __print_int_warn_state__ ("Octave:int-convert-overflow"); - __print_int_warn_state__ ("Octave:int-math-overflow"); - printf("\n"); - endif - elseif (strcmpi (x, "on")) - warning ("on", "Octave:int-convert-nan"); - warning ("on", "Octave:int-convert-non-int-val"); - warning ("on", "Octave:int-convert-overflow"); - warning ("on", "Octave:int-math-overflow"); - elseif (strcmpi (x, "off")) - warning ("off", "Octave:int-convert-nan"); - warning ("off", "Octave:int-convert-non-int-val"); - warning ("off", "Octave:int-convert-overflow"); - warning ("off", "Octave:int-math-overflow"); - else - error ("intwarning: unrecognized argument"); - endif - elseif (isstruct(x)) - for fld = fieldnames (x) - if (strcmp ("Octave:int-convert-nan") - || strcmp ("Octave:int-convert-non-int-val") - || strcmp ("Octave:int-convert-overflow") - || strcmp ("Octave:int-cmath-overflow")) - s = getfield (x, fld); - if (! ischar (s) || !(strcmpi("s","on") || strcmpi("s","off"))) - error ("intwarning: unexpected warning state"); - endif - warning (s, fld); - else - error ("intwarning: unrecognized integer warning %s", fld); - endif - endfor - else - error ("intwarning: unexpected input"); - endif - endif -endfunction - -function __print_int_warn_state__ (s) - fprintf ("The state of warning \"%s\" is \"%s\"\n", - s, warning ("query", s).state); -endfunction
deleted file mode 100644 --- a/scripts/deprecated/is_duplicate_entry.m +++ /dev/null @@ -1,53 +0,0 @@ -## Copyright (C) 1996-2012 A. S. Hodel -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} is_duplicate_entry (@var{x}) -## Return non-zero if any entries in @var{x} are duplicates of one -## another. -## @seealso{unique} -## @end deftypefn - -## Author: A. S. Hodel <scotte@eng.auburn.edu> - -function retval = is_duplicate_entry (x) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "is_duplicate_entry is obsolete and will be removed from a future version of Octave; see the function unique for equivalent functionality"); - endif - - - if (nargin == 1) - if (ismatrix (x)) - lx = numel (x); - lx1 = lx-1; - x = sort (reshape (x, 1, lx)); - dx = x(1:lx1) - x(2:lx); - retval = sum (dx == 0); - else - error ("is_duplicate_entry: expecting matrix argument"); - endif - else - print_usage (); - endif - -endfunction -
deleted file mode 100644 --- a/scripts/deprecated/is_global.m +++ /dev/null @@ -1,37 +0,0 @@ -## Copyright (C) 1994-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} is_global (@var{name}) -## This function is provided for compatibility with older versions of -## Octave. New programs should use isglobal instead. -## @end deftypefn - -## Deprecated in version 3.4 - -function retval = is_global (name) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "is_global is obsolete and will be removed from a future version of Octave; please use isglobal instead"); - endif - - retval = isglobal(name); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/krylovb.m +++ /dev/null @@ -1,46 +0,0 @@ -## Copyright (C) 1993-2012 A. Scottedward Hodel -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{u}, @var{ucols}] =} krylovb (@var{A}, @var{V}, @var{k}, @var{eps1}, @var{pflg}) -## See @code{krylov}. -## @end deftypefn - -## Deprecated in version 3.4 - -function [Uret, Ucols] = krylovb (A, V, k, eps1, pflg) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "krylovb is obsolete and will be removed from a future version of Octave; please use [Uret, ~, Ucols] = krylov (...) instead"); - endif - - switch (nargin) - case (3) - [Uret, H, Ucols] = krylov (A, V, k); - case (4) - [Uret, H, Ucols] = krylov (A, V, k, eps1); - case (5) - [Uret, H, Ucols] = krylov (A, V, k, eps1, pflg); - otherwise - print_usage (); - endswitch - -endfunction
--- a/scripts/deprecated/module.mk +++ b/scripts/deprecated/module.mk @@ -2,39 +2,16 @@ deprecated_FCN_FILES = \ deprecated/__error_text__.m \ - deprecated/autocor.m \ - deprecated/autocov.m \ - deprecated/betai.m \ - deprecated/cellidx.m \ - deprecated/clg.m \ deprecated/cor.m \ deprecated/corrcoef.m \ - deprecated/cquad.m \ deprecated/cut.m \ - deprecated/dispatch.m \ deprecated/error_text.m \ - deprecated/fstat.m \ - deprecated/gammai.m \ - deprecated/glpkmex.m \ - deprecated/intwarning.m \ - deprecated/is_duplicate_entry.m \ - deprecated/is_global.m \ deprecated/isstr.m \ - deprecated/krylovb.m \ - deprecated/perror.m \ deprecated/polyderiv.m \ - deprecated/replot.m \ - deprecated/saveimage.m \ deprecated/setstr.m \ deprecated/shell_cmd.m \ - deprecated/strerror.m \ deprecated/studentize.m \ - deprecated/sylvester_matrix.m \ - deprecated/values.m \ - deprecated/weibcdf.m \ - deprecated/weibinv.m \ - deprecated/weibpdf.m \ - deprecated/weibrnd.m + deprecated/sylvester_matrix.m FCN_FILES += $(deprecated_FCN_FILES)
deleted file mode 100644 --- a/scripts/deprecated/perror.m +++ /dev/null @@ -1,45 +0,0 @@ -## Copyright (C) 1993-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} perror (@var{funcname}, @var{num}) -## Print the error message for function @var{funcname} corresponding to the -## error number @var{num}. This function is intended to be used to print -## useful error messages for those functions that return numeric error -## codes. -## @seealso{strerror} -## @end deftypefn - -## Author: jwe - -function perror (funcname, num) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "perror is obsolete and will be removed from a future version of Octave."); - endif - - if (nargin != 2) - print_usage (); - else - printf (strerror (funcname, num)); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/replot.m +++ /dev/null @@ -1,43 +0,0 @@ -## Copyright (C) 2005-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} replot () -## Refresh the plot window. -## @end deftypefn - -## Author: jwe - -## Deprecated in version 3.4 - -function replot () - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "replot is obsolete and will be removed from a future version of Octave; please use refresh instead"); - endif - - if (nargin == 0) - drawnow (); - else - print_usage (); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/saveimage.m +++ /dev/null @@ -1,314 +0,0 @@ -## Copyright (C) 1994-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} saveimage (@var{fname}, @var{img}, @var{fmt}) -## @deftypefnx {Function File} {} saveimage (@var{fname}, @var{img}, @var{fmt}, @var{map}) -## Save the matrix @var{img} to file @var{fname} in image format @var{fmt}. -## Valid values for @var{fmt} are -## -## @table @asis -## @item "img" -## Octave's image format. The current colormap is also saved in the file. -## -## @item "ppm" -## Portable pixmap format. -## -## @item "ps" -## PostScript format. -## @end table -## -## If the fourth argument is supplied, the specified colormap will also be -## saved along with the image. -## -## Note: if the colormap contains only two entries and these entries are -## black and white, the bitmap ppm and PostScript formats are used. If the -## image is a gray scale image (the entries within each row of the colormap -## are equal) the gray scale ppm and PostScript image formats are used, -## otherwise the full color formats are used. -## @seealso{imread, save, load, colormap} -## @end deftypefn - -## The conversion to PostScript is based on pbmtolps.c, which was -## written by -## -## George Phillips <phillips@cs.ubc.ca> -## Department of Computer Science -## University of British Columbia -## -## and is part of the portable bitmap utilities, - -## Author: Tony Richardson <arichard@stark.cc.oh.us> -## Created: July 1994 -## Adapted-By: jwe - -## Rewritten by jwe to avoid using octoppm and pbm routines so that -## people who don't have the pbm stuff installed can still use this -## function. -## -## The conversion to PostScript is based on pnmtops.c, which is part of -## the portable bitmap utilties and bears this copyright notice: -## -## Copyright (C) 1989 by Jef Poskanzer. -## -## Permission to use, copy, modify, and distribute this software and its -## documentation for any purpose and without fee is hereby granted, provided -## that the above copyright notice appear in all copies and that both that -## copyright notice and this permission notice appear in supporting -## documentation. This software is provided "as is" without express or -## implied warranty. - -function saveimage (fname, img, fmt, map) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "saveimage is obsolete and will be removed from a future version of Octave; please use imwrite instead"); - endif - - if (nargin < 2 || nargin > 4) - print_usage (); - endif - - if (nargin < 4) - if (size(img, 3) == 3) - [img, map] = rgb2ind(img); - else - map = colormap (); - endif - endif - - [map_nr, map_nc] = size (map); - - if (map_nc != 3) - error ("saveimage: MAP must be an N x 3 matrix"); - endif - - if (nargin < 3) - fmt = "img"; - elseif (! ischar (fmt)) - error ("saveimage: FMT specification must be a string"); - elseif (! (strcmp (fmt, "img") - || strcmp (fmt, "ppm") - || strcmp (fmt, "ps"))) - error ("saveimage: unsupported image format specification"); - endif - - if (! ismatrix (img)) - warning ("IMG variable is not a matrix"); - endif - - if (! ischar (fname)) - error ("saveimage: FNAME must be a string"); - endif - - ## If we just want Octave image format, save and return. - - if (strcmp (fmt, "img")) - save ("-text", fname, "map", "img"); - return; - endif - - ## Convert to another format if requested. - - grey = all (map(:,1) == map(:,2) && map(:,1) == map (:,3)); - - pbm = pgm = ppm = 0; - - map_sz = map_nr * map_nc; - - map = reshape (map, map_sz, 1); - - map (map > 1) = 1; - map (map < 0) = 0; - - map = round (255 * map); - - bw = (map_nr == 2 - && ((map(1,1) == 0 && map(2,1) == 255) - || (map(1,1) == 255 && map(2,1) == 0))); - - img = round (img'); - [img_nr, img_nc] = size (img); - - img_sz = img_nr * img_nc; - img = reshape (img, img_sz, 1); - - img (img > map_nr) = map_nr; - img (img <= 0) = 1; - - if (strcmp (fmt, "ppm")) - - ## Would be nice to make this consistent with the line used by the - ## load/save functions, but we need a good way to get username and - ## hostname information. - - time_string = ctime (time ()); - time_string = time_string (1:length (time_string)-1); - tagline = sprintf ("# Created by Octave %s, %s", - OCTAVE_VERSION, time_string); - - if (grey && bw) - - if (map(1) != 0) - map = [0; 1]; - else - map = [1; 0]; - endif - - n_long = rem (img_nc, 8); - tmp = zeros (ceil (img_nc/8), img_nr); - - k = ceil (img_nr/8); - tmp = zeros (k, img_nc); - - ## Append columns with zeros to original image so that - ## mod (cols, 8) = 0. - - bwimg = postpad (reshape (map(img), img_nr, img_nc), k * 8, 0); - - b = kron (pow2 (7:-1:0)', ones (1, img_nc)); - - for i = 1:k - tmp(i,:) = sum (bwimg(8*(i-1)+1:8*i,:) .* b); - endfor - - fid = fopen (fname, "wb"); - fprintf (fid, "P4\n%s\n%d %d\n", tagline, img_nr, img_nc); - fwrite (fid, tmp, "uchar"); - fprintf (fid, "\n"); - fclose (fid); - - elseif (grey) - - fid = fopen (fname, "wb"); - fprintf (fid, "P5\n%s\n%d %d\n255\n", tagline, img_nr, img_nc); - fwrite (fid, map(img), "uchar"); - fprintf (fid, "\n"); - fclose (fid); - - else - - img_idx = ((1:3:3*img_sz)+2)'; - map_idx = ((2*map_nr+1):map_sz)'; - - tmap = map(map_idx); - tmp(img_idx--) = tmap(img); - - map_idx = map_idx - map_nr; - tmap = map(map_idx); - tmp(img_idx--) = tmap(img); - - map_idx = map_idx - map_nr; - tmap = map(map_idx); - tmp(img_idx--) = tmap(img); - - fid = fopen (fname, "wb"); - fprintf (fid, "P6\n%s\n%d %d\n255\n", tagline, img_nr, img_nc); - fwrite (fid, tmp, "uchar"); - fprintf (fid, "\n"); - fclose (fid); - - endif - - elseif (strcmp (fmt, "ps") == 1) - - if (! grey) - error ("saveimage: must have a greyscale colormap for conversion to PostScript"); - endif - - bps = 8; - dpi = 300; - pagewid = 612; - pagehgt = 762; - MARGIN = 0.95; - devpix = dpi / 72.0 + 0.5; - pixfac = 72.0 / dpi * devpix; - - ## Compute padding to round cols * bps up to the nearest multiple of 8 - ## (nr and nc are switched because we transposed the image above). - - padright = (((img_nr * bps + 7) / 8) * 8 - img_nr * bps) / bps; - - scols = img_nr * pixfac; - srows = img_nc * pixfac; - scale = 1; - - if (scols > pagewid * MARGIN || srows > pagehgt * MARGIN) - if (scols > pagewid * MARGIN) - scale = scale * (pagewid / scols * MARGIN); - scols = scale * img_nr * pixfac; - srows = scale * img_nc * pixfac; - endif - if (srows > pagehgt * MARGIN) - scale = scale * (pagehgt / srows * MARGIN); - scols = scale * img_nr * pixfac; - srows = scale * img_nc * pixfac; - endif - warning ("image too large for page, rescaling to %g", scale); - endif - - llx = (pagewid - scols) / 2; - lly = (pagehgt - srows) / 2; - urx = llx + fix (scols + 0.5); - ury = lly + fix (srows + 0.5); - - fid = fopen (fname, "wb"); - - fprintf (fid, "%%!PS-Adobe-2.0 EPSF-2.0\n"); - fprintf (fid, "%%%%Creator: Octave %s (saveimage.m)\n", OCTAVE_VERSION); - fprintf (fid, "%%%%Title: %s\n", fname); - fprintf (fid, "%%%%Pages: 1\n"); - fprintf (fid, "%%%%BoundingBox: %d %d %d %d\n", - fix (llx), fix (lly), fix (urx), fix (ury)); - fprintf (fid, "%%%%EndComments\n"); - fprintf (fid, "/readstring {\n"); - fprintf (fid, " currentfile exch readhexstring pop\n"); - fprintf (fid, "} bind def\n"); - fprintf (fid, "/picstr %d string def\n", - fix ((img_nr + padright) * bps / 8)); - fprintf (fid, "%%%%EndProlog\n"); - fprintf (fid, "%%%%Page: 1 1\n"); - fprintf (fid, "gsave\n"); - fprintf (fid, "%g %g translate\n", llx, lly); - fprintf (fid, "%g %g scale\n", scols, srows); - fprintf (fid, "%d %d %d\n", img_nr, img_nc, bps); - fprintf (fid, "[ %d 0 0 -%d 0 %d ]\n", img_nr, img_nc, img_nc); - fprintf (fid, "{ picstr readstring }\n"); - fprintf (fid, "image\n"); - - img = map(img); - - fmt = "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n"; - fprintf (fid, fmt, img); - - if (rem (img_sz, 30) != 0) - fprintf (fid, "\n"); - endif - - fprintf (fid, "grestore\n"); - fprintf (fid, "showpage\n"); - fprintf (fid, "%%%%Trailer\n"); - fclose (fid); - - else - error ("saveimage: what happened to the image type?"); - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/strerror.m +++ /dev/null @@ -1,72 +0,0 @@ -## Copyright (C) 1995-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} strerror (@var{name}, @var{num}) -## Return the text of an error message for function @var{name} -## corresponding to the error number @var{num}. This function is intended -## to be used to print useful error messages for those functions that -## return numeric error codes. -## @end deftypefn - -## Author: jwe - -function msg = strerror (name, num) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "strerror is obsolete and will be removed from a future version of Octave."); - endif - - if (nargin != 2) - print_usage (); - endif - - if (! ischar (name)) - error ("strerror: first argument must be a string"); - endif - - if (! isscalar (num)) - error ("strerror: second argument must be a scalar"); - endif - - if (strcmp (name, "fsolve")) - - if (num == -2) - msg = "input error\n"; - elseif (num == -1) - msg = "error encountered in user-supplied function\n"; - elseif (num == 1) - msg = "solution converged to requested tolerance\n"; - elseif (num == 3) - msg = "iteration is not making good progress\n"; - elseif (num == 4) - msg = "iteration limit exceeded\n"; - else - error ("strerror: unrecognized error code for fsolve"); - endif - - else - - error ("strerror: unrecognized function NAME"); - - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/values.m +++ /dev/null @@ -1,61 +0,0 @@ -## Copyright (C) 1995-2012 Kurt Hornik -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} values (@var{x}) -## Return the different values in a column vector, arranged in ascending -## order. -## -## As an example, @code{values([1, 2, 3, 1])} returns the vector -## @code{[1, 2, 3]}. -## @end deftypefn - -## Author: KH <Kurt.Hornik@wu-wien.ac.at> -## Description: Extract unique elements - -## Deprecated in version 3.4 - -function v = values (x) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "values is obsolete and will be removed from a future version of Octave; please use unique instead"); - endif - - if (nargin != 1) - print_usage (); - endif - - if (! (isvector (x))) - error ("values: X must be a vector"); - endif - - i = any (isnan (x)); - ## HACK! - x = x(find(!isnan (x))); - n = length (x); - x = reshape (x, n, 1); - s = sort (x); - v = s([1; (find (s(2:n) > s(1:n-1)) + 1)]); - if (i) - v = [v; NaN]; - endif - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/weibcdf.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 2006-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} weibcdf (@var{x}, @var{scale}, @var{shape}) -## Compute the cumulative distribution function (CDF) at @var{x} of the -## Weibull distribution with shape parameter @var{scale} and scale -## parameter @var{shape}, which is -## -## @example -## 1 - exp(-(x/shape)^scale) -## @end example -## -## @noindent -## for @var{x} @geq{} 0. -## @end deftypefn - -## Deprecated in version 3.0 -## Matlab still has this function, so don't remove just yet. - -function cdf = weibcdf (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "weibcdf is obsolete and will be removed from a future version of Octave; please use wblcdf instead"); - endif - - cdf = wblcdf (varargin{:}); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/weibinv.m +++ /dev/null @@ -1,40 +0,0 @@ -## Copyright (C) 2006-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} weibinv (@var{x}, @var{scale}, @var{shape}) -## Compute the quantile (the inverse of the CDF) at @var{x} of the -## Weibull distribution with shape parameter @var{scale} and scale -## parameter @var{shape}. -## @end deftypefn - -## Deprecated in version 3.0 -## Matlab still has this function, so don't remove just yet. - -function inv = weibinv (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "weibinv is obsolete and will be removed from a future version of Octave; please use wblinv instead"); - endif - - inv = wblinv (varargin{:}); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/weibpdf.m +++ /dev/null @@ -1,47 +0,0 @@ -## Copyright (C) 2006-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} weibpdf (@var{x}, @var{scale}, @var{shape}) -## Compute the probability density function (PDF) at @var{x} of the -## Weibull distribution with shape parameter @var{scale} and scale -## parameter @var{shape} which is given by -## -## @example -## scale * shape^(-scale) * x^(scale-1) * exp(-(x/shape)^scale) -## @end example -## -## @noindent -## for @var{x} > 0. -## @end deftypefn - -## Deprecated in version 3.0 -## Matlab still has this function, so don't remove just yet. - -function pdf = weibpdf (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "weibpdf is obsolete and will be removed from a future version of Octave; please use wblpdf instead"); - endif - - pdf = wblpdf (varargin{:}); - -endfunction
deleted file mode 100644 --- a/scripts/deprecated/weibrnd.m +++ /dev/null @@ -1,46 +0,0 @@ -## Copyright (C) 2006-2012 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} weibrnd (@var{scale}, @var{shape}, @var{r}, @var{c}) -## @deftypefnx {Function File} {} weibrnd (@var{scale}, @var{shape}, @var{sz}) -## Return an @var{r} by @var{c} matrix of random samples from the -## Weibull distribution with parameters @var{scale} and @var{shape} -## which must be scalar or of size @var{r} by @var{c}. Or if @var{sz} -## is a vector return a matrix of size @var{sz}. -## -## If @var{r} and @var{c} are omitted, the size of the result matrix is -## the common size of @var{alpha} and @var{sigma}. -## @end deftypefn - -## Deprecated in version 3.0 -## Matlab still has this function, so don't remove just yet. - -function rnd = weibrnd (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "weibrnd is obsolete and will be removed from a future version of Octave; please use wblrnd instead"); - endif - - rnd = wblrnd (varargin{:}); - -endfunction -
--- a/scripts/elfun/acosd.m +++ b/scripts/elfun/acosd.m @@ -35,7 +35,8 @@ endfunction -%!assert (acosd (0:0.1:1), 180/pi*acos (0:0.1:1), -10*eps) +%!assert (acosd (0:0.1:1), 180/pi * acos (0:0.1:1), -10*eps) %!error acosd () %!error acosd (1, 2) +
--- a/scripts/elfun/acot.m +++ b/scripts/elfun/acot.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! x = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; %! v = [pi/6, pi/4, pi/3, pi/2, -pi/3, -pi/4, -pi/6]; -%! assert (all (abs (acot (x) - v) < sqrt (eps))); +%! assert (acot (x), v, sqrt (eps)); %!error acot () %!error acot (1, 2)
--- a/scripts/elfun/acotd.m +++ b/scripts/elfun/acotd.m @@ -35,7 +35,8 @@ endfunction -%!assert (acotd (0:10:90), 180./pi.*acot (0:10:90), -10*eps) +%!assert (acotd (0:10:90), 180/pi * acot (0:10:90), -10*eps) %!error acotd () %!error acotd (1, 2) +
--- a/scripts/elfun/acoth.m +++ b/scripts/elfun/acoth.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! v = -i*[pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6]; %! x = i*[rt3, 1, rt3/3, -rt3/3, -1, -rt3]; -%! assert (all (abs (acoth (x) - v) < sqrt (eps))); +%! assert (acoth (x), v, sqrt (eps)); %!error acoth () %!error acoth (1, 2)
--- a/scripts/elfun/acsc.m +++ b/scripts/elfun/acsc.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! v = [pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6]; %! x = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; -%! assert (all (abs (acsc (x) - v) < sqrt (eps))); +%! assert (acsc (x), v, sqrt (eps)); %!error acsc () %!error acsc (1, 2)
--- a/scripts/elfun/acscd.m +++ b/scripts/elfun/acscd.m @@ -35,7 +35,8 @@ endfunction -%!assert (acscd (0:10:90), 180/pi*acsc (0:10:90), -10*eps) +%!assert (acscd (0:10:90), 180/pi * acsc (0:10:90), -10*eps) %!error acscd () %!error acscd (1, 2) +
--- a/scripts/elfun/acsch.m +++ b/scripts/elfun/acsch.m @@ -38,7 +38,7 @@ %!test %! v = [pi/2*i, -pi/2*i]; %! x = [-i, i]; -%! assert (all (abs (acsch (x) - v) < sqrt (eps))); +%! assert (acsch (x), v, sqrt (eps)); %!error acsch () %!error acsch (1, 2)
--- a/scripts/elfun/asec.m +++ b/scripts/elfun/asec.m @@ -40,7 +40,8 @@ %! rt3 = sqrt (3); %! v = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; %! x = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; -%! assert (all (abs (asec (x) - v) < sqrt (eps))); +%! assert (asec (x), v, sqrt (eps)); %!error asec () %!error asec (1, 2) +
--- a/scripts/elfun/asecd.m +++ b/scripts/elfun/asecd.m @@ -35,7 +35,8 @@ endfunction -%!assert (asecd (0:10:90), 180./pi.*asec (0:10:90), -10*eps) +%!assert (asecd (0:10:90), 180/pi * asec (0:10:90), -10*eps) %!error asecd () %!error asecd (1, 2) +
--- a/scripts/elfun/asech.m +++ b/scripts/elfun/asech.m @@ -38,7 +38,7 @@ %!test %! v = [0, pi*i]; %! x = [1, -1]; -%! assert (all (abs (asech (x) - v) < sqrt (eps))); +%! assert (asech (x), v, sqrt (eps)); %!error asech () %!error asech (1, 2)
--- a/scripts/elfun/asind.m +++ b/scripts/elfun/asind.m @@ -35,7 +35,8 @@ endfunction -%!assert (asind (0:0.1:1), 180/pi*asin (0:0.1:1), -10*eps) +%!assert (asind (0:0.1:1), 180/pi * asin (0:0.1:1), -10*eps) %!error asind () %!error asind (1, 2) +
--- a/scripts/elfun/atand.m +++ b/scripts/elfun/atand.m @@ -35,7 +35,8 @@ endfunction -%!assert (atand (0:10:90), 180./pi.*atan (0:10:90), -10*eps) +%!assert (atand (0:10:90), 180/pi * atan (0:10:90), -10*eps) %!error atand () %!error atand (1, 2) +
--- a/scripts/elfun/cosd.m +++ b/scripts/elfun/cosd.m @@ -45,3 +45,4 @@ %!error cosd () %!error cosd (1, 2) +
--- a/scripts/elfun/cot.m +++ b/scripts/elfun/cot.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; %! v = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3]; -%! assert (all (abs (cot (x) - v) < sqrt (eps))); +%! assert (cot (x), v, sqrt (eps)); %!error cot () %!error cot (1, 2)
--- a/scripts/elfun/cotd.m +++ b/scripts/elfun/cotd.m @@ -41,3 +41,4 @@ %!error cotd () %!error cotd (1, 2) +
--- a/scripts/elfun/coth.m +++ b/scripts/elfun/coth.m @@ -38,7 +38,7 @@ %!test %! x = [pi/2*i, 3*pi/2*i]; %! v = [0, 0]; -%! assert (all (abs (coth (x) - v) < sqrt (eps))); +%! assert (coth (x), v, sqrt (eps)); %!error coth () %!error coth (1, 2)
--- a/scripts/elfun/csc.m +++ b/scripts/elfun/csc.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6]; %! v = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2]; -%! assert (all (abs (csc (x) - v) < sqrt (eps))); +%! assert (csc (x), v, sqrt (eps)); %!error csc () %!error csc (1, 2)
--- a/scripts/elfun/cscd.m +++ b/scripts/elfun/cscd.m @@ -41,3 +41,4 @@ %!error cscd () %!error cscd (1, 2) +
--- a/scripts/elfun/csch.m +++ b/scripts/elfun/csch.m @@ -38,7 +38,7 @@ %!test %! x = [pi/2*i, 3*pi/2*i]; %! v = [-i, i]; -%! assert (all (abs (csch (x) - v) < sqrt (eps))); +%! assert (csch (x), v, sqrt (eps)); %!error csch () %!error csch (1, 2)
--- a/scripts/elfun/sec.m +++ b/scripts/elfun/sec.m @@ -40,7 +40,7 @@ %! rt3 = sqrt (3); %! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; %! v = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1]; -%! assert (all (abs (sec (x) - v) < sqrt (eps))); +%! assert (sec (x), v, sqrt (eps)); %!error sec () %!error sec (1, 2)
--- a/scripts/elfun/secd.m +++ b/scripts/elfun/secd.m @@ -41,3 +41,4 @@ %!error secd () %!error secd (1, 2) +
--- a/scripts/elfun/sech.m +++ b/scripts/elfun/sech.m @@ -38,7 +38,7 @@ %!test %! x = [0, pi*i]; %! v = [1, -1]; -%! assert (all (abs (sech (x) - v) < sqrt (eps))); +%! assert (sech (x), v, sqrt (eps)); %!error sech () %!error sech (1, 2)
--- a/scripts/elfun/sind.m +++ b/scripts/elfun/sind.m @@ -44,3 +44,4 @@ %!error sind () %!error sind (1, 2) +
--- a/scripts/elfun/tand.m +++ b/scripts/elfun/tand.m @@ -47,3 +47,4 @@ %!error tand () %!error tand (1, 2) +
--- a/scripts/general/accumarray.m +++ b/scripts/general/accumarray.m @@ -68,11 +68,11 @@ ## @var{x} = [91, 92, 90, 92, 90, 89, 91, 89, 90, 100, 100, 100]; ## [@var{u}, ~, @var{j}] = unique (@var{x}); ## [accumarray(@var{j}', 1), @var{u}'] -## @result{} 2 89 -## 3 90 -## 2 91 -## 2 92 -## 3 100 +## @result{} 2 89 +## 3 90 +## 2 91 +## 2 92 +## 3 100 ## @end group ## @end example ## @@ -87,12 +87,12 @@ ## 2, 1, 2; ## 2, 3, 2], 101:105) ## @result{} ans(:,:,1) = [101, 0, 0; 0, 0, 0] -## ans(:,:,2) = [0, 0, 0; 206, 0, 208] +## @result{} ans(:,:,2) = [0, 0, 0; 206, 0, 208] ## @end group ## @end example ## ## The sparse option can be used as an alternative to the @code{sparse} -## constructor (@pxref{doc-sparse}). Thus +## constructor (@pxref{doc-sparse}). Thus ## ## @example ## sparse (@var{i}, @var{j}, @var{sv}) @@ -106,7 +106,7 @@ ## @end example ## ## @noindent -## For repeated indices, @code{sparse} adds the corresponding value. To +## For repeated indices, @code{sparse} adds the corresponding value. To ## take the minimum instead, use @code{min} as an accumulator function: ## ## @example @@ -368,24 +368,23 @@ endif endfunction -%!error (accumarray (1:5)) -%!error (accumarray ([1,2,3],1:2)) + %!assert (accumarray ([1;2;4;2;4],101:105), [101;206;0;208]) -%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105),cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208])) -%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105,[],@(x)sin(sum(x))),sin(cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208]))) -%!assert (accumarray ({[1 3 3 2 3 1 2 2 3 3 1 2],[3 4 2 1 4 3 4 2 2 4 3 4],[1 1 2 2 1 1 2 1 1 1 2 2]},101:112),cat(3,[0,0,207,0;0,108,0,0;0,109,0,317],[0,0,111,0;104,0,0,219;0,103,0,0])) -%!assert (accumarray ([1,1;2,1;2,3;2,1;2,3],101:105,[2,4],@max,NaN),[101,NaN,NaN,NaN;104,NaN,105,NaN]) +%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105), cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208])) +%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105,[],@(x)sin(sum(x))), sin (cat (3, [101,0,0;0,0,0],[0,0,0;206,0,208]))) +%!assert (accumarray ({[1 3 3 2 3 1 2 2 3 3 1 2],[3 4 2 1 4 3 4 2 2 4 3 4],[1 1 2 2 1 1 2 1 1 1 2 2]},101:112), cat (3, [0,0,207,0;0,108,0,0;0,109,0,317], [0,0,111,0;104,0,0,219;0,103,0,0])) +%!assert (accumarray ([1,1;2,1;2,3;2,1;2,3],101:105,[2,4],@max,NaN), [101,NaN,NaN,NaN;104,NaN,105,NaN]) %!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105, [], @prod), [101, 0, 0; 10608, 0, 10815]) -%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2 4],@prod,0,true),sparse([1,2,2],[1,1,3],[101,10608,10815],2,4)) +%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2 4],@prod,0,true), sparse ([1,2,2],[1,1,3],[101,10608,10815],2,4)) %!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],1,[2,4]), [1,0,0,0;2,0,2,0]) -%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x)length(x)>1),[false,false,false,false;true,false,true,false]) +%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x)length(x)>1), [false,false,false,false;true,false,true,false]) %!assert (accumarray ([1; 2], [3; 4], [2, 1], @min, [], 0), [3; 4]) %!assert (accumarray ([1; 2], [3; 4], [2, 1], @min, [], 1), sparse ([3; 4])) %!assert (accumarray ([1; 2], [3; 4], [1, 2], @min, [], 0), [3, 4]) %!assert (accumarray ([1; 2], [3; 4], [1, 2], @min, [], 1), sparse ([3, 4])) %!test -%! A = accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x){x}); -%! assert (A{2},[102;104]) +%! A = accumarray ([1 1; 2 1; 2 3; 2 1; 2 3], 101:105, [2,4], @(x){x}); +%! assert (A{2},[102;104]); %!test %! subs = ceil (rand (2000, 3)*10); %! vals = rand (2000, 1); @@ -405,4 +404,6 @@ %! vals = rand (2000, 1); %! assert (accumarray (subsc, vals, [], @max), accumarray (subs, vals, [], @max)); +%!error (accumarray (1:5)) +%!error (accumarray ([1,2,3],1:2))
--- a/scripts/general/accumdim.m +++ b/scripts/general/accumdim.m @@ -50,7 +50,7 @@ ## -12, 2, 8; ## -10, 9, -3; ## -5, -3, -13]) -## @result{} ans = [-10,-11,-1;-15,-3,5] +## @result{} [-10,-11,-1;-15,-3,5] ## @end group ## @end example ## @@ -148,6 +148,7 @@ endfunction + %%test accumdim vs. accumarray %!shared a @@ -157,3 +158,4 @@ %!assert (accumdim ([2;3;2;2;2], a, 2, 4)(4,:,2), accumarray ([2;3;2;2;2], a(4,:,2), [1,4])) %!assert (accumdim ([2;3;2;1;2], a, 3, 3, @min)(1,5,:), accumarray ([2;3;2;1;2], a(1,5,:), [1,1,3], @min)) %!assert (accumdim ([1;3;2;2;1], a, 2, 3, @median)(4,:,5), accumarray ([1;3;2;2;1], a(4,:,5), [1,3], @median)) +
--- a/scripts/general/bitcmp.m +++ b/scripts/general/bitcmp.m @@ -23,12 +23,12 @@ ## ## @example ## @group -## bitcmp(7,4) -## @result{} 8 -## dec2bin(11) -## @result{} 1011 -## dec2bin(bitcmp(11, 6)) -## @result{} 110100 +## bitcmp (7,4) +## @result{} 8 +## dec2bin (11) +## @result{} 1011 +## dec2bin (bitcmp (11, 6)) +## @result{} 110100 ## @end group ## @end example ## @seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax} @@ -86,38 +86,38 @@ %!test -%! Amax=53; +%! Amax = 53; %! Bmax = bitmax; -%! A = bitshift(Bmax,-2); -%! assert(bitcmp(A,Amax),bitor(bitshift(1,Amax-1),bitshift(1,Amax-2))); -%! assert(bitcmp(A,Amax-1),bitshift(1,Amax-2)); -%! assert(bitcmp(A,Amax-2),0); +%! A = bitshift (Bmax,-2); +%! assert (bitcmp (A,Amax),bitor (bitshift (1,Amax-1), bitshift (1,Amax-2))); +%! assert (bitcmp (A,Amax-1), bitshift (1,Amax-2)); +%! assert (bitcmp (A,Amax-2), 0); %!test -%! Amax=8; -%! Bmax = intmax('uint8'); -%! A = bitshift(Bmax,-2); -%! assert(bitcmp(A,Amax),bitor(bitshift(uint8(1),Amax-1),bitshift(uint8(1),Amax-2))); -%! assert(bitcmp(A,Amax-1),bitshift(uint8(1),Amax-2)); -%! assert(bitcmp(A,Amax-2),uint8(0)); +%! Amax = 8; +%! Bmax = intmax ("uint8"); +%! A = bitshift (Bmax,-2); +%! assert (bitcmp (A,Amax),bitor (bitshift (uint8 (1),Amax-1), bitshift (uint8 (1),Amax-2))); +%! assert (bitcmp (A,Amax-1), bitshift (uint8 (1),Amax-2)); +%! assert (bitcmp (A,Amax-2), uint8 (0)); %!test -%! Amax=16; -%! Bmax = intmax('uint16'); -%! A = bitshift(Bmax,-2); -%! assert(bitcmp(A,Amax),bitor(bitshift(uint16(1),Amax-1),bitshift(uint16(1),Amax-2))); -%! assert(bitcmp(A,Amax-1),bitshift(uint16(1),Amax-2)); -%! assert(bitcmp(A,Amax-2),uint16(0)); +%! Amax = 16; +%! Bmax = intmax ("uint16"); +%! A = bitshift (Bmax,-2); +%! assert (bitcmp (A,Amax),bitor (bitshift (uint16 (1),Amax-1), bitshift (uint16 (1),Amax-2))); +%! assert (bitcmp (A,Amax-1), bitshift (uint16 (1),Amax-2)); +%! assert (bitcmp (A,Amax-2), uint16 (0)); %!test -%! Amax=32; -%! Bmax = intmax('uint32'); -%! A = bitshift(Bmax,-2); -%! assert(bitcmp(A,Amax),bitor(bitshift(uint32(1),Amax-1),bitshift(uint32(1),Amax-2))); -%! assert(bitcmp(A,Amax-1),bitshift(uint32(1),Amax-2)); -%! assert(bitcmp(A,Amax-2),uint32(0)); +%! Amax = 32; +%! Bmax = intmax ("uint32"); +%! A = bitshift (Bmax,-2); +%! assert (bitcmp (A,Amax),bitor (bitshift (uint32 (1),Amax-1), bitshift (uint32 (1),Amax-2))); +%! assert (bitcmp (A,Amax-1), bitshift (uint32 (1),Amax-2)); +%! assert (bitcmp (A,Amax-2), uint32 (0)); %!test -%! Amax=64; -%! Bmax = intmax('uint64'); -%! A = bitshift(Bmax,-2); -%! assert(bitcmp(A,Amax),bitor(bitshift(uint64(1),Amax-1),bitshift(uint64(1),Amax-2))); -%! assert(bitcmp(A,Amax-1),bitshift(uint64(1),Amax-2)); -%! assert(bitcmp(A,Amax-2),uint64(0)); +%! Amax = 64; +%! Bmax = intmax ("uint64"); +%! A = bitshift (Bmax,-2); +%! assert (bitcmp (A,Amax),bitor (bitshift (uint64 (1),Amax-1), bitshift (uint64 (1),Amax-2))); +%! assert (bitcmp (A,Amax-1), bitshift (uint64 (1),Amax-2)); +%! assert (bitcmp (A,Amax-2), uint64 (0));
--- a/scripts/general/bitget.m +++ b/scripts/general/bitget.m @@ -80,8 +80,6 @@ endfunction -%!error bitget (1); -%!error bitget (1, 2, 3); %!test %! assert (bitget ([4, 14], [3, 3]), logical ([1, 1])); @@ -93,17 +91,21 @@ %! endfor %! endfor -%!error bitget (0, 0); -%!error bitget (0, 55); +%!error bitget (0, 0) +%!error bitget (0, 55) -%!error bitget (int8 (0), 9); -%!error bitget (uint8 (0), 9); +%!error bitget (int8 (0), 9) +%!error bitget (uint8 (0), 9) + +%!error bitget (int16 (0), 17) +%!error bitget (uint16 (0), 17) -%!error bitget (int16 (0), 17); -%!error bitget (uint16 (0), 17); +%!error bitget (int32 (0), 33) +%!error bitget (uint32 (0), 33) -%!error bitget (int32 (0), 33); -%!error bitget (uint32 (0), 33); +%!error bitget (int64 (0), 65) +%!error bitget (uint64 (0), 65) -%!error bitget (int64 (0), 65); -%!error bitget (uint64 (0), 65); +%!error bitget (1) +%!error bitget (1, 2, 3) +
--- a/scripts/general/bitset.m +++ b/scripts/general/bitset.m @@ -26,7 +26,7 @@ ## @example ## @group ## dec2bin (bitset (10, 1)) -## @result{} 1011 +## @result{} 1011 ## @end group ## @end example ## @seealso{bitand, bitor, bitxor, bitget, bitcmp, bitshift, bitmax} @@ -93,8 +93,6 @@ endfunction -%!error bitset (1); -%!error bitset (1, 2, 3, 4); %!test %! assert (bitset ([0, 10], [3, 3]), [4, 14]); @@ -106,17 +104,17 @@ %! endfor %! endfor -%!error bitset (0, 0); -%!error bitset (0, 55); - -%!error bitset (int8 (0), 9); -%!error bitset (uint8 (0), 9); +%!error bitset (0, 0) +%!error bitset (0, 55) +%!error bitset (int8 (0), 9) +%!error bitset (uint8 (0), 9) +%!error bitset (int16 (0), 17) +%!error bitset (uint16 (0), 17) +%!error bitset (int32 (0), 33) +%!error bitset (uint32 (0), 33) +%!error bitset (int64 (0), 65) +%!error bitset (uint64 (0), 65) -%!error bitset (int16 (0), 17); -%!error bitset (uint16 (0), 17); +%!error bitset (1) +%!error bitset (1, 2, 3, 4) -%!error bitset (int32 (0), 33); -%!error bitset (uint32 (0), 33); - -%!error bitset (int64 (0), 65); -%!error bitset (uint64 (0), 65);
--- a/scripts/general/blkdiag.m +++ b/scripts/general/blkdiag.m @@ -63,19 +63,21 @@ endfunction + ## regular tests -%!assert(blkdiag(1,ones(2),1),[1,0,0,0;0,1,1,0;0,1,1,0;0,0,0,1]) -%!assert(blkdiag([1,2],[3,4],[5,6]),[1,2,0,0,0,0;0,0,3,4,0,0;0,0,0,0,5,6]) -%!assert(blkdiag([1,2],[3;4],[5,6]),[1,2,0,0,0;0,0,3,0,0;0,0,4,0,0;0,0,0,5,6]) -%!assert(blkdiag([1,2;3,4],[5,6,7]),[1,2,0,0,0;3,4,0,0,0;0,0,5,6,7]) +%!assert (blkdiag (1,ones (2),1), [1,0,0,0;0,1,1,0;0,1,1,0;0,0,0,1]) +%!assert (blkdiag ([1,2],[3,4],[5,6]), [1,2,0,0,0,0;0,0,3,4,0,0;0,0,0,0,5,6]) +%!assert (blkdiag ([1,2],[3;4],[5,6]), [1,2,0,0,0;0,0,3,0,0;0,0,4,0,0;0,0,0,5,6]) +%!assert (blkdiag ([1,2;3,4],[5,6,7]), [1,2,0,0,0;3,4,0,0,0;0,0,5,6,7]) ## tests involving empty matrices -%!assert(blkdiag([],[],[]),[]) -%!assert(blkdiag([],[1,2;3,4],[],5,[]),[1,2,0;3,4,0;0,0,5]) -%!assert(blkdiag(zeros(1,0,1),[1,2,3],1,0,5,zeros(0,1,1)),[0,0,0,0,0,0,0;1,2,3,0,0,0,0;0,0,0,1,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,5,0]); +%!assert (blkdiag ([],[],[]), []) +%!assert (blkdiag ([],[1,2;3,4],[],5,[]), [1,2,0;3,4,0;0,0,5]) +%!assert (blkdiag (zeros (1,0,1),[1,2,3],1,0,5,zeros (0,1,1)), [0,0,0,0,0,0,0;1,2,3,0,0,0,0;0,0,0,1,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,5,0]); ## tests involving sparse matrices -%!assert (blkdiag (sparse([1,2;3,4]),[5,6;7,8]), sparse([1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8])) -%!assert (blkdiag (sparse([1,2;3,4]),[5,6]), sparse([1,2,0,0;3,4,0,0;0,0,5,6])) +%!assert (blkdiag (sparse ([1,2;3,4]),[5,6;7,8]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8])) +%!assert (blkdiag (sparse ([1,2;3,4]),[5,6]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6])) # sanity checks %!test %! A = rand (round (rand (1, 2) * 10)); %! assert (blkdiag (A), A); +
--- a/scripts/general/cart2pol.m +++ b/scripts/general/cart2pol.m @@ -81,6 +81,7 @@ endfunction + %!test %! x = [0, 1, 2]; %! y = 0; @@ -92,16 +93,16 @@ %! x = [0, 1, 2]; %! y = [0, 1, 2]; %! [t, r] = cart2pol (x, y); -%! assert (t, [0, pi/4, pi/4], sqrt(eps)); -%! assert (r, sqrt(2)*[0, 1, 2], sqrt(eps)); +%! assert (t, [0, pi/4, pi/4], sqrt (eps)); +%! assert (r, sqrt (2)*[0, 1, 2], sqrt (eps)); %!test %! x = [0, 1, 2]; %! y = [0, 1, 2]; %! z = [0, 1, 2]; %! [t, r, z2] = cart2pol (x, y, z); -%! assert (t, [0, pi/4, pi/4], sqrt(eps)); -%! assert (r, sqrt(2)*[0, 1, 2], sqrt(eps)); +%! assert (t, [0, pi/4, pi/4], sqrt (eps)); +%! assert (r, sqrt (2)*[0, 1, 2], sqrt (eps)); %! assert (z, z2); %!test @@ -134,10 +135,10 @@ %!test %! C = [0, 0; 1, 1; 2, 2]; %! P = [0, 0; pi/4, sqrt(2); pi/4, 2*sqrt(2)]; -%! assert (cart2pol (C), P, sqrt(eps)); +%! assert (cart2pol (C), P, sqrt (eps)); %!test %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2]; %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2]; -%! assert (cart2pol (C), P, sqrt(eps)); +%! assert (cart2pol (C), P, sqrt (eps));
--- a/scripts/general/cart2sph.m +++ b/scripts/general/cart2sph.m @@ -71,14 +71,15 @@ endfunction + %!test %! x = [0, 1, 2]; %! y = [0, 1, 2]; %! z = [0, 1, 2]; %! [t, p, r] = cart2sph (x, y, z); %! assert (t, [0, pi/4, pi/4], eps); -%! assert (p, [0, 1, 1]*atan(sqrt(0.5)), eps); -%! assert (r, [0, 1, 2]*sqrt(3), eps); +%! assert (p, [0, 1, 1]*atan (sqrt (0.5)), eps); +%! assert (r, [0, 1, 2]*sqrt (3), eps); %!test %! x = 0; @@ -87,7 +88,7 @@ %! [t, p, r] = cart2sph (x, y, z); %! assert (t, [0, 1, 1] * pi/2, eps); %! assert (p, [0, 1, 1] * pi/4, eps); -%! assert (r, [0, 1, 2] * sqrt(2), eps); +%! assert (r, [0, 1, 2] * sqrt (2), eps); %!test %! x = [0, 1, 2]; @@ -96,7 +97,7 @@ %! [t, p, r] = cart2sph (x, y, z); %! assert (t, [0, 0, 0]); %! assert (p, [0, 1, 1] * pi/4); -%! assert (r, [0, 1, 2] * sqrt(2)); +%! assert (r, [0, 1, 2] * sqrt (2)); %!test %! x = [0, 1, 2]; @@ -105,9 +106,10 @@ %! [t, p, r] = cart2sph (x, y, z); %! assert (t, [0, 1, 1] * pi/4); %! assert (p, [0, 0, 0]); -%! assert (r, [0, 1, 2] * sqrt(2)); +%! assert (r, [0, 1, 2] * sqrt (2)); %!test %! C = [0, 0, 0; 1, 0, 1; 2, 0, 2]; %! S = [0, 0, 0; 0, pi/4, sqrt(2); 0, pi/4, 2*sqrt(2)]; -%! assert (cart2sph(C), S, eps); +%! assert (cart2sph (C), S, eps); +
--- a/scripts/general/celldisp.m +++ b/scripts/general/celldisp.m @@ -25,16 +25,16 @@ ## @example ## @group ## c = @{1, 2, @{31, 32@}@}; -## celldisp(c, "b") -## @result{} -## b@{1@} = -## 1 -## b@{2@} = -## 2 -## b@{3@}@{1@} = -## 31 -## b@{3@}@{2@} = -## 32 +## celldisp (c, "b") +## @result{} +## b@{1@} = +## 1 +## b@{2@} = +## 2 +## b@{3@}@{1@} = +## 31 +## b@{3@}@{2@} = +## 32 ## @end group ## @end example ## @@ -83,6 +83,7 @@ %! c = {1, 2, {31, 32}}; %! celldisp (c, "b") -%!error celldisp (); -%!error celldisp ({}, "name", 1); -%!error celldisp (1); +%!error celldisp () +%!error celldisp ({}, "name", 1) +%!error celldisp (1) +
--- a/scripts/general/chop.m +++ b/scripts/general/chop.m @@ -25,9 +25,9 @@ ## @example ## @group ## chop (-pi, 5, 10) -## @result{} -3.14200000000000 +## @result{} -3.14200000000000 ## chop (-pi, 5, 5) -## @result{} -3.14150000000000 +## @result{} -3.14150000000000 ## @end group ## @end example ## @end deftypefn @@ -78,3 +78,4 @@ %!assert (chop (-e, 4, 7), -2.716) %!assert (chop (hilb (3), 3), [1,.5,.333;.5,.333,.25;.333,.25,.2]) %!assert (chop (hilb (3), 2, 7), [.7,.49,.35;.49,.35,.28;.35,.28,.21], 2*eps) +
--- a/scripts/general/circshift.m +++ b/scripts/general/circshift.m @@ -98,7 +98,7 @@ %!error circshift () %!error circshift (1) %!error circshift (1,2,3) -%!error circshift (1, ones(2,2)) +%!error circshift (1, ones (2,2)) %!error circshift (1, [1 2 3]) %!error circshift (1, 1.5)
--- a/scripts/general/colon.m +++ b/scripts/general/colon.m @@ -24,8 +24,8 @@ ## ## @example ## @group -## a = myclass (@dots{}) -## b = myclass (@dots{}) +## a = myclass (@dots{}); +## b = myclass (@dots{}); ## c = a : b ## @end group ## @end example @@ -39,6 +39,7 @@ endif endfunction + %!error colon (1) ## FIXME -- what does colon () mean since it doesn't set a return value?
--- a/scripts/general/common_size.m +++ b/scripts/general/common_size.m @@ -79,7 +79,6 @@ endif endfunction -%!error common_size (); %!test %! m = [1,2;3,4]; @@ -88,3 +87,6 @@ %! assert (a, m); %! assert (b, [3,3;3,3]); %! assert (c, [5,5;5,5]); + +%!error common_size () +
--- a/scripts/general/cplxpair.m +++ b/scripts/general/cplxpair.m @@ -163,4 +163,4 @@ %!## tolerance test %!assert (cplxpair ([1i, -1i, 1+(1i*eps)],2*eps), [-1i, 1i, 1+(1i*eps)]) - +
--- a/scripts/general/cumtrapz.m +++ b/scripts/general/cumtrapz.m @@ -117,18 +117,18 @@ %! x1 = [0,0,0;2,2,2]; %! x2 = [0,2,4;0,2,4]; %! y = [1,2,3;4,5,6]; -%!assert (cumtrapz(y), [0,0,0;2.5,3.5,4.5]) -%!assert (cumtrapz(x1,y), [0,0,0;5,7,9]) -%!assert (cumtrapz(y,1), [0,0,0;2.5,3.5,4.5]) -%!assert (cumtrapz(x1,y,1), [0,0,0;5,7,9]) -%!assert (cumtrapz(y,2), [0,1.5,4;0,4.5,10]) -%!assert (cumtrapz(x2,y,2), [0,3,8;0,9,20]) +%!assert (cumtrapz (y), [0,0,0;2.5,3.5,4.5]) +%!assert (cumtrapz (x1,y), [0,0,0;5,7,9]) +%!assert (cumtrapz (y,1), [0,0,0;2.5,3.5,4.5]) +%!assert (cumtrapz (x1,y,1), [0,0,0;5,7,9]) +%!assert (cumtrapz (y,2), [0,1.5,4;0,4.5,10]) +%!assert (cumtrapz (x2,y,2), [0,3,8;0,9,20]) %% Test ND-array implementation %!shared x1,x2,y %! x1 = 1:3; %! x2 = reshape ([0,2,4;0,2,4], [1 2 3]); %! y = reshape ([1,2,3;4,5,6], [1 2 3]); -%!assert (cumtrapz(y,3), reshape([0,1.5,4;0,4.5,10],[1 2 3])) -%!assert (cumtrapz(x1,y,3), reshape([0,1.5,4;0,4.5,10],[1 2 3])) -%!assert (cumtrapz(x2,y,3), reshape([0,3,8;0,9,20],[1 2 3])) +%!assert (cumtrapz (y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3])) +%!assert (cumtrapz (x1,y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3])) +%!assert (cumtrapz (x2,y,3), reshape ([0,3,8;0,9,20],[1 2 3]))
--- a/scripts/general/curl.m +++ b/scripts/general/curl.m @@ -129,14 +129,16 @@ endfunction + %!test -%! [X,Y]=meshgrid(-20:20,-22:22); -%! av = curl(2*(X-Y),Y); -%! assert(all(av(:)==1)); -%! [cz,av] = curl(2*(X-Y),Y); -%! assert(all(cz(:)==2)); -%! assert(all(av(:)==1)); -%! [cz,av] = curl(X/2,Y/2,2*(X-Y),Y); -%! assert(all(cz(:)==4)); -%! assert(all(av(:)==2)); -%! assert(size_equal(X,Y,cz,av)); +%! [X,Y] = meshgrid (-20:20,-22:22); +%! av = curl (2*(X-Y), Y); +%! assert (all (av(:) == 1)); +%! [cz,av] = curl (2*(X-Y), Y); +%! assert (all (cz(:) == 2)); +%! assert (all (av(:) == 1)); +%! [cz,av] = curl (X/2, Y/2, 2*(X-Y), Y); +%! assert (all (cz(:) == 4)); +%! assert (all (av(:) == 2)); +%! assert (size_equal (X,Y,cz,av)); +
--- a/scripts/general/dblquad.m +++ b/scripts/general/dblquad.m @@ -73,10 +73,11 @@ endfor endfunction + %% Nasty integrand to show quadcc off -%!assert (dblquad (@(x,y) 1 ./ (x+y), 0, 1, 0, 1), 2*log(2), 1e-6) +%!assert (dblquad (@(x,y) 1 ./ (x+y), 0, 1, 0, 1), 2*log (2), 1e-6) -%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadgk), pi * erf(1).^2, 1e-6) -%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadl), pi * erf(1).^2, 1e-6) -%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadv), pi * erf(1).^2, 1e-6) +%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadgk), pi * erf (1).^2, 1e-6) +%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadl), pi * erf (1).^2, 1e-6) +%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadv), pi * erf (1).^2, 1e-6)
--- a/scripts/general/deal.m +++ b/scripts/general/deal.m @@ -73,11 +73,13 @@ endfunction + %!test -%! [a,b]=deal(1,2); -%! assert(a,1); -%! assert(b,2); +%! [a,b] = deal (1,2); +%! assert (a, 1); +%! assert (b, 2); %!test -%! [a,b]=deal(1); -%! assert(a,1); -%! assert(b,1); +%! [a,b] = deal (1); +%! assert (a, 1); +%! assert (b, 1); +
--- a/scripts/general/divergence.m +++ b/scripts/general/divergence.m @@ -105,8 +105,10 @@ endfunction + %!test -%! [X,Y]=meshgrid(-20:20,-22:22); -%! div = divergence(X-Y,Y); -%! assert(all(div(:)==2)); -%! assert(size_equal(X,Y,div)); +%! [X,Y] = meshgrid (-20:20,-22:22); +%! div = divergence (X-Y,Y); +%! assert (all (div(:) == 2)); +%! assert (size_equal (X,Y,div)); +
--- a/scripts/general/flipdim.m +++ b/scripts/general/flipdim.m @@ -27,8 +27,8 @@ ## @example ## @group ## flipdim ([1, 2; 3, 4], 2) -## @result{} 2 1 -## 4 3 +## @result{} 2 1 +## 4 3 ## @end group ## @end example ## @seealso{fliplr, flipud, rot90, rotdim} @@ -57,11 +57,13 @@ endfunction -%!error flipdim (); -%!error flipdim (1, 2, 3); -%!assert (flipdim ([1,2;3,4]), flipdim ([1,2 ; 3,4], 1)); -%!assert (flipdim ([1,2;3,4], 2), [2,1;4,3]); -%!assert (flipdim ([1,2;3,4], 3), [1,2;3,4]); +%!assert (flipdim ([1,2;3,4]), flipdim ([1,2 ; 3,4], 1)) +%!assert (flipdim ([1,2;3,4], 2), [2,1;4,3]) +%!assert (flipdim ([1,2;3,4], 3), [1,2;3,4]) ## FIXME -- we need tests for multidimensional arrays. + +%!error flipdim () +%!error flipdim (1, 2, 3) +
--- a/scripts/general/fliplr.m +++ b/scripts/general/fliplr.m @@ -52,11 +52,11 @@ endfunction -%!assert((fliplr ([1, 2; 3, 4]) == [2, 1; 4, 3] -%! && fliplr ([1, 2; 3, 4; 5, 6]) == [2, 1; 4, 3; 6, 5] -%! && fliplr ([1, 2, 3; 4, 5, 6]) == [3, 2, 1; 6, 5, 4])); -%!error fliplr(); +%!assert (fliplr ([1, 2; 3, 4]), [2, 1; 4, 3]) +%!assert (fliplr ([1, 2; 3, 4; 5, 6]), [2, 1; 4, 3; 6, 5]) +%!assert (fliplr ([1, 2, 3; 4, 5, 6]), [3, 2, 1; 6, 5, 4]) -%!error fliplr (1, 2); +%!error fliplr() +%!error fliplr (1, 2)
--- a/scripts/general/flipud.m +++ b/scripts/general/flipud.m @@ -52,11 +52,11 @@ endfunction -%!assert((flipud ([1, 2; 3, 4]) == [3, 4; 1, 2] -%! && flipud ([1, 2; 3, 4; 5, 6]) == [5, 6; 3, 4; 1, 2] -%! && flipud ([1, 2, 3; 4, 5, 6]) == [4, 5, 6; 1, 2, 3])); -%!error flipud (); +%!assert (flipud ([1, 2; 3, 4]), [3, 4; 1, 2]) +%!assert (flipud ([1, 2; 3, 4; 5, 6]), [5, 6; 3, 4; 1, 2]) +%!assert (flipud ([1, 2, 3; 4, 5, 6]), [4, 5, 6; 1, 2, 3]) -%!error flipud (1, 2); +%!error flipud () +%!error flipud (1, 2)
--- a/scripts/general/genvarname.m +++ b/scripts/general/genvarname.m @@ -30,7 +30,7 @@ ## @group ## x = 3.141; ## genvarname ("x", who ()) -## @result{} x1 +## @result{} x1 ## @end group ## @end example ## @@ -40,11 +40,11 @@ ## @example ## @group ## genvarname (@{"foo", "foo"@}) -## @result{} -## @{ -## [1,1] = foo -## [1,2] = foo1 -## @} +## @result{} +## @{ +## [1,1] = foo +## [1,2] = foo1 +## @} ## @end group ## @end example ## @@ -55,8 +55,8 @@ ## @example ## @group ## name = genvarname ("x"); -## eval([name " = 42"]); -## @result{} x = 42 +## eval ([name " = 42"]); +## @result{} x = 42 ## @end group ## @end example ## @@ -68,13 +68,12 @@ ## for i = 1:3 ## x.(genvarname ("a", fieldnames (x))) = i; ## endfor -## @result{} -## x = -## @{ -## a = 1 -## a1 = 2 -## a2 = 3 -## @} +## @result{} x = +## @{ +## a = 1 +## a1 = 2 +## a2 = 3 +## @} ## @end group ## @end example ## @@ -173,31 +172,31 @@ endfunction -## Tests + ## a single argument -%!assert(genvarname("a"), "a") +%!assert (genvarname ("a"), "a") ## a single argument with a non-conflicting exception -%!assert(genvarname("a", "b"), "a") +%!assert (genvarname ("a", "b"), "a") ## a single argument with a conflicting exception -%!assert(genvarname("a", "a"), "a1") +%!assert (genvarname ("a", "a"), "a1") ## a single argument as a cell -%!assert(genvarname({"a"}), {"a"}) -%!assert(genvarname({"a"}, "b"), {"a"}) -%!assert(genvarname({"a"}, {"b"}), {"a"}) -%!assert(genvarname({"a"}, "a"), {"a1"}) -%!assert(genvarname({"a"}, {"a"}), {"a1"}) +%!assert (genvarname ({"a"}), {"a"}) +%!assert (genvarname ({"a"}, "b"), {"a"}) +%!assert (genvarname ({"a"}, {"b"}), {"a"}) +%!assert (genvarname ({"a"}, "a"), {"a1"}) +%!assert (genvarname ({"a"}, {"a"}), {"a1"}) ## Test different arguments ## orientation -%!assert(genvarname({"a" "b"}), {"a" "b"}) -%!assert(genvarname({"a";"b"}), {"a";"b"}) -%!assert(genvarname({"a" "a"}), {"a" "a1"}) -%!assert(genvarname({"a" "b";"c" "d"}), {"a" "b";"c" "d"}) -%!assert(genvarname({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"}) +%!assert (genvarname ({"a" "b"}), {"a" "b"}) +%!assert (genvarname ({"a";"b"}), {"a";"b"}) +%!assert (genvarname ({"a" "a"}), {"a" "a1"}) +%!assert (genvarname ({"a" "b";"c" "d"}), {"a" "b";"c" "d"}) +%!assert (genvarname ({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"}) ## more than one repetition -%!assert(genvarname({"a" "a" "a"}), {"a" "a1" "a2"}) -%!assert(genvarname({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"}) +%!assert (genvarname ({"a" "a" "a"}), {"a" "a1" "a2"}) +%!assert (genvarname ({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"}) ## more than one repetition not in order -%!assert(genvarname({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"}) +%!assert (genvarname ({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"}) ## Variable name munging %!assert (genvarname ("__x__"), "_x_") %!assert (genvarname ("123456789"), "_123456789") @@ -207,3 +206,4 @@ %!assert (genvarname ({"", "", ""}), {"x", "x1", "x2"}) %!assert (genvarname ("if"), "_if") %!assert (genvarname ({"if", "if", "if"}), {"_if", "_if1", "_if2"}) +
--- a/scripts/general/gradient.m +++ b/scripts/general/gradient.m @@ -220,6 +220,7 @@ endfor endfunction + %!test %! data = [1, 2, 4, 2]; %! dx = gradient (data); @@ -228,63 +229,63 @@ %! assert (dx, [1, 3/2, 0, -2]); %! assert (dx2, [4, 6, 0, -8]); %! assert (dx3, [4, 4, 0, -1]); -%! assert (size_equal(data, dx)); +%! assert (size_equal (data, dx)); %!test %! [Y,X,Z,U] = ndgrid (2:2:8,1:5,4:4:12,3:5:30); %! [dX,dY,dZ,dU] = gradient (X); -%! assert (all(dX(:)==1)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 1)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (Y); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==2)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 2)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (Z); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==4)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 4)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (U); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==5)); -%! assert (size_equal(dX, dY, dZ, dU, X, Y, Z, U)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 5)); +%! assert (size_equal (dX, dY, dZ, dU, X, Y, Z, U)); %! [dX,dY,dZ,dU] = gradient (U, 5.0); -%! assert (all(dU(:)==1)); +%! assert (all (dU(:) == 1)); %! [dX,dY,dZ,dU] = gradient (U, 1.0, 2.0, 3.0, 2.5); -%! assert (all(dU(:)==2)); +%! assert (all (dU(:) == 2)); %!test %! [Y,X,Z,U] = ndgrid (2:2:8,1:5,4:4:12,3:5:30); %! [dX,dY,dZ,dU] = gradient (X+j*X); -%! assert (all(dX(:)==1+1j)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 1+1j)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (Y-j*Y); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==2-j*2)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 2-j*2)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (Z+j*1); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==4)); -%! assert (all(dU(:)==0)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 4)); +%! assert (all (dU(:) == 0)); %! [dX,dY,dZ,dU] = gradient (U-j*1); -%! assert (all(dX(:)==0)); -%! assert (all(dY(:)==0)); -%! assert (all(dZ(:)==0)); -%! assert (all(dU(:)==5)); +%! assert (all (dX(:) == 0)); +%! assert (all (dY(:) == 0)); +%! assert (all (dZ(:) == 0)); +%! assert (all (dU(:) == 5)); %! assert (size_equal(dX, dY, dZ, dU, X, Y, Z, U)); %! [dX,dY,dZ,dU] = gradient (U, 5.0); -%! assert (all(dU(:)==1)); +%! assert (all (dU(:) == 1)); %! [dX,dY,dZ,dU] = gradient (U, 1.0, 2.0, 3.0, 2.5); -%! assert (all(dU(:)==2)); +%! assert (all (dU(:) == 2)); %!test %! x = 0:10;
--- a/scripts/general/idivide.m +++ b/scripts/general/idivide.m @@ -52,13 +52,13 @@ ## @example ## @group ## idivide (int8 ([-3, 3]), int8 (4), "fix") -## @result{} int8 ([0, 0]) +## @result{} int8 ([0, 0]) ## idivide (int8 ([-3, 3]), int8 (4), "round") -## @result{} int8 ([-1, 1]) +## @result{} int8 ([-1, 1]) ## idivide (int8 ([-3, 3]), int8 (4), "floor") -## @result{} int8 ([-1, 0]) +## @result{} int8 ([-1, 0]) ## idivide (int8 ([-3, 3]), int8 (4), "ceil") -## @result{} int8 ([0, 1]) +## @result{} int8 ([0, 1]) ## @end group ## @end example ## @@ -100,25 +100,27 @@ endif endfunction + %!shared a, af, b, bf -%! a = int8(3); +%! a = int8 (3); %! af = 3; -%! b = int8([-4, 4]); +%! b = int8 ([-4, 4]); %! bf = [-4, 4]; %!assert (idivide (a, b), int8 ([0, 0])) -%!assert (idivide (a, b, "floor"), int8([-1, 0])) +%!assert (idivide (a, b, "floor"), int8 ([-1, 0])) %!assert (idivide (a, b, "ceil"), int8 ([0, 1])) %!assert (idivide (a, b, "round"), int8 ([-1, 1])) %!assert (idivide (af, b), int8 ([0, 0])) -%!assert (idivide (af, b, "floor"), int8([-1, 0])) +%!assert (idivide (af, b, "floor"), int8 ([-1, 0])) %!assert (idivide (af, b, "ceil"), int8 ([0, 1])) %!assert (idivide (af, b, "round"), int8 ([-1, 1])) %!assert (idivide (a, bf), int8 ([0, 0])) -%!assert (idivide (a, bf, "floor"), int8([-1, 0])) +%!assert (idivide (a, bf, "floor"), int8 ([-1, 0])) %!assert (idivide (a, bf, "ceil"), int8 ([0, 1])) %!assert (idivide (a, bf, "round"), int8 ([-1, 1])) -%!error (idivide (uint8(1), int8(1))) +%!error (idivide (uint8 (1), int8 (1))) +
--- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -23,7 +23,6 @@ ## ## @example ## @group -## ## int2str (123) ## @result{} "123" ## @@ -114,10 +113,12 @@ endfunction -%!assert (strcmp (int2str (-123), "-123") && strcmp (int2str (1.2), "1")); -%!assert (all (int2str ([1, 2, 3; 4, 5, 6]) == ["1 2 3";"4 5 6"])); -%!assert (int2str([]), ""); -%!error int2str (); -%!error int2str (1, 2); +%!assert (int2str (-123), "-123") +%!assert (int2str (1.2), "1") +%!assert (int2str ([1, 2, 3; 4, 5, 6]), ["1 2 3";"4 5 6"]) +%!assert (int2str ([]), "") +%!error int2str () +%!error int2str (1, 2) +
--- a/scripts/general/interp1.m +++ b/scripts/general/interp1.m @@ -22,7 +22,7 @@ ## @deftypefnx {Function File} {@var{yi} =} interp1 (@var{y}, @var{xi}) ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{method}) ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{extrap}) -## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, 'pp') +## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, "pp") ## ## One-dimensional interpolation. Interpolate @var{y}, defined at the ## points @var{x}, at the points @var{xi}. The sample points @var{x} @@ -33,19 +33,19 @@ ## Method is one of: ## ## @table @asis -## @item 'nearest' +## @item "nearest" ## Return the nearest neighbor. ## -## @item 'linear' +## @item "linear" ## Linear interpolation from nearest neighbors ## -## @item 'pchip' +## @item "pchip" ## Piecewise cubic Hermite interpolating polynomial ## -## @item 'cubic' +## @item "cubic" ## Cubic interpolation (same as @code{pchip}) ## -## @item 'spline' +## @item "spline" ## Cubic spline interpolation---smooth first and second derivatives ## throughout the curve ## @end table @@ -53,18 +53,18 @@ ## Appending '*' to the start of the above method forces @code{interp1} ## to assume that @var{x} is uniformly spaced, and only @code{@var{x} ## (1)} and @code{@var{x} (2)} are referenced. This is usually faster, -## and is never slower. The default method is 'linear'. +## and is never slower. The default method is "linear". ## -## If @var{extrap} is the string 'extrap', then extrapolate values beyond +## If @var{extrap} is the string "extrap", then extrapolate values beyond ## the endpoints. If @var{extrap} is a number, replace values beyond the ## endpoints with that number. If @var{extrap} is missing, assume NA. ## -## If the string argument 'pp' is specified, then @var{xi} should not be +## If the string argument "pp" is specified, then @var{xi} should not be ## supplied and @code{interp1} returns the piecewise polynomial that ## can later be used with @code{ppval} to evaluate the interpolation. ## There is an equivalence, such that @code{ppval (interp1 (@var{x}, -## @var{y}, @var{method}, 'pp'), @var{xi}) == interp1 (@var{x}, @var{y}, -## @var{xi}, @var{method}, 'extrap')}. +## @var{y}, @var{method}, "pp"), @var{xi}) == interp1 (@var{x}, @var{y}, +## @var{xi}, @var{method}, "extrap")}. ## ## Duplicate points in @var{x} specify a discontinuous interpolant. There ## should be at most 2 consecutive points with the same value. @@ -87,7 +87,7 @@ ## near = interp1 (xp, yp, xf, "nearest"); ## plot (xf, yf, "r", xf, lin, "g", xf, spl, "b", ## xf, cub, "c", xf, near, "m", xp, yp, "r*"); -## legend ("original", "linear", "spline", "cubic", "nearest") +## legend ("original", "linear", "spline", "cubic", "nearest"); ## @end group ## @end example ## @@ -301,8 +301,8 @@ %!demo %! clf; -%! xf = 0:0.05:10; yf = sin (2*pi*xf/5); -%! xp = 0:10; yp = sin (2*pi*xp/5); +%! xf = 0:0.05:10; yf = sin (2*pi*xf/5); +%! xp = 0:10; yp = sin (2*pi*xp/5); %! lin = interp1 (xp,yp,xf, "linear"); %! spl = interp1 (xp,yp,xf, "spline"); %! cub = interp1 (xp,yp,xf, "pchip"); @@ -314,8 +314,8 @@ %!demo %! clf; -%! xf = 0:0.05:10; yf = sin (2*pi*xf/5); -%! xp = 0:10; yp = sin (2*pi*xp/5); +%! xf = 0:0.05:10; yf = sin (2*pi*xf/5); +%! xp = 0:10; yp = sin (2*pi*xp/5); %! lin = interp1 (xp,yp,xf, "*linear"); %! spl = interp1 (xp,yp,xf, "*spline"); %! cub = interp1 (xp,yp,xf, "*cubic"); @@ -340,8 +340,8 @@ %!demo %! clf; -%! xf = 0:0.05:10; yf = sin (2*pi*xf/5) - (xf >= 5); -%! xp = [0:.5:4.5,4.99,5:.5:10]; yp = sin (2*pi*xp/5) - (xp >= 5); +%! xf = 0:0.05:10; yf = sin (2*pi*xf/5) - (xf >= 5); +%! xp = [0:.5:4.5,4.99,5:.5:10]; yp = sin (2*pi*xp/5) - (xp >= 5); %! lin = interp1 (xp,yp,xf, "linear"); %! near= interp1 (xp,yp,xf, "nearest"); %! plot (xf,yf,"r", xf,near,"g", xf,lin,"b", xp,yp,"r*"); @@ -353,7 +353,7 @@ ## For each type of interpolated test, confirm that the interpolated ## value at the knots match the values at the knots. Points away -## from the knots are requested, but only 'nearest' and 'linear' +## from the knots are requested, but only "nearest" and "linear" ## confirm they are the correct values. %!shared xp, yp, xi, style @@ -372,204 +372,205 @@ %!test style = "nearest"; ## BLOCK -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); -%!assert (interp1(xp,[yp',yp'],xi,style), -%! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); -%!test style=['*',style]; -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) +%!assert (interp1 (xp,[yp',yp'],xi,style), +%! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) +%!test style = ["*",style]; +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) ## ENDBLOCK -%!test style='linear'; +%!test style = "linear"; ## BLOCK -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); -%!assert (interp1(xp,[yp',yp'],xi,style), -%! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); -%!test style=['*',style]; -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) +%!assert (interp1 (xp,[yp',yp'],xi,style), +%! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) +%!test style = ['*',style]; +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) ## ENDBLOCK -%!test style='cubic'; +%!test style = "cubic"; ## BLOCK -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),100*eps); -%!error interp1(1,1,1, style); -%!assert (interp1(xp,[yp',yp'],xi,style), -%! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); -%!test style=['*',style]; -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),100*eps); -%!error interp1(1,1,1, style); +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),100*eps) +%!error interp1 (1,1,1, style) +%!assert (interp1 (xp,[yp',yp'],xi,style), +%! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) +%!test style = ["*",style]; +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),100*eps) +%!error interp1 (1,1,1, style) ## ENDBLOCK -%!test style='pchip'; +%!test style = "pchip"; ## BLOCK -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); -%!assert (interp1(xp,[yp',yp'],xi,style), -%! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); -%!test style=['*',style]; -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) +%!assert (interp1 (xp,[yp',yp'],xi,style), +%! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) +%!test style = ["*",style]; +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) ## ENDBLOCK -%!test style='spline'; +%!test style = "spline"; ## BLOCK -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); -%!assert (interp1(xp,[yp',yp'],xi,style), -%! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); -%!test style=['*',style]; -%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]); -%!assert (interp1(xp,yp,xp,style), yp, 100*eps); -%!assert (interp1(xp,yp,xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp',style), yp', 100*eps); -%!assert (interp1(xp',yp',xp,style), yp, 100*eps); -%!assert (isempty(interp1(xp',yp',[],style))); -%!assert (isempty(interp1(xp,yp,[],style))); -%!assert (interp1(xp,[yp',yp'],xi(:),style),... -%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); -%!assert (interp1(xp,yp,xi,style),... -%! interp1(fliplr(xp),fliplr(yp),xi,style),100*eps); -%!assert (ppval(interp1(xp,yp,style,"pp"),xi), -%! interp1(xp,yp,xi,style,"extrap"),10*eps); -%!error interp1(1,1,1, style); +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) +%!assert (interp1 (xp,[yp',yp'],xi,style), +%! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps) +%!test style = ["*",style]; +%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]) +%!assert (interp1 (xp,yp,xp,style), yp, 100*eps) +%!assert (interp1 (xp,yp,xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp',style), yp', 100*eps) +%!assert (interp1 (xp',yp',xp,style), yp, 100*eps) +%!assert (isempty (interp1 (xp',yp',[],style))) +%!assert (isempty (interp1 (xp,yp,[],style))) +%!assert (interp1 (xp,[yp',yp'],xi(:),style),... +%! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) +%!assert (interp1 (xp,yp,xi,style),... +%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +%!assert (ppval (interp1 (xp,yp,style,"pp"),xi), +%! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!error interp1 (1,1,1, style) ## ENDBLOCK ## ENDBLOCKTEST %!# test linear extrapolation -%!assert (interp1([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps); -%!assert (interp1(xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]); - -%!error interp1 -%!error interp1(1:2,1:2,1,"bogus") +%!assert (interp1 ([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps) +%!assert (interp1 (xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]) -%!assert (interp1(1:2,1:2,1.4,"nearest"),1); -%!error interp1(1,1,1, "linear"); -%!assert (interp1(1:2,1:2,1.4,"linear"),1.4); -%!assert (interp1(1:4,1:4,1.4,"cubic"),1.4); -%!assert (interp1(1:2,1:2,1.1, "spline"), 1.1); -%!assert (interp1(1:3,1:3,1.4,"spline"),1.4); +%!assert (interp1 (1:2,1:2,1.4,"nearest"), 1) +%!assert (interp1 (1:2,1:2,1.4,"linear"), 1.4) +%!assert (interp1 (1:4,1:4,1.4,"cubic"), 1.4) +%!assert (interp1 (1:2,1:2,1.1, "spline"), 1.1) +%!assert (interp1 (1:3,1:3,1.4,"spline"), 1.4) -%!error interp1(1,1,1, "*nearest"); -%!assert (interp1(1:2:4,1:2:4,1.4,"*nearest"),1); -%!error interp1(1,1,1, "*linear"); -%!assert (interp1(1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"),[NA,1,1.4,3,NA]); -%!assert (interp1(1:2:8,1:2:8,1.4,"*cubic"),1.4); -%!assert (interp1(1:2,1:2,1.3, "*spline"), 1.3); -%!assert (interp1(1:2:6,1:2:6,1.4,"*spline"),1.4); +%!assert (interp1 (1:2:4,1:2:4,1.4,"*nearest"), 1) +%!assert (interp1 (1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"), [NA,1,1.4,3,NA]) +%!assert (interp1 (1:2:8,1:2:8,1.4,"*cubic"), 1.4) +%!assert (interp1 (1:2,1:2,1.3, "*spline"), 1.3) +%!assert (interp1 (1:2:6,1:2:6,1.4,"*spline"), 1.4) -%!assert (interp1([3,2,1],[3,2,2],2.5),2.5) +%!assert (interp1 ([3,2,1],[3,2,2],2.5), 2.5) %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap"), [-2,0.5,4,3,1.5]) %!assert (interp1 ([4,4,3,2,0],[0,1,4,2,1],[1.5,4,4.5], "linear"), [1.75,1,NA]) %!assert (interp1 (0:4, 2.5), 1.5) + +%!error interp1 () +%!error interp1 (1,1,1, "linear") +%!error interp1 (1,1,1, "*nearest") +%!error interp1 (1,1,1, "*linear") +%!error interp1 (1:2,1:2,1, "bogus") +
--- a/scripts/general/interp1q.m +++ b/scripts/general/interp1q.m @@ -57,14 +57,16 @@ endif endfunction + %!shared xp, yp, xi, yi -%! xp=[0:2:10].'; yp = sin(2*pi*xp/5); +%! xp = [0:2:10].'; yp = sin(2*pi*xp/5); %! xi = [-1; 0; 2.2; 4; 6.6; 10; 11]; %! yi = interp1 (xp,yp,xi); -%!assert (interp1q(xp, yp, [min(xp)-1; max(xp)+1]), [NA; NA]); -%!assert (interp1q(xp,yp,xp), yp, 100*eps); -%!assert (isempty(interp1q(xp,yp,[]))); -%!assert (interp1q(xp,yp,xi), yi); -%!assert (interp1q(xp,[yp,yp],xi), [yi, yi]); -%!assert (interp1q(xp,yp,[xi,xi]), [yi, yi]); -%!assert (interp1q(xp,[yp,yp],[xi,xi]), cat (3, [yi, yi], [yi, yi])); +%!assert (interp1q (xp,yp, [min(xp)-1; max(xp)+1]), [NA; NA]); +%!assert (interp1q (xp,yp,xp), yp, 100*eps); +%!assert (isempty (interp1q (xp,yp,[]))); +%!assert (interp1q (xp,yp,xi), yi); +%!assert (interp1q (xp,[yp,yp],xi), [yi, yi]); +%!assert (interp1q (xp,yp,[xi,xi]), [yi, yi]); +%!assert (interp1q (xp,[yp,yp],[xi,xi]), cat (3, [yi, yi], [yi, yi])); +
--- a/scripts/general/interp2.m +++ b/scripts/general/interp2.m @@ -36,8 +36,8 @@ ## matrices @var{xi}, @var{yi}. ## ## If the last argument is a string, the interpolation method can -## be specified. The method can be 'linear', 'nearest' or 'cubic'. -## If it is omitted 'linear' interpolation is assumed. +## be specified. The method can be "linear", "nearest" or "cubic". +## If it is omitted "linear" interpolation is assumed. ## ## @item interp2 (@var{z}, @var{xi}, @var{yi}) ## Assumes @code{@var{x} = 1:rows (@var{z})} and @code{@var{y} = @@ -52,19 +52,19 @@ ## interpolation. It can take one of the following values ## ## @table @asis -## @item 'nearest' +## @item "nearest" ## Return the nearest neighbor. ## -## @item 'linear' +## @item "linear" ## Linear interpolation from nearest neighbors. ## -## @item 'pchip' +## @item "pchip" ## Piecewise cubic Hermite interpolating polynomial. ## -## @item 'cubic' +## @item "cubic" ## Cubic interpolation from four nearest neighbors. ## -## @item 'spline' +## @item "spline" ## Cubic spline interpolation---smooth first and second derivatives ## throughout the curve. ## @end table @@ -449,9 +449,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,4]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,4]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "linear")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -460,9 +460,9 @@ %! clf; %! colormap ("default"); %! [x,y,A] = peaks (10); -%! x = x(1,:)'; y = y(:,1); -%! xi = linspace (min(x), max(x), 41); -%! yi = linspace (min(y), max(y), 41)'; +%! x = x(1,:)'; y = y(:,1); +%! xi = linspace (min (x), max (x), 41); +%! yi = linspace (min (y), max (y), 41)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "linear")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -471,9 +471,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,4]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,4]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "nearest")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -482,9 +482,9 @@ %! clf; %! colormap ("default"); %! [x,y,A] = peaks (10); -%! x = x(1,:)'; y = y(:,1); -%! xi = linspace (min(x), max(x), 41); -%! yi = linspace (min(y), max(y), 41)'; +%! x = x(1,:)'; y = y(:,1); +%! xi = linspace (min (x), max (x), 41); +%! yi = linspace (min (y), max (y), 41)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "nearest")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -493,9 +493,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,2]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,2]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "pchip")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -504,9 +504,9 @@ %! clf; %! colormap ("default"); %! [x,y,A] = peaks (10); -%! x = x(1,:)'; y = y(:,1); -%! xi = linspace (min(x), max(x), 41); -%! yi = linspace (min(y), max(y), 41)'; +%! x = x(1,:)'; y = y(:,1); +%! xi = linspace (min (x), max (x), 41); +%! yi = linspace (min (y), max (y), 41)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "pchip")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -515,9 +515,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,2]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,2]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "cubic")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -526,9 +526,9 @@ %! clf; %! colormap ("default"); %! [x,y,A] = peaks (10); -%! x = x(1,:)'; y = y(:,1); -%! xi = linspace (min(x), max(x), 41); -%! yi = linspace (min(y), max(y), 41)'; +%! x = x(1,:)'; y = y(:,1); +%! xi = linspace (min (x), max (x), 41); +%! yi = linspace (min (y), max (y), 41)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "cubic")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -537,9 +537,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,2]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,2]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "spline")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -548,83 +548,84 @@ %! clf; %! colormap ("default"); %! [x,y,A] = peaks (10); -%! x = x(1,:)'; y = y(:,1); -%! xi = linspace (min(x), max(x), 41); -%! yi = linspace (min(y), max(y), 41)'; +%! x = x(1,:)'; y = y(:,1); +%! xi = linspace (min (x), max (x), 41); +%! yi = linspace (min (y), max (y), 41)'; %! mesh (xi,yi,interp2 (x,y,A,xi,yi, "spline")); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; %!test % simple test -%! x = [1,2,3]; -%! y = [4,5,6,7]; -%! [X, Y] = meshgrid (x,y); -%! Orig = X.^2 + Y.^3; -%! xi = [1.2,2, 1.5]; -%! yi = [6.2, 4.0, 5.0]'; +%! x = [1,2,3]; +%! y = [4,5,6,7]; +%! [X, Y] = meshgrid (x, y); +%! Orig = X.^2 + Y.^3; +%! xi = [1.2,2, 1.5]; +%! yi = [6.2, 4.0, 5.0]'; %! -%! Expected = ... -%! [243, 245.4, 243.9; -%! 65.6, 68, 66.5; -%! 126.6, 129, 127.5]; -%! Result = interp2 (x,y,Orig, xi, yi); +%! Expected = ... +%! [243, 245.4, 243.9; +%! 65.6, 68, 66.5; +%! 126.6, 129, 127.5]; +%! Result = interp2 (x,y,Orig, xi, yi); %! -%! assert(Result, Expected, 1000*eps); +%! assert (Result, Expected, 1000*eps); %!test % 2^n form -%! x = [1,2,3]; -%! y = [4,5,6,7]; -%! [X, Y] = meshgrid(x,y); -%! Orig = X.^2 + Y.^3; -%! xi = [1:0.25:3]; yi = [4:0.25:7]'; -%! Expected = interp2(x,y,Orig, xi, yi); -%! Result = interp2(Orig,2); +%! x = [1,2,3]; +%! y = [4,5,6,7]; +%! [X, Y] = meshgrid (x, y); +%! Orig = X.^2 + Y.^3; +%! xi = [1:0.25:3]; yi = [4:0.25:7]'; +%! Expected = interp2 (x,y,Orig, xi, yi); +%! Result = interp2 (Orig, 2); %! -%! assert(Result, Expected, 10*eps); +%! assert (Result, Expected, 10*eps); %!test % matrix slice -%! A = eye(4); -%! assert(interp2(A,[1:4],[1:4]),[1,1,1,1]); +%! A = eye (4); +%! assert (interp2 (A,[1:4],[1:4]), [1,1,1,1]); %!test % non-gridded XI,YI -%! A = eye(4); -%! assert(interp2(A,[1,2;3,4],[1,3;2,4]),[1,0;0,1]); +%! A = eye (4); +%! assert (interp2 (A,[1,2;3,4],[1,3;2,4]), [1,0;0,1]); %!test % for values outside of boundaries -%! x = [1,2,3]; -%! y = [4,5,6,7]; -%! [X, Y] = meshgrid(x,y); -%! Orig = X.^2 + Y.^3; -%! xi = [0,4]; -%! yi = [3,8]'; -%! assert(interp2(x,y,Orig, xi, yi),[NA,NA;NA,NA]); -%! assert(interp2(x,y,Orig, xi, yi,'linear', 0),[0,0;0,0]); +%! x = [1,2,3]; +%! y = [4,5,6,7]; +%! [X, Y] = meshgrid (x,y); +%! Orig = X.^2 + Y.^3; +%! xi = [0,4]; +%! yi = [3,8]'; +%! assert (interp2 (x,y,Orig, xi, yi), [NA,NA;NA,NA]); +%! assert (interp2 (x,y,Orig, xi, yi,"linear", 0), [0,0;0,0]); %!test % for values at boundaries -%! A=[1,2;3,4]; -%! x=[0,1]; -%! y=[2,3]'; -%! assert(interp2(x,y,A,x,y,'linear'), A); -%! assert(interp2(x,y,A,x,y,'nearest'), A); +%! A=[1,2;3,4]; +%! x=[0,1]; +%! y=[2,3]'; +%! assert (interp2 (x,y,A,x,y,"linear"), A); +%! assert (interp2 (x,y,A,x,y,"nearest"), A); %!test % for Matlab-compatible rounding for 'nearest' %! X = meshgrid (1:4); -%! assert (interp2 (X, 2.5, 2.5, 'nearest'), 3); +%! assert (interp2 (X, 2.5, 2.5, "nearest"), 3); %!shared z, zout, tol -%! z = [1 3 5; 3 5 7; 5 7 9]; -%! zout = [1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8; 5 6 7 8 9]; -%! tol = 2 * eps; -%!assert (interp2 (z), zout, tol); -%!assert (interp2 (z, "linear"), zout, tol); -%!assert (interp2 (z, "pchip"), zout, tol); -%!assert (interp2 (z, "cubic"), zout, 10 * tol); -%!assert (interp2 (z, "spline"), zout, tol); +%! z = [1 3 5; 3 5 7; 5 7 9]; +%! zout = [1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8; 5 6 7 8 9]; +%! tol = 2 * eps; +%!assert (interp2 (z), zout, tol) +%!assert (interp2 (z, "linear"), zout, tol) +%!assert (interp2 (z, "pchip"), zout, tol) +%!assert (interp2 (z, "cubic"), zout, 10 * tol) +%!assert (interp2 (z, "spline"), zout, tol) %!assert (interp2 (z, [2 3 1], [2 2 2]', "linear"), repmat ([5, 7, 3], [3, 1]), tol) %!assert (interp2 (z, [2 3 1], [2 2 2]', "pchip"), repmat ([5, 7, 3], [3, 1]), tol) %!assert (interp2 (z, [2 3 1], [2 2 2]', "cubic"), repmat ([5, 7, 3], [3, 1]), 10 * tol) %!assert (interp2 (z, [2 3 1], [2 2 2]', "spline"), repmat ([5, 7, 3], [3, 1]), tol) -%!assert (interp2 (z, [2 3 1], [2 2 2], "linear"), [5 7 3], tol); -%!assert (interp2 (z, [2 3 1], [2 2 2], "pchip"), [5 7 3], tol); -%!assert (interp2 (z, [2 3 1], [2 2 2], "cubic"), [5 7 3], 10 * tol); -%!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol); +%!assert (interp2 (z, [2 3 1], [2 2 2], "linear"), [5 7 3], tol) +%!assert (interp2 (z, [2 3 1], [2 2 2], "pchip"), [5 7 3], tol) +%!assert (interp2 (z, [2 3 1], [2 2 2], "cubic"), [5 7 3], 10 * tol) +%!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol) +
--- a/scripts/general/interp3.m +++ b/scripts/general/interp3.m @@ -28,7 +28,7 @@ ## array @var{v} represents a value at a location given by the parameters ## @var{x}, @var{y}, and @var{z}. The parameters @var{x}, @var{x}, and ## @var{z} are either 3-dimensional arrays of the same size as the array -## @var{v} in the 'meshgrid' format or vectors. The parameters @var{xi}, etc. +## @var{v} in the "meshgrid" format or vectors. The parameters @var{xi}, etc. ## respect a similar format to @var{x}, etc., and they represent the points ## at which the array @var{vi} is interpolated. ## @@ -42,23 +42,23 @@ ## Method is one of: ## ## @table @asis -## @item 'nearest' +## @item "nearest" ## Return the nearest neighbor. ## -## @item 'linear' +## @item "linear" ## Linear interpolation from nearest neighbors. ## -## @item 'cubic' +## @item "cubic" ## Cubic interpolation from four nearest neighbors (not implemented yet). ## -## @item 'spline' +## @item "spline" ## Cubic spline interpolation---smooth first and second derivatives ## throughout the curve. ## @end table ## -## The default method is 'linear'. +## The default method is "linear". ## -## If @var{extrap} is the string 'extrap', then extrapolate values beyond +## If @var{extrap} is the string "extrap", then extrapolate values beyond ## the endpoints. If @var{extrap} is a number, replace values beyond the ## endpoints with that number. If @var{extrap} is missing, assume NA. ## @seealso{interp1, interp2, spline, meshgrid} @@ -135,6 +135,7 @@ endif endfunction + %!test %! x = y = z = -1:1; %! f = @(x,y,z) x.^2 - y - z.^2; @@ -142,9 +143,9 @@ %! v = f (xx,yy,zz); %! xi = yi = zi = -1:0.5:1; %! [xxi, yyi, zzi] = meshgrid (xi, yi, zi); -%! vi = interp3(x, y, z, v, xxi, yyi, zzi); +%! vi = interp3 (x, y, z, v, xxi, yyi, zzi); %! [xxi, yyi, zzi] = ndgrid (xi, yi, zi); -%! vi2 = interpn(x, y, z, v, xxi, yyi, zzi); +%! vi2 = interpn (x, y, z, v, xxi, yyi, zzi); %! assert (vi, vi2); %!shared z, zout, tol @@ -164,3 +165,4 @@ %!assert (interp3 (z), zout, tol) %!assert (interp3 (z, "linear"), zout, tol) %!assert (interp3 (z, "spline"), zout, tol) +
--- a/scripts/general/interpft.m +++ b/scripts/general/interpft.m @@ -93,8 +93,8 @@ %!demo %! clf; -%! t = 0 : 0.3 : pi; dt = t(2)-t(1); -%! n = length (t); k = 100; +%! t = 0 : 0.3 : pi; dt = t(2)-t(1); +%! n = length (t); k = 100; %! ti = t(1) + [0 : k-1]*dt*n/k; %! y = sin (4*t + 0.3) .* cos (3*t - 0.1); %! yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1); @@ -103,7 +103,7 @@ %! legend ("sin(4t+0.3)cos(3t-0.1)", "spline", "interpft", "data"); %!shared n,y -%! x = [0:10]'; y = sin(x); n = length (x); +%! x = [0:10]'; y = sin(x); n = length (x); %!assert (interpft (y, n), y, 20*eps); %!assert (interpft (y', n), y', 20*eps); %!assert (interpft ([y,y],n), [y,y], 20*eps);
--- a/scripts/general/interpn.m +++ b/scripts/general/interpn.m @@ -29,7 +29,7 @@ ## at a location given by the parameters @var{x1}, @var{x2}, @dots{}, @var{xn}. ## The parameters @var{x1}, @var{x2}, @dots{}, @var{xn} are either ## @var{n}-dimensional arrays of the same size as the array @var{v} in -## the 'ndgrid' format or vectors. The parameters @var{y1}, etc. respect a +## the "ndgrid" format or vectors. The parameters @var{y1}, etc. respect a ## similar format to @var{x1}, etc., and they represent the points at which ## the array @var{vi} is interpolated. ## @@ -42,21 +42,21 @@ ## Method is one of: ## ## @table @asis -## @item 'nearest' +## @item "nearest" ## Return the nearest neighbor. ## -## @item 'linear' +## @item "linear" ## Linear interpolation from nearest neighbors. ## -## @item 'cubic' +## @item "cubic" ## Cubic interpolation from four nearest neighbors (not implemented yet). ## -## @item 'spline' +## @item "spline" ## Cubic spline interpolation---smooth first and second derivatives ## throughout the curve. ## @end table ## -## The default method is 'linear'. +## The default method is "linear". ## ## If @var{extrapval} is the scalar value, use it to replace the values ## beyond the endpoints with that number. If @var{extrapval} is missing, @@ -214,9 +214,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,4]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,4]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi, yi, interpn (x,y,A.',xi,yi, "linear").'); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -225,9 +225,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,4]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,4]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi, yi, interpn (x,y,A.',xi,yi, "nearest").'); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -236,9 +236,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,2]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,2]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi, yi, interpn (x,y,A.',xi,yi, "cubic").'); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -247,9 +247,9 @@ %! clf; %! colormap ("default"); %! A = [13,-1,12;5,4,3;1,6,2]; -%! x = [0,1,2]; y = [10,11,12]; -%! xi = linspace (min(x), max(x), 17); -%! yi = linspace (min(y), max(y), 26)'; +%! x = [0,1,2]; y = [10,11,12]; +%! xi = linspace (min (x), max (x), 17); +%! yi = linspace (min (y), max (y), 26)'; %! mesh (xi, yi, interpn (x,y,A.',xi,yi, "spline").'); %! [x,y] = meshgrid (x,y); %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; @@ -263,7 +263,7 @@ %! v = f (xx,yy,zz); %! xi = yi = zi = -1:0.1:1; %! [xxi, yyi, zzi] = ndgrid (xi, yi, zi); -%! vi = interpn (x, y, z, v, xxi, yyi, zzi, 'spline'); +%! vi = interpn (x, y, z, v, xxi, yyi, zzi, "spline"); %! mesh (yi, zi, squeeze (vi(1,:,:))); %!test
--- a/scripts/general/isa.m +++ b/scripts/general/isa.m @@ -51,6 +51,7 @@ endfunction + %!assert (isa ("char", "float"), false) %!assert (isa (logical (1), "float"), false) %!assert (isa (double (13), "float"), true) @@ -76,20 +77,20 @@ %!assert (isa (uint32 (13), "numeric"), true) %!assert (isa (uint64 (13), "numeric"), true) -%!assert (isa (double (13), "double")); -%!assert (isa (single (13), "single")); -%!assert (isa (int8 (13), "int8")); -%!assert (isa (int16 (13), "int16")); -%!assert (isa (int32 (13), "int32")); -%!assert (isa (int64 (13), "int64")); -%!assert (isa (uint8 (13), "uint8")); -%!assert (isa (uint16 (13), "uint16")); -%!assert (isa (uint32 (13), "uint32")); -%!assert (isa (uint64 (13), "uint64")); -%!assert (isa ("string", "char")); -%!assert (isa (true, "logical")); -%!assert (isa (false, "logical")); -%!assert (isa ({1, 2}, "cell")); +%!assert (isa (double (13), "double")) +%!assert (isa (single (13), "single")) +%!assert (isa (int8 (13), "int8")) +%!assert (isa (int16 (13), "int16")) +%!assert (isa (int32 (13), "int32")) +%!assert (isa (int64 (13), "int64")) +%!assert (isa (uint8 (13), "uint8")) +%!assert (isa (uint16 (13), "uint16")) +%!assert (isa (uint32 (13), "uint32")) +%!assert (isa (uint64 (13), "uint64")) +%!assert (isa ("string", "char")) +%!assert (isa (true, "logical")) +%!assert (isa (false, "logical")) +%!assert (isa ({1, 2}, "cell")) %!test %! a.b = 1; %! assert (isa (a, "struct"));
--- a/scripts/general/isdir.m +++ b/scripts/general/isdir.m @@ -32,8 +32,9 @@ endfunction -%!error isdir (); -%!error isdir (1, 2); +%!assert (isdir (pwd ())) +%!assert (! isdir ("this is highly unlikely to be a directory name")) -%!assert (isdir (pwd ())); -%!assert (! isdir ("this is highly unlikely to be a directory name")); +%!error isdir () +%!error isdir (1, 2) +
--- a/scripts/general/isequal.m +++ b/scripts/general/isequal.m @@ -32,12 +32,13 @@ endfunction + ## test size and shape -%!assert(isequal([1,2,3,4],[1,2,3,4]), true) -%!assert(isequal([1;2;3;4],[1;2;3;4]), true) -%!assert(isequal([1,2,3,4],[1;2;3;4]), false) -%!assert(isequal([1,2,3,4],[1,2;3,4]), false) -%!assert(isequal([1,2,3,4],[1,3;2,4]), false) +%!assert (isequal ([1,2,3,4],[1,2,3,4]), true) +%!assert (isequal ([1;2;3;4],[1;2;3;4]), true) +%!assert (isequal ([1,2,3,4],[1;2;3;4]), false) +%!assert (isequal ([1,2,3,4],[1,2;3,4]), false) +%!assert (isequal ([1,2,3,4],[1,3;2,4]), false) %!test %! A = 1:8; @@ -55,20 +56,21 @@ %! assert (isequal (A, B), false); ## test for equality -%!assert(isequal([1,2,3,4],[1,2,3,4]), true) -%!assert(isequal(['a','b','c','d'],['a','b','c','d']), true) +%!assert (isequal ([1,2,3,4],[1,2,3,4]), true) +%!assert (isequal (['a','b','c','d'],['a','b','c','d']), true) ## Test multi-line strings -%!assert(isequal(["test";"strings"],["test";"strings"],["test";"strings"]), true) +%!assert (isequal (["test";"strings"],["test";"strings"],["test";"strings"]), true) ## test for inequality -%!assert(isequal([1,2,3,4],[1;2;3;4]),false) -%!assert(isequal({1,2,3,4},[1,2,3,4]),false) -%!assert(isequal([1,2,3,4],{1,2,3,4}),false) -%!assert(isequal([1,2,NaN,4],[1,2,NaN,4]),false) -%!assert(isequal(['a','b','c','d'],['a';'b';'c';'d']),false) -%!assert(isequal({'a','b','c','d'},{'a';'b';'c';'d'}),false) +%!assert (isequal ([1,2,3,4],[1;2;3;4]), false) +%!assert (isequal ({1,2,3,4},[1,2,3,4]), false) +%!assert (isequal ([1,2,3,4],{1,2,3,4}), false) +%!assert (isequal ([1,2,NaN,4],[1,2,NaN,4]), false) +%!assert (isequal (['a','b','c','d'],['a';'b';'c';'d']), false) +%!assert (isequal ({'a','b','c','d'},{'a';'b';'c';'d'}), false) ## test for equality (struct) -%!assert(isequal(struct('a',1,'b',2),struct('a',1,'b',2)),true) -%!assert(isequal(struct('a',1,'b',2),struct('a',1,'b',2),struct('a',1,'b',2)),true) -%!assert(isequal(struct('a','abc','b',2),struct('a','abc','b',2)),true) +%!assert (isequal (struct ('a',1,'b',2),struct ('a',1,'b',2)), true) +%!assert (isequal (struct ('a',1,'b',2),struct ('a',1,'b',2),struct ('a',1,'b',2)), true) +%!assert (isequal (struct ('a',"abc",'b',2),struct ('a',"abc",'b',2)), true) ## test for inequality (struct) -%!assert(isequal(struct('a',NaN,'b',2),struct('a',NaN,'b',2),struct('a',NaN,'b',2)),false) +%!assert (isequal (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), false) +
--- a/scripts/general/isequalwithequalnans.m +++ b/scripts/general/isequalwithequalnans.m @@ -33,12 +33,14 @@ endfunction + ## test for equality -%!assert(isequalwithequalnans({1,2,NaN,4},{1,2,NaN,4}), true) -%!assert(isequalwithequalnans([1,2,NaN,4],[1,2,NaN,4]), true) +%!assert (isequalwithequalnans ({1,2,NaN,4},{1,2,NaN,4}), true) +%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,NaN,4]), true) ## test for inequality -%!assert(isequalwithequalnans([1,2,NaN,4],[1,NaN,3,4]),false) -%!assert(isequalwithequalnans([1,2,NaN,4],[1,2,3,4]),false) +%!assert (isequalwithequalnans ([1,2,NaN,4],[1,NaN,3,4]), false) +%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,3,4]), false) ## test for equality (struct) -%!assert(isequalwithequalnans(struct('a',NaN,'b',2),struct('a',NaN,'b',2),struct('a',NaN,'b',2)),true) -%!assert(isequalwithequalnans(1,2,1), false) +%!assert (isequalwithequalnans (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true) +%!assert (isequalwithequalnans (1,2,1), false) +
--- a/scripts/general/issquare.m +++ b/scripts/general/issquare.m @@ -41,22 +41,23 @@ endfunction -%!assert(issquare ([])); -%!assert(issquare (1)); -%!assert(!(issquare ([1, 2]))); -%!assert(issquare ([1, 2; 3, 4])); -%!assert(!(issquare ([1, 2; 3, 4; 5, 6]))); -%!assert(!(issquare (ones (3,3,3)))); -%!assert(issquare ("t")); -%!assert(!(issquare ("test"))); -%!assert(issquare (["test"; "ing"; "1"; "2"])); + +%!assert (issquare ([])) +%!assert (issquare (1)) +%!assert (! issquare ([1, 2])) +%!assert (issquare ([1, 2; 3, 4])) +%!assert (! issquare ([1, 2; 3, 4; 5, 6])) +%!assert (! issquare (ones (3,3,3))) +%!assert (issquare ("t")) +%!assert (! issquare ("test")) +%!assert (issquare (["test"; "ing"; "1"; "2"])) %!test %! s.a = 1; -%! assert(issquare (s)); -%!assert(issquare ({1, 2; 3, 4})); -%!assert(sparse (([1, 2; 3, 4]))); +%! assert (issquare (s)); +%!assert (issquare ({1, 2; 3, 4})) +%!assert (sparse (([1, 2; 3, 4]))) %% Test input validation -%!error issquare (); -%!error issquare ([1, 2; 3, 4], 2); +%!error issquare () +%!error issquare ([1, 2; 3, 4], 2)
--- a/scripts/general/logspace.m +++ b/scripts/general/logspace.m @@ -91,9 +91,9 @@ %! assert (size (x4) == [1, 10] && x4(1) == 10 && abs (x4(10) - pi) < sqrt (eps)); %% Test input validation -%!error logspace (); -%!error logspace (1, 2, 3, 4); -%!error logspace ([1, 2; 3, 4], 5, 6); -%!error logspace (1, [1, 2; 3, 4], 6); -%!error logspace (1, 2, [1, 2; 3, 4]); +%!error logspace () +%!error logspace (1, 2, 3, 4) +%!error logspace ([1, 2; 3, 4], 5, 6) +%!error logspace (1, [1, 2; 3, 4], 6) +%!error logspace (1, 2, [1, 2; 3, 4])
--- a/scripts/general/nargchk.m +++ b/scripts/general/nargchk.m @@ -63,18 +63,19 @@ ## Tests %!shared stnul, stmin, stmax -%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); -%! stmin = struct ("message", "not enough input arguments", -%! "identifier", "Octave:nargchk:not-enough-inputs"); -%! stmax = struct ("message", "too many input arguments", -%! "identifier", "Octave:nargchk:too-many-inputs"); +%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); +%! stmin = struct ("message", "not enough input arguments", +%! "identifier", "Octave:nargchk:not-enough-inputs"); +%! stmax = struct ("message", "too many input arguments", +%! "identifier", "Octave:nargchk:too-many-inputs"); %!assert (nargchk (0, 1, 0), "") %!assert (nargchk (0, 1, 1), "") %!assert (nargchk (1, 1, 0), "not enough input arguments") %!assert (nargchk (0, 1, 2), "too many input arguments") %!assert (nargchk (0, 1, 2, "string"), "too many input arguments") ## Struct outputs -%!assert (isequal (nargchk (0, 1, 0, "struct"), stnul)) -%!assert (isequal (nargchk (0, 1, 1, "struct"), stnul)) +%!assert (nargchk (0, 1, 0, "struct"), stnul) +%!assert (nargchk (0, 1, 1, "struct"), stnul) %!assert (nargchk (1, 1, 0, "struct"), stmin) %!assert (nargchk (0, 1, 2, "struct"), stmax) +
--- a/scripts/general/narginchk.m +++ b/scripts/general/narginchk.m @@ -55,6 +55,7 @@ endfunction + %!function f (nargs, varargin) %! narginchk (nargs(1), nargs(2)); %!endfunction @@ -64,6 +65,6 @@ %!test %! f([1,1]) - %!test %! f([1,5], 2, 3, 4, 5) +
--- a/scripts/general/nargoutchk.m +++ b/scripts/general/nargoutchk.m @@ -104,21 +104,21 @@ endfunction -## Tests + %!shared stnul, stmin, stmax -%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); -%! stmin = struct ("message", "not enough output arguments", -%! "identifier", "Octave:nargoutchk:not-enough-outputs"); -%! stmax = struct ("message", "too many output arguments", -%! "identifier", "Octave:nargoutchk:too-many-outputs"); +%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1); +%! stmin = struct ("message", "not enough output arguments", +%! "identifier", "Octave:nargoutchk:not-enough-outputs"); +%! stmax = struct ("message", "too many output arguments", +%! "identifier", "Octave:nargoutchk:too-many-outputs"); %!assert (nargoutchk (0, 1, 0), "") %!assert (nargoutchk (0, 1, 1), "") %!assert (nargoutchk (1, 1, 0), "not enough output arguments") %!assert (nargoutchk (0, 1, 2), "too many output arguments") %!assert (nargoutchk (0, 1, 2, "string"), "too many output arguments") ## Struct outputs -%!assert (isequal (nargoutchk (0, 1, 0, "struct"), stnul)) -%!assert (isequal (nargoutchk (0, 1, 1, "struct"), stnul)) +%!assert (nargoutchk (0, 1, 0, "struct"), stnul) +%!assert (nargoutchk (0, 1, 1, "struct"), stnul) %!assert (nargoutchk (1, 1, 0, "struct"), stmin) %!assert (nargoutchk (0, 1, 2, "struct"), stmax)
--- a/scripts/general/nextpow2.m +++ b/scripts/general/nextpow2.m @@ -56,13 +56,15 @@ endfunction -%!error nexpow2 (); -%!error nexpow2 (1, 2); -%!assert (nextpow2 (16), 4); -%!assert (nextpow2 (17), 5); -%!assert (nextpow2 (31), 5); -%!assert (nextpow2 (-16), 4); -%!assert (nextpow2 (-17), 5); -%!assert (nextpow2 (-31), 5); -%!assert (nextpow2 (1:17), 5); +%!assert (nextpow2 (16), 4) +%!assert (nextpow2 (17), 5) +%!assert (nextpow2 (31), 5) +%!assert (nextpow2 (-16), 4) +%!assert (nextpow2 (-17), 5) +%!assert (nextpow2 (-31), 5) +%!assert (nextpow2 (1:17), 5) + +%!error nexpow2 () +%!error nexpow2 (1, 2) +
--- a/scripts/general/nthargout.m +++ b/scripts/general/nthargout.m @@ -107,7 +107,9 @@ endfunction + %!shared m %! m = magic (5); -%!assert (nthargout ([1, 2], @ind2sub, size(m), nthargout (2, @max, m(:))), {5,3}) +%!assert (nthargout ([1,2], @ind2sub, size (m), nthargout (2, @max, m(:))), {5,3}) %!assert (nthargout (3, @find, m(m>20)), [23, 24, 25, 21, 22]') +
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -177,10 +177,13 @@ endfunction -%!assert ((strcmp (num2str (123), "123") && strcmp (num2str (1.23), "1.23"))); -%!assert (num2str (123.456, 4), "123.5"); -%!assert (all (num2str ([1, 1.34; 3, 3.56], "%5.1f") == ["1.0 1.3"; "3.0 3.6"])); -%!assert (num2str (1.234 + 27.3i), "1.234+27.3i"); -%!error num2str (); -%!error num2str (1, 2, 3); +%!assert (num2str (123), "123") +%!assert (num2str (1.23), "1.23") +%!assert (num2str (123.456, 4), "123.5") +%!assert (num2str ([1, 1.34; 3, 3.56], "%5.1f"), ["1.0 1.3"; "3.0 3.6"]) +%!assert (num2str (1.234 + 27.3i), "1.234+27.3i") + +%!error num2str () +%!error num2str (1, 2, 3) +
--- a/scripts/general/pol2cart.m +++ b/scripts/general/pol2cart.m @@ -80,27 +80,28 @@ endfunction + %!test %! t = [0, 0.5, 1] * pi; %! r = 1; %! [x, y] = pol2cart (t, r); -%! assert (x, [1, 0, -1], sqrt(eps)); -%! assert (y, [0, 1, 0], sqrt(eps)); +%! assert (x, [1, 0, -1], sqrt (eps)); +%! assert (y, [0, 1, 0], sqrt (eps)); %!test %! t = [0, 1, 1] * pi/4; -%! r = sqrt(2) * [0, 1, 2]; +%! r = sqrt (2) * [0, 1, 2]; %! [x, y] = pol2cart (t, r); -%! assert (x, [0, 1, 2], sqrt(eps)); -%! assert (y, [0, 1, 2], sqrt(eps)); +%! assert (x, [0, 1, 2], sqrt (eps)); +%! assert (y, [0, 1, 2], sqrt (eps)); %!test %! t = [0, 1, 1] * pi/4; -%! r = sqrt(2) * [0, 1, 2]; +%! r = sqrt (2) * [0, 1, 2]; %! z = [0, 1, 2]; %! [x, y, z2] = pol2cart (t, r, z); -%! assert (x, [0, 1, 2], sqrt(eps)); -%! assert (y, [0, 1, 2], sqrt(eps)); +%! assert (x, [0, 1, 2], sqrt (eps)); +%! assert (y, [0, 1, 2], sqrt (eps)); %! assert (z, z2); %!test @@ -108,8 +109,8 @@ %! r = [0, 1, 2]; %! z = [0, 1, 2]; %! [x, y, z2] = pol2cart (t, r, z); -%! assert (x, [0, 1, 2], sqrt(eps)); -%! assert (y, [0, 0, 0], sqrt(eps)); +%! assert (x, [0, 1, 2], sqrt (eps)); +%! assert (y, [0, 0, 0], sqrt (eps)); %! assert (z, z2); %!test @@ -117,8 +118,8 @@ %! r = 1; %! z = [0, 1, 2]; %! [x, y, z2] = pol2cart (t, r, z); -%! assert (x, [1, 1, 1] / sqrt(2), eps); -%! assert (y, [1, 1, 1] / sqrt(2), eps); +%! assert (x, [1, 1, 1] / sqrt (2), eps); +%! assert (y, [1, 1, 1] / sqrt (2), eps); %! assert (z, z2); %!test @@ -127,16 +128,16 @@ %! z = 1; %! [x, y, z2] = pol2cart (t, r, z); %! assert (x, [1, 2, 3], eps); -%! assert (y, [0, 0, 0] / sqrt(2), eps); +%! assert (y, [0, 0, 0] / sqrt (2), eps); %! assert (z, z2); %!test %! P = [0, 0; pi/4, sqrt(2); pi/4, 2*sqrt(2)]; %! C = [0, 0; 1, 1; 2, 2]; -%! assert (pol2cart(P), C, sqrt(eps)); +%! assert (pol2cart (P), C, sqrt (eps)); %!test %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2]; %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2]; -%! assert (pol2cart(P), C, sqrt(eps)); +%! assert (pol2cart (P), C, sqrt (eps));
--- a/scripts/general/polyarea.m +++ b/scripts/general/polyarea.m @@ -61,10 +61,12 @@ endif endfunction + %!shared x, y %! x = [1;1;3;3;1]; %! y = [1;3;3;1;1]; -%!assert (polyarea(x,y), 4, eps) -%!assert (polyarea([x,x],[y,y]), [4,4], eps) -%!assert (polyarea([x,x],[y,y],1), [4,4], eps) -%!assert (polyarea([x,x]',[y,y]',2), [4;4], eps) +%!assert (polyarea (x,y), 4, eps) +%!assert (polyarea ([x,x],[y,y]), [4,4], eps) +%!assert (polyarea ([x,x],[y,y],1), [4,4], eps) +%!assert (polyarea ([x,x]',[y,y]',2), [4;4], eps) +
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -83,15 +83,15 @@ endfunction -%!error postpad (); -%!error postpad (1); -%!error postpad (1,2,3,4,5); -%!error postpad ([1,2], 2, 2,3); -%!assert (postpad ([1,2], 4), [1,2,0,0]); -%!assert (postpad ([1;2], 4), [1;2;0;0]); +%!assert (postpad ([1,2], 4), [1,2,0,0]) +%!assert (postpad ([1;2], 4), [1;2;0;0]) +%!assert (postpad ([1,2], 4, 2), [1,2,2,2]) +%!assert (postpad ([1;2], 4, 2), [1;2;2;2]) +%!assert (postpad ([1,2], 2, 2, 1), [1,2;2,2]) -%!assert (postpad ([1,2], 4, 2), [1,2,2,2]); -%!assert (postpad ([1;2], 4, 2), [1;2;2;2]); +%!error postpad () +%!error postpad (1) +%!error postpad (1,2,3,4,5) +%!error postpad ([1,2], 2, 2,3) -%!assert (postpad ([1,2], 2, 2, 1), [1,2;2,2]);
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -83,17 +83,19 @@ endfunction -%!error prepad (); -%!error prepad (1); -%!error prepad (1,2,3,4,5); -%!error prepad ([1,2], 2, 2,3); + +%!assert (prepad ([1,2], 4), [0,0,1,2]) +%!assert (prepad ([1;2], 4), [0;0;1;2]) -%!assert (prepad ([1,2], 4), [0,0,1,2]); -%!assert (prepad ([1;2], 4), [0;0;1;2]); +%!assert (prepad ([1,2], 4, 2), [2,2,1,2]) +%!assert (prepad ([1;2], 4, 2), [2;2;1;2]) -%!assert (prepad ([1,2], 4, 2), [2,2,1,2]); -%!assert (prepad ([1;2], 4, 2), [2;2;1;2]); - -%!assert (prepad ([1,2], 2, 2, 1), [2,2;1,2]); +%!assert (prepad ([1,2], 2, 2, 1), [2,2;1,2]) ## FIXME -- we need tests for multidimensional arrays. + +%!error prepad () +%!error prepad (1) +%!error prepad (1,2,3,4,5) +%!error prepad ([1,2], 2, 2,3) +
--- a/scripts/general/profexplore.m +++ b/scripts/general/profexplore.m @@ -21,7 +21,7 @@ ## Interactively explore hierarchical profiler output. ## ## Assuming @var{data} is the structure with profile data returned by -## @code{profile ('info')}, this command opens an interactive prompt +## @code{profile ("info")}, this command opens an interactive prompt ## that can be used to explore the call-tree. Type @kbd{help} to get a list ## of possible commands. ## @seealso{profile, profshow} @@ -45,7 +45,7 @@ endfunction ## This is the worker function. tree is the current subtree we want to -## display / explore. parents is a string containing the already 'rendered' +## display / explore. parents is a string containing the already "rendered" ## data for the parents which is displayed on top of the list of current ## children. prefix is the prefix to add to each line rendered; this ## is just a string of spaces to get indentation right.
--- a/scripts/general/profile.m +++ b/scripts/general/profile.m @@ -21,8 +21,8 @@ ## @deftypefnx {Command} {} profile off ## @deftypefnx {Command} {} profile resume ## @deftypefnx {Command} {} profile clear -## @deftypefnx {Function File} {@var{S} =} profile ('status') -## @deftypefnx {Function File} {@var{T} =} profile ('info') +## @deftypefnx {Function File} {@var{S} =} profile ("status") +## @deftypefnx {Function File} {@var{T} =} profile ("info") ## Control the built-in profiler. ## ## @table @code @@ -32,7 +32,7 @@ ## ## @item profile off ## Stop profiling. The collected data can later be retrieved and examined -## with calls like @code{S = profile ('info')}. +## with calls like @code{S = profile ("info")}. ## ## @item profile clear ## Clear all collected profiler data. @@ -41,12 +41,12 @@ ## Restart profiling without cleaning up the old data and instead ## all newly collected statistics are added to the already existing ones. ## -## @item @var{S} = profile ('status') +## @item @var{S} = profile ("status") ## Return a structure filled with certain information about the current status ## of the profiler. At the moment, the only field is @code{ProfilerStatus} -## which is either 'on' or 'off'. +## which is either "on" or "off". ## -## @item @var{T} = profile ('info') +## @item @var{T} = profile ("info") ## Return the collected profiling statistics in the structure @var{T}. ## The flat profile is returned in the field @code{FunctionTable} which is an ## array of structures, each entry corresponding to a function which was called @@ -150,5 +150,5 @@ %% Test input validation %!error profile () %!error profile ("on", 2) -%!error profile ("INVALID_OPTION"); +%!error profile ("INVALID_OPTION")
--- a/scripts/general/profshow.m +++ b/scripts/general/profshow.m @@ -22,7 +22,7 @@ ## Show flat profiler results. ## ## This command prints out profiler data as a flat profile. @var{data} is the -## structure returned by @code{profile ('info')}. If @var{n} is given, it +## structure returned by @code{profile ("info")}. If @var{n} is given, it ## specifies the number of functions to show in the profile; functions are ## sorted in descending order by total time spent in them. If there are more ## than @var{n} included in the profile, those will not be shown. @var{n} @@ -96,7 +96,7 @@ %! profile off; %! profshow (profile ("info"), 5); -%!error profshow (); -%!error profshow (1, 2, 3); -%!error profshow (struct (), 1.2); +%!error profshow () +%!error profshow (1, 2, 3) +%!error profshow (struct (), 1.2)
--- a/scripts/general/quadgk.m +++ b/scripts/general/quadgk.m @@ -42,7 +42,7 @@ ## weaken the singularities. For example: ## ## @example -## quadgk(@@(x) 1 ./ (sqrt (x) .* (x + 1)), 0, Inf) +## quadgk (@@(x) 1 ./ (sqrt (x) .* (x + 1)), 0, Inf) ## @end example ## ## @noindent @@ -78,7 +78,7 @@ ## unacceptable error are subdivided and re-evaluated. If the number of ## subintervals exceeds 650 subintervals at any point then a poor ## convergence is signaled and the current estimate of the integral is -## returned. The property 'MaxIntervalCount' can be used to alter the +## returned. The property "MaxIntervalCount" can be used to alter the ## number of subintervals that can exist before exiting. ## ## @item WayPoints @@ -89,7 +89,7 @@ ## computation, or both. For example, ## ## @example -## quadgk (@@(x) abs (1 - x.^2), 0, 2, 'Waypoints', 1) +## quadgk (@@(x) abs (1 - x.^2), 0, 2, "Waypoints", 1) ## @end example ## ## @noindent @@ -440,22 +440,24 @@ t = real ((sqrt(3) .* 1i * (1 - k .^ 2) - (1 + k .^ 2)) ./ 2 ./ k); endfunction + +%!assert (quadgk (@sin,-pi,pi), 0, 1e-6) +%!assert (quadgk (inline ("sin"),-pi,pi), 0, 1e-6) +%!assert (quadgk ("sin",-pi,pi), 0, 1e-6) +%!assert (quadgk (@sin,-pi,pi, "waypoints", 0, "MaxIntervalCount", 100, "reltol", 1e-3, "abstol", 1e-6, "trace", false), 0, 1e-6) +%!assert (quadgk (@sin,-pi,pi, 1e-6,false), 0, 1e-6) + +%!assert (quadgk (@sin,-pi,0), -2, 1e-6) +%!assert (quadgk (@sin,0,pi), 2, 1e-6) +%!assert (quadgk (@(x) 1./sqrt (x),0,1), 2, 1e-6) +%!assert (quadgk (@(x) abs (1 - x.^2),0,2, "Waypoints", 1), 2, 1e-6) +%!assert (quadgk (@(x) 1./(sqrt (x) .* (x+1)),0,Inf), pi, 1e-6) +%!assert (quadgk (@(z) log (z),1+1i,1+1i, "WayPoints", [1-1i, -1,-1i, -1+1i]), -pi * 1i, 1e-6) + +%!assert (quadgk (@(x) exp (-x .^ 2),-Inf,Inf), sqrt (pi), 1e-6) +%!assert (quadgk (@(x) exp (-x .^ 2),-Inf,0), sqrt (pi)/2, 1e-6) + %error (quadgk (@sin)) %error (quadgk (@sin, -pi)) -%error (quadgk (@sin, -pi, pi, 'DummyArg')) - -%!assert (quadgk(@sin,-pi,pi), 0, 1e-6) -%!assert (quadgk(inline('sin'),-pi,pi), 0, 1e-6) -%!assert (quadgk('sin',-pi,pi), 0, 1e-6) -%!assert (quadgk(@sin,-pi,pi,'waypoints', 0, 'MaxIntervalCount', 100, 'reltol', 1e-3, 'abstol', 1e-6, 'trace', false), 0, 1e-6) -%!assert (quadgk(@sin,-pi,pi,1e-6,false), 0, 1e-6) +%error (quadgk (@sin, -pi, pi, "DummyArg")) -%!assert (quadgk(@sin,-pi,0), -2, 1e-6) -%!assert (quadgk(@sin,0,pi), 2, 1e-6) -%!assert (quadgk(@(x) 1./sqrt(x), 0, 1), 2, 1e-6) -%!assert (quadgk (@(x) abs (1 - x.^2), 0, 2, 'Waypoints', 1), 2, 1e-6) -%!assert (quadgk(@(x) 1./(sqrt(x).*(x+1)), 0, Inf), pi, 1e-6) -%!assert (quadgk (@(z) log (z), 1+1i, 1+1i, 'WayPoints', [1-1i, -1,-1i, -1+1i]), -pi * 1i, 1e-6) - -%!assert (quadgk (@(x) exp(-x .^ 2), -Inf, Inf), sqrt(pi), 1e-6) -%!assert (quadgk (@(x) exp(-x .^ 2), -Inf, 0), sqrt(pi)/2, 1e-6)
--- a/scripts/general/quadv.m +++ b/scripts/general/quadv.m @@ -148,6 +148,7 @@ endif endfunction + %!assert (quadv (@sin, 0, 2 * pi), 0, 1e-5) %!assert (quadv (@sin, 0, pi), 2, 1e-5) @@ -159,3 +160,4 @@ %% Handles matrix-valued functions %!assert (quadv (@(x) [ x, x, x; x, 1./sqrt(x), x; x, x, x ], 0, 1 ), [0.5, 0.5, 0.5; 0.5, 2, 0.5; 0.5, 0.5, 0.5], 1e-5) +
--- a/scripts/general/randi.m +++ b/scripts/general/randi.m @@ -40,7 +40,7 @@ ## The following example returns 150 integers in the range 1-10. ## ## @example -## ri = randi (10, 150, 1); +## ri = randi (10, 150, 1) ## @end example ## ## Implementation Note: @code{randi} relies internally on @code{rand} which @@ -113,29 +113,29 @@ %!test %! ri = randi (10, 1000, 1); -%! assert(isequal(ri, fix (ri))); -%! assert(min(ri) == 1); -%! assert(max(ri) == 10); -%! assert(rows(ri) == 1000); -%! assert(columns(ri) == 1); -%! assert(strcmp (class (ri), "double")); +%! assert (ri, fix (ri)); +%! assert (min (ri), 1); +%! assert (max (ri), 10); +%! assert (rows (ri), 1000); +%! assert (columns (ri), 1); +%! assert (class (ri), "double"); %!test %! ri = randi ([-5, 10], 1000, 1, "int8"); -%! assert(isequal(ri, fix (ri))); -%! assert(min(ri) == -5); -%! assert(max(ri) == 10); -%! assert(strcmp (class (ri), "int8")); +%! assert (ri, fix (ri)); +%! assert (min (ri), int8 (-5)); +%! assert (max (ri), int8 (10)); +%! assert (class (ri), "int8"); %! -%!assert(size (randi(10, 3,1,2)) == [3, 1, 2]) +%!assert (size (randi (10, 3,1,2)), [3, 1, 2]) %% Test input validation -%!error(randi()) -%!error(randi("test")) -%!error(randi(10+2i)) -%!error(randi(0)) -%!error(randi([10, 1])) -%!error(randi(256, "uint8")) -%!error(randi(2^25, "single")) -%!error(randi(bitmax() + 1)) -%!error(randi([-1, bitmax()])) +%!error (randi ()) +%!error (randi ("test")) +%!error (randi (10+2i)) +%!error (randi (0)) +%!error (randi ([10, 1])) +%!error (randi (256, "uint8")) +%!error (randi (2^25, "single")) +%!error (randi (bitmax () + 1)) +%!error (randi ([-1, bitmax()]))
--- a/scripts/general/rat.m +++ b/scripts/general/rat.m @@ -25,9 +25,9 @@ ## ## @example ## @group -## rat(pi) = 3 + 1/(7 + 1/16) = 355/113 -## rat(e) = 3 + 1/(-4 + 1/(2 + 1/(5 + 1/(-2 + 1/(-7))))) -## = 1457/536 +## rat (pi) = 3 + 1/(7 + 1/16) = 355/113 +## rat (e) = 3 + 1/(-4 + 1/(2 + 1/(5 + 1/(-2 + 1/(-7))))) +## = 1457/536 ## @end group ## @end example ## @@ -151,10 +151,12 @@ endfunction -%!error rat (); -%!error rat (1, 2, 3); %!test %! [n, d] = rat ([0.5, 0.3, 1/3]); %! assert (n, [1, 3, 1]); %! assert (d, [2, 10, 3]); + +%!error rat (); +%!error rat (1, 2, 3); +
--- a/scripts/general/repmat.m +++ b/scripts/general/repmat.m @@ -24,7 +24,7 @@ ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n} @var{p} @dots{}]) ## Form a block matrix of size @var{m} by @var{n}, with a copy of matrix ## @var{A} as each element. If @var{n} is not specified, form an -## @var{m} by @var{m} block matrix. For copying along more than two +## @var{m} by @var{m} block matrix. For copying along more than two ## dimensions, specify the number of times to copy across each dimension ## @var{m}, @var{n}, @var{p}, @dots{}, in a vector in the second argument. ## @seealso{repelems} @@ -101,63 +101,64 @@ endfunction + # Test various methods of providing size parameters %!shared x %! x = [1 2;3 4]; -%!assert(repmat(x, [1 1]), repmat(x, 1)); -%!assert(repmat(x, [3 3]), repmat(x, 3)); -%!assert(repmat(x, [1 1]), repmat(x, 1, 1)); -%!assert(repmat(x, [1 3]), repmat(x, 1, 3)); -%!assert(repmat(x, [3 1]), repmat(x, 3, 1)); -%!assert(repmat(x, [3 3]), repmat(x, 3, 3)); +%!assert (repmat (x, [1 1]), repmat (x, 1)) +%!assert (repmat (x, [3 3]), repmat (x, 3)) +%!assert (repmat (x, [1 1]), repmat (x, 1, 1)) +%!assert (repmat (x, [1 3]), repmat (x, 1, 3)) +%!assert (repmat (x, [3 1]), repmat (x, 3, 1)) +%!assert (repmat (x, [3 3]), repmat (x, 3, 3)) # Tests for numel==1 case: %!shared x, r %! x = [ 65 ]; -%! r = kron(ones(2,2), x); -%!assert(r, repmat(x, [2 2])); -%!assert(char(r), repmat(char(x), [2 2])); -%!assert(int8(r), repmat(int8(x), [2 2])); +%! r = kron (ones (2,2), x); +%!assert (r, repmat (x, [2 2])) +%!assert (char (r), repmat (char (x), [2 2])) +%!assert (int8 (r), repmat (int8 (x), [2 2])) # Tests for ndims==2 case: %!shared x, r %! x = [ 65 66 67 ]; -%! r = kron(ones(2,2), x); -%!assert(r, repmat(x, [2 2])); -%!assert(char(r), repmat(char(x), [2 2])); -%!assert(int8(r), repmat(int8(x), [2 2])); +%! r = kron (ones (2,2), x); +%!assert (r, repmat (x, [2 2])) +%!assert (char (r), repmat (char (x), [2 2])) +%!assert (int8 (r), repmat (int8 (x), [2 2])) # Tests for dim>2 case: %!shared x, r %! x = [ 65 66 67 ]; -%! r = kron(ones(2,2), x); +%! r = kron (ones (2,2), x); %! r(:,:,2) = r(:,:,1); -%!assert(r, repmat(x, [2 2 2])); -%!assert(char(r), repmat(char(x), [2 2 2])); -%!assert(int8(r), repmat(int8(x), [2 2 2])); +%!assert (r, repmat (x, [2 2 2])) +%!assert (char (r), repmat (char (x), [2 2 2])) +%!assert (int8 (r), repmat (int8 (x), [2 2 2])) # Test that sparsity is kept -%!assert(sparse(4,4), repmat(sparse(2,2),[2 2])); +%!assert (sparse (4,4), repmat (sparse (2,2),[2 2])) +%!assert (size (repmat (".", -1, 1)), [0, 1]) +%!assert (size (repmat (".", 1, -1)), [1, 0]) -%!assert (size (repmat (".", -1, 1)), [0, 1]); -%!assert (size (repmat (".", 1, -1)), [1, 0]); -%!error (size (repmat (".", -1, -1))); - -%!assert (size (repmat (1, [1, 0])), [1, 0]); -%!assert (size (repmat (1, [5, 0])), [5, 0]); -%!assert (size (repmat (1, [0, 1])), [0, 1]); -%!assert (size (repmat (1, [0, 5])), [0, 5]); +%!assert (size (repmat (1, [1, 0])), [1, 0]) +%!assert (size (repmat (1, [5, 0])), [5, 0]) +%!assert (size (repmat (1, [0, 1])), [0, 1]) +%!assert (size (repmat (1, [0, 5])), [0, 5]) %!shared x %! x = struct ("a", [], "b", []); -%!assert (size (repmat (x, [1, 0])), [1, 0]); -%!assert (size (repmat (x, [5, 0])), [5, 0]); -%!assert (size (repmat (x, [0, 1])), [0, 1]); -%!assert (size (repmat (x, [0, 5])), [0, 5]); +%!assert (size (repmat (x, [1, 0])), [1, 0]) +%!assert (size (repmat (x, [5, 0])), [5, 0]) +%!assert (size (repmat (x, [0, 1])), [0, 1]) +%!assert (size (repmat (x, [0, 5])), [0, 5]) -%!assert (size (repmat ({1}, [1, 0])), [1, 0]); -%!assert (size (repmat ({1}, [5, 0])), [5, 0]); -%!assert (size (repmat ({1}, [0, 1])), [0, 1]); -%!assert (size (repmat ({1}, [0, 5])), [0, 5]); +%!assert (size (repmat ({1}, [1, 0])), [1, 0]) +%!assert (size (repmat ({1}, [5, 0])), [5, 0]) +%!assert (size (repmat ({1}, [0, 1])), [0, 1]) +%!assert (size (repmat ({1}, [0, 5])), [0, 5]) +%!error (size (repmat (".", -1, -1))) +
--- a/scripts/general/rot90.m +++ b/scripts/general/rot90.m @@ -28,8 +28,8 @@ ## @example ## @group ## rot90 ([1, 2; 3, 4], -1) -## @result{} 3 1 -## 4 2 +## @result{} 3 1 +## 4 2 ## @end group ## @end example ## @@ -95,8 +95,9 @@ %! assert(rot90 (x1, -1), x4); %% Test input validation -%!error rot90 (); -%!error rot90 (1, 2, 3); -%!error rot90 (1, ones(2)); -%!error rot90 (1, 1.5); -%!error rot90 (1, 1+i); +%!error rot90 () +%!error rot90 (1, 2, 3) +%!error rot90 (1, ones(2)) +%!error rot90 (1, 1.5) +%!error rot90 (1, 1+i) +
--- a/scripts/general/rotdim.m +++ b/scripts/general/rotdim.m @@ -124,35 +124,37 @@ endfunction -%!error rotdim (); -%!error rotdim (1, 2, 3, 4); %!shared r, rr -%! r = [1,2,3]; rr = [3,2,1]; -%!assert (rotdim (r, 0), r); -%!assert (rotdim (r, 1), rr'); -%!assert (rotdim (r, 2), rr); -%!assert (rotdim (r, 3), r'); -%!assert (rotdim (r, 3), rotdim (r, -1)); -%!assert (rotdim (r, 1), rotdim (r)); +%! r = [1,2,3]; rr = [3,2,1]; +%!assert (rotdim (r, 0), r) +%!assert (rotdim (r, 1), rr') +%!assert (rotdim (r, 2), rr) +%!assert (rotdim (r, 3), r') +%!assert (rotdim (r, 3), rotdim (r, -1)) +%!assert (rotdim (r, 1), rotdim (r)) %!shared c, cr -%! c = [1;2;3]; cr = [3;2;1]; -%!assert (rotdim (c, 0), c); -%!assert (rotdim (c, 1), c'); -%!assert (rotdim (c, 2), cr); -%!assert (rotdim (c, 3), cr'); -%!assert (rotdim (c, 3), rotdim (c, -1)); -%!assert (rotdim (c, 1), rotdim (c)); +%! c = [1;2;3]; cr = [3;2;1]; +%!assert (rotdim (c, 0), c) +%!assert (rotdim (c, 1), c') +%!assert (rotdim (c, 2), cr) +%!assert (rotdim (c, 3), cr') +%!assert (rotdim (c, 3), rotdim (c, -1)) +%!assert (rotdim (c, 1), rotdim (c)) %!shared m %! m = [1,2;3,4]; -%!assert (rotdim (m, 0), m); -%!assert (rotdim (m, 1), [2,4;1,3]); -%!assert (rotdim (m, 2), [4,3;2,1]); -%!assert (rotdim (m, 3), [3,1;4,2]); -%!assert (rotdim (m, 3), rotdim (m, -1)); -%!assert (rotdim (m, 1), rotdim (m)); +%!assert (rotdim (m, 0), m) +%!assert (rotdim (m, 1), [2,4;1,3]) +%!assert (rotdim (m, 2), [4,3;2,1]) +%!assert (rotdim (m, 3), [3,1;4,2]) +%!assert (rotdim (m, 3), rotdim (m, -1)) +%!assert (rotdim (m, 1), rotdim (m)) ## FIXME -- we need tests for multidimensional arrays and different ## values of PLANE. + +%!error rotdim () +%!error rotdim (1, 2, 3, 4) +
--- a/scripts/general/saveobj.m +++ b/scripts/general/saveobj.m @@ -30,7 +30,7 @@ ## function b = saveobj (a) ## b = a; ## if (isempty (b.field)) -## b.field = initfield(b); +## b.field = initfield (b); ## endif ## endfunction ## @end group
--- a/scripts/general/shift.m +++ b/scripts/general/shift.m @@ -80,19 +80,19 @@ %! r = [a, b, c]; %! m = [a; b; c]; %! -%! assert(shift (r, 0), r); -%! assert(shift (r, 3), [c, a, b]); -%! assert(shift (r, -6), [c, a, b]); -%! assert(shift (r, -3), [b, c, a]); -%! assert(shift (m, 1), [c; a; b]); -%! assert(shift (m, -2), [c; a; b]); +%! assert (shift (r, 0), r); +%! assert (shift (r, 3), [c, a, b]); +%! assert (shift (r, -6), [c, a, b]); +%! assert (shift (r, -3), [b, c, a]); +%! assert (shift (m, 1), [c; a; b]); +%! assert (shift (m, -2), [c; a; b]); %% Test input validation %!error shift () %!error shift (1, 2, 3, 4) %!error shift ([], 1) -%!error shift (ones(2), ones(2)) -%!error shift (ones(2), 1.5) +%!error shift (ones (2), ones (2)) +%!error shift (ones (2), 1.5) %!error shift (1, 1, 1.5) %!error shift (1, 1, 0) %!error shift (1, 1, 3)
--- a/scripts/general/shiftdim.m +++ b/scripts/general/shiftdim.m @@ -36,12 +36,12 @@ ## @group ## x = ones (1, 2, 3); ## size (shiftdim (x, -1)) -## @result{} [1, 1, 2, 3] +## @result{} [1, 1, 2, 3] ## size (shiftdim (x, 1)) -## @result{} [2, 3] -## [b, ns] = shiftdim (x); -## @result{} b = [1, 1, 1; 1, 1, 1] -## @result{} ns = 1 +## @result{} [2, 3] +## [b, ns] = shiftdim (x) +## @result{} b = [1, 1, 1; 1, 1, 1] +## @result{} ns = 1 ## @end group ## @end example ## @seealso {reshape, permute, ipermute, circshift, squeeze} @@ -90,11 +90,12 @@ %! assert (ns, 2); %! assert (shiftdim (y, -2), x); %! assert (size (shiftdim (x, 2)), [4 2]); -%!assert (size (shiftdim (rand (0, 1, 2))), [0 1 2]); + +%!assert (size (shiftdim (rand (0, 1, 2))), [0 1 2]) %% Test input validation -%!error(shiftdim ()); -%!error(shiftdim (1,2,3)); -%!error(shiftdim (1, ones (2))); -%!error(shiftdim (1, 1.5)); +%!error (shiftdim ()) +%!error (shiftdim (1,2,3)) +%!error (shiftdim (1, ones (2))) +%!error (shiftdim (1, 1.5))
--- a/scripts/general/sph2cart.m +++ b/scripts/general/sph2cart.m @@ -71,6 +71,7 @@ endfunction + %!test %! t = [0, 0, 0]; %! p = [0, 0, 0]; @@ -110,5 +111,5 @@ %!test %! S = [ 0, 0, 1; 0.5*pi, 0, 1; pi, 0, 1]; %! C = [ 1, 0, 0; 0, 1, 0; -1, 0, 0]; -%! assert (sph2cart(S), C, eps); +%! assert (sph2cart (S), C, eps);
--- a/scripts/general/structfun.m +++ b/scripts/general/structfun.m @@ -47,7 +47,7 @@ ## s.name2 = "Jill Jones"; ## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s, ## "UniformOutput", false) -## @result{} +## @result{} ## @{ ## name1 = Smith ## name2 = Jones @@ -133,14 +133,15 @@ %! d(1:2, 1, 1) = [1; 16]; %! d(1:2, 1, 2) = [4; 25]; %! d(1:2, 1, 3) = [9; 36]; -%! [aa, bb] = structfun(@__twoouts, s); -%! assert(aa, c); -%! assert(bb, d); +%! [aa, bb] = structfun (@__twoouts, s); +%! assert (aa, c); +%! assert (bb, d); %!test %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6}); %! c = struct ("a", {2, 4, 6}, "b", {8, 10, 12}); %! d = struct ("a", {1, 4, 9}, "b", {16, 25, 36}); -%! [aa, bb] = structfun(@__twoouts, s, "UniformOutput", false); -%! assert(aa, c); -%! assert(bb, d); +%! [aa, bb] = structfun (@__twoouts, s, "UniformOutput", false); +%! assert (aa, c); +%! assert (bb, d); +
--- a/scripts/general/subsindex.m +++ b/scripts/general/subsindex.m @@ -28,7 +28,7 @@ ## @example ## @group ## function b = myclass (a) -## b = class (struct ("a", a), "myclass"); +## b = class (struct ("a", a), "myclass"); ## endfunction ## @end group ## @end example @@ -39,7 +39,7 @@ ## @example ## @group ## function idx = subsindex (a) -## idx = double (a.a) - 1.0; +## idx = double (a.a) - 1.0; ## endfunction ## @end group ## @end example
--- a/scripts/general/trapz.m +++ b/scripts/general/trapz.m @@ -123,16 +123,16 @@ endfunction -%!assert (trapz(1:5), 12) -%!assert (trapz(0:0.5:2,1:5), 6) -%!assert (trapz([1:5;1:5].',1), [12,12]) -%!assert (trapz([1:5;1:5],2), [12;12]) -%!assert (trapz(repmat(reshape(1:5,1,1,5),2,2), 3), [12 12; 12 12]) -%!assert (trapz([0:0.5:2;0:0.5:2].',[1:5;1:5].',1), [6, 6]) -%!assert (trapz([0:0.5:2;0:0.5:2],[1:5;1:5],2), [6; 6]) -%!assert (trapz(repmat(reshape([0:0.5:2],1,1,5),2,2), ... -%! repmat(reshape(1:5,1,1,5),2,2), 3), [6 6; 6 6]) -%!assert (trapz(0:0.5:2,[(1:5)',(1:5)']), [6, 6]) -%!assert (trapz(0:0.5:2,[(1:5);(1:5)],2), [6; 6]) -%!assert (trapz(0:0.5:2,repmat(reshape(1:5,1,1,5),2,2),3), [6 6; 6 6]) +%!assert (trapz (1:5), 12) +%!assert (trapz (0:0.5:2,1:5), 6) +%!assert (trapz ([1:5;1:5].',1), [12,12]) +%!assert (trapz ([1:5;1:5],2), [12;12]) +%!assert (trapz (repmat (reshape (1:5,1,1,5),2,2), 3), [12 12; 12 12]) +%!assert (trapz ([0:0.5:2;0:0.5:2].',[1:5;1:5].',1), [6, 6]) +%!assert (trapz ([0:0.5:2;0:0.5:2],[1:5;1:5],2), [6; 6]) +%!assert (trapz (repmat (reshape ([0:0.5:2],1,1,5),2,2), ... +%! repmat (reshape (1:5,1,1,5),2,2), 3), [6 6; 6 6]) +%!assert (trapz (0:0.5:2,[(1:5)',(1:5)']), [6, 6]) +%!assert (trapz (0:0.5:2,[(1:5);(1:5)],2), [6; 6]) +%!assert (trapz (0:0.5:2,repmat (reshape (1:5,1,1,5),2,2),3), [6 6; 6 6])
--- a/scripts/general/triplequad.m +++ b/scripts/general/triplequad.m @@ -76,10 +76,10 @@ endfunction -%!assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadcc), pi ^ (3/2) * erf(1).^3, 1e-6) +%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadcc), pi^(3/2) * erf (1).^3, 1e-6) %% These tests are too expensive to run normally (~30 sec each). Disable them -#%!assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadgk), pi ^ (3/2) * erf(1).^3, 1e-6) -#%!#assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi ^ (3/2) * erf(1).^3, 1e-6) -#%!#assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi ^ (3/2) * erf(1).^3, 1e-6) +#%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadgk), pi^(3/2) * erf (1).^3, 1e-6) +#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi^(3/2) * erf (1).^3, 1e-6) +#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi^(3/2) * erf (1).^3, 1e-6)
--- a/scripts/geometry/convhull.m +++ b/scripts/geometry/convhull.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {@var{H} =} convhull (@var{x}, @var{y}) ## @deftypefnx {Function File} {@var{H} =} convhull (@var{x}, @var{y}, @var{options}) ## Compute the convex hull of the set of points defined by the -## vectors @var{x} and @var{y}. The hull @var{H} is an index vector into +## arrays @var{x} and @var{y}. The hull @var{H} is an index vector into ## the set of points and specifies which points form the enclosing hull. ## ## An optional third argument, which must be a string or cell array of strings, @@ -45,17 +45,20 @@ print_usage (); endif - if (! (isvector (x) && isvector (y) && length (x) == length (y)) - && ! size_equal (x, y)) - error ("convhull: X and Y must be the same size"); + ## convhulln expects column vectors + x = x(:); + y = y(:); + + if (length (x) != length (y)) + error ("convhull: X and Y must have the same size"); elseif (nargin == 3 && ! (ischar (options) || iscellstr (options))) error ("convhull: OPTIONS must be a string or cell array of strings"); endif if (nargin == 2) - i = convhulln ([x(:), y(:)]); + i = convhulln ([x, y]); else - i = convhulln ([x(:), y(:)], options); + i = convhulln ([x, y], options); endif n = rows (i); @@ -95,7 +98,7 @@ %!testif HAVE_QHULL %! x = -3:0.5:3; %! y = abs (sin (x)); -%! assert (convhull (x, y), [1;7;13;12;11;10;4;3;2;1]) +%! assert (convhull (x, y), [1;7;13;12;11;10;4;3;2;1]); %% FIXME: Need input validation tests
--- a/scripts/geometry/dsearch.m +++ b/scripts/geometry/dsearch.m @@ -32,9 +32,11 @@ idx = __dsearchn__ ([x(:), y(:)], [xi(:), yi(:)]); endfunction + %!shared x, y, tri %! x = [-1;-1;1]; %! y = [-1;1;-1]; %! tri = [1,2,3]; -%!assert (dsearch(x,y,tri,1,1/3), 3); -%!assert (dsearch(x,y,tri,1/3,1), 2); +%!assert (dsearch (x,y,tri,1,1/3), 3) +%!assert (dsearch (x,y,tri,1/3,1), 2) +
--- a/scripts/geometry/dsearchn.m +++ b/scripts/geometry/dsearchn.m @@ -46,12 +46,14 @@ endif endfunction + %!shared x, tri %! x = [-1,-1;-1,1;1,-1]; %! tri = [1,2,3]; -%!assert (dsearchn(x,tri,[1,1/3]), 3); -%!assert (dsearchn(x,tri,[1,1/3],NaN), NaN); -%!assert (dsearchn(x,tri,[1,1/3],NA), NA); -%!assert (dsearchn(x,tri,[1/3,1]), 2); -%!assert (dsearchn(x,tri,[1/3,1],NaN), NaN); -%!assert (dsearchn(x,tri,[1/3,1],NA), NA); +%!assert (dsearchn (x,tri,[1,1/3]), 3) +%!assert (dsearchn (x,tri,[1,1/3],NaN), NaN) +%!assert (dsearchn (x,tri,[1,1/3],NA), NA) +%!assert (dsearchn (x,tri,[1/3,1]), 2) +%!assert (dsearchn (x,tri,[1/3,1],NaN), NaN) +%!assert (dsearchn (x,tri,[1/3,1],NA), NA) +
--- a/scripts/geometry/griddata.m +++ b/scripts/geometry/griddata.m @@ -17,8 +17,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method}) -## @deftypefnx {Function File} {[@var{xi}, @var{yi}, @var{zi}] =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method}) +## @deftypefn {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}) +## @deftypefnx {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method}) +## @deftypefnx {Function File} {[@var{xi}, @var{yi}, @var{zi}] =} griddata (@dots{}) ## ## Generate a regular mesh from irregular data using interpolation. ## The function is defined by @code{@var{z} = f (@var{x}, @var{y})}. @@ -30,7 +31,7 @@ ## ## The interpolation method can be @code{"nearest"}, @code{"cubic"} or ## @code{"linear"}. If method is omitted it defaults to @code{"linear"}. -## @seealso{delaunay} +## @seealso{griddata3, griddatan, delaunay} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> @@ -38,11 +39,8 @@ ## xi and yi are not "meshgridded" if both are vectors ## of the same size (for compatibility) -function [rx, ry, rz] = griddata (x, y, z, xi, yi, method) +function [rx, ry, rz] = griddata (x, y, z, xi, yi, method = "linear") - if (nargin == 5) - method = "linear"; - endif if (nargin < 5 || nargin > 7) print_usage (); endif @@ -51,27 +49,32 @@ method = tolower (method); endif + ## Meshgrid if x and y are vectors but z is matrix if (isvector (x) && isvector (y) && all ([numel(y), numel(x)] == size (z))) [x, y] = meshgrid (x, y); - elseif (! all (size (x) == size (y) & size (x) == size (z))) - if (isvector (z)) - error ("griddata: X, Y, and Z, be vectors of same length"); - else - error ("griddata: lengths of X, Y must match the columns and rows of Z"); + endif + + if (isvector (x) && isvector (y) && isvector (z)) + if (! isequal (length (x), length (y), length (z))) + error ("griddata: X, Y, and Z must be vectors of the same length"); endif + elseif (! size_equal (x, y, z)) + error ("griddata: lengths of X, Y must match the columns and rows of Z"); endif ## Meshgrid xi and yi if they are a row and column vector. if (rows (xi) == 1 && columns (yi) == 1) [xi, yi] = meshgrid (xi, yi); + elseif (isvector (xi) && isvector (yi)) + ## Otherwise, convert to column vectors + xi = xi(:); + yi = yi(:); endif if (! size_equal (xi, yi)) error ("griddata: XI and YI must be vectors or matrices of same size"); endif - [nr, nc] = size (xi); - x = x(:); y = y(:); z = z(:); @@ -138,6 +141,7 @@ elseif (nargout == 0) mesh (xi, yi, zi); endif + endfunction @@ -183,3 +187,18 @@ %! zz2(isnan (zz)) = NaN; %! assert (zz, zz2, 100*eps); +%% Test input validation +%!error griddata () +%!error griddata (1) +%!error griddata (1,2) +%!error griddata (1,2,3) +%!error griddata (1,2,3,4) +%!error griddata (1,2,3,4,5,6,7) +%!error <vectors of the same length> griddata (1:3, 1:3, 1:4, 1:3, 1:3) +%!error <vectors of the same length> griddata (1:3, 1:4, 1:3, 1:3, 1:3) +%!error <vectors of the same length> griddata (1:4, 1:3, 1:3, 1:3, 1:3) +%!error <the columns and rows of Z> griddata (1:4, 1:3, ones (4,4), 1:3, 1:3) +%!error <the columns and rows of Z> griddata (1:4, 1:3, ones (3,5), 1:3, 1:3) +%!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:4, 1:3) +%!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:3, 1:4) +
--- a/scripts/geometry/griddata3.m +++ b/scripts/geometry/griddata3.m @@ -17,7 +17,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) +## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) ## ## Generate a regular mesh from irregular data using interpolation. ## The function is defined by @code{@var{y} = f (@var{x},@var{y},@var{z})}. @@ -25,7 +27,12 @@ ## ## The interpolation method can be @code{"nearest"} or @code{"linear"}. ## If method is omitted it defaults to @code{"linear"}. -## @seealso{griddata, delaunayn} +## +## The optional argument @var{options} is passed directly to Qhull when +## computing the Delaunay triangulation used for interpolation. See +## @code{delaunayn} for information on the defaults and how to pass different +## values. +## @seealso{griddata, griddatan, delaunayn} ## @end deftypefn ## Author: David Bateman <dbateman@free.fr> @@ -36,19 +43,29 @@ print_usage (); endif - if (!all (size (x) == size (y) & size (x) == size(z) & size(x) == size (v))) - error ("griddata3: X, Y, Z, and V must be vectors of same length"); + if (isvector (x) && isvector (y) && isvector (z) && isvector (v)) + if (! isequal (length (x), length (y), length (z), length (v))) + error ("griddata: X, Y, Z, and V must be vectors of the same length"); + endif + elseif (! size_equal (x, y, z, v)) + error ("griddata: X, Y, Z, and V must have equal sizes"); endif - ## meshgrid xi, yi and zi if they are vectors unless they - ## are vectors of the same length - if (isvector (xi) && isvector (yi) && isvector (zi) - && (numel (xi) != numel (yi) || numel (xi) != numel (zi))) - [xi, yi, zi] = meshgrid (xi, yi, zi); + ## meshgrid xi, yi and zi if they are vectors unless + ## they are vectors of the same length. + if (isvector (xi) && isvector (yi) && isvector (zi)) + if (! isequal (length (xi), length (yi), length (zi))) + [xi, yi, zi] = meshgrid (xi, yi, zi); + else + ## Otherwise, convert to column vectors + xi = xi(:); + yi = yi(:); + zi = zi(:); + endif endif - if (any (size(xi) != size(yi)) || any (size(xi) != size(zi))) - error ("griddata3: XI, YI and ZI must be vectors or matrices of same size"); + if (! size_equal (xi, yi, zi)) + error ("griddata3: XI, YI, and ZI must be vectors or matrices of the same size"); endif vi = griddatan ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:}); @@ -66,7 +83,7 @@ %! z = 2 * rand (1000, 1) - 1; %! v = x.^2 + y.^2 + z.^2; %! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8); -%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'linear'); +%! vi = griddata3 (x, y, z, v, xi, yi, zi, "linear"); %! vv = vi - xi.^2 - yi.^2 - zi.^2; %! assert (max (abs (vv(:))), 0, 0.1); @@ -79,6 +96,7 @@ %! z = 2 * rand (1000, 1) - 1; %! v = x.^2 + y.^2 + z.^2; %! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8); -%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'nearest'); +%! vi = griddata3 (x, y, z, v, xi, yi, zi, "nearest"); %! vv = vi - xi.^2 - yi.^2 - zi.^2; %! assert (max (abs (vv(:))), 0, 0.1) +
--- a/scripts/geometry/griddatan.m +++ b/scripts/geometry/griddatan.m @@ -17,7 +17,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}, @var{options}) +## @deftypefn {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}) +## @deftypefnx {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}) +## @deftypefnx {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}, @var{options}) ## ## Generate a regular mesh from irregular data using interpolation. ## The function is defined by @code{@var{y} = f (@var{x})}. @@ -25,16 +27,18 @@ ## ## The interpolation method can be @code{"nearest"} or @code{"linear"}. ## If method is omitted it defaults to @code{"linear"}. -## @seealso{griddata, delaunayn} +## +## The optional argument @var{options} is passed directly to Qhull when +## computing the Delaunay triangulation used for interpolation. See +## @code{delaunayn} for information on the defaults and how to pass different +## values. +## @seealso{griddata, griddata3, delaunayn} ## @end deftypefn ## Author: David Bateman <dbateman@free.fr> -function yi = griddatan (x, y, xi, method, varargin) +function yi = griddatan (x, y, xi, method = "linear", varargin) - if (nargin == 3) - method = "linear"; - endif if (nargin < 3) print_usage (); endif @@ -46,13 +50,12 @@ [m, n] = size (x); [mi, ni] = size (xi); - if (n != ni || size (y, 1) != m || size (y, 2) != 1) + if (n != ni || rows (y) != m || columns (y) != 1) error ("griddatan: dimensional mismatch"); endif ## triangulate data - ## tri = delaunayn(x, varargin{:}); - tri = delaunayn (x); + tri = delaunayn (x, varargin{:}); yi = NaN (mi, 1); @@ -85,22 +88,24 @@ endfunction -%!testif HAVE_QHULL -%! [xx,yy] = meshgrid(linspace(-1,1,32)); -%! xi = [xx(:), yy(:)]; -%! x = (2 * rand(100,2) - 1); -%! x = [x;1,1;1,-1;-1,-1;-1,1]; -%! y = sin(2*(sum(x.^2,2))); -%! zz = griddatan(x,y,xi,'linear'); -%! zz2 = griddata(x(:,1),x(:,2),y,xi(:,1),xi(:,2),'linear'); -%! assert (zz, zz2, 1e-10) %!testif HAVE_QHULL -%! [xx,yy] = meshgrid(linspace(-1,1,32)); +%! [xx,yy] = meshgrid (linspace (-1,1,32)); %! xi = [xx(:), yy(:)]; -%! x = (2 * rand(100,2) - 1); +%! x = 2*rand (100,2) - 1; %! x = [x;1,1;1,-1;-1,-1;-1,1]; -%! y = sin(2*(sum(x.^2,2))); -%! zz = griddatan(x,y,xi,'nearest'); -%! zz2 = griddata(x(:,1),x(:,2),y,xi(:,1),xi(:,2),'nearest'); -%! assert (zz, zz2, 1e-10) +%! y = sin (2 * sum (x.^2,2)); +%! zz = griddatan (x,y,xi,"linear"); +%! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2),"linear"); +%! assert (zz, zz2, 1e-10); + +%!testif HAVE_QHULL +%! [xx,yy] = meshgrid (linspace (-1,1,32)); +%! xi = [xx(:), yy(:)]; +%! x = 2*rand (100,2) - 1; +%! x = [x;1,1;1,-1;-1,-1;-1,1]; +%! y = sin (2*sum (x.^2,2)); +%! zz = griddatan (x,y,xi,"nearest"); +%! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2),"nearest"); +%! assert (zz, zz2, 1e-10); +
--- a/scripts/geometry/rectint.m +++ b/scripts/geometry/rectint.m @@ -111,21 +111,22 @@ endfunction -## Tests + ## Exactly overlapping -%!assert(rectint([0 0 1 1], [0 0 1 1]), 1) +%!assert (rectint ([0 0 1 1], [0 0 1 1]), 1) ## rect2 completely enclosed by rect1 -%!assert(rectint([-1 -1 3 3], [0 0 1 1]), 1) +%!assert (rectint ([-1 -1 3 3], [0 0 1 1]), 1) ## rect1 completely enclosed by rect2 -%!assert(rectint([0 0 1 1], [-1 -1 3 3]), 1) +%!assert (rectint ([0 0 1 1], [-1 -1 3 3]), 1) ## rect1 right and top in rect2 -%!assert(rectint([-1 -1 1.5 1.5], [0 0 1 1]), 0.25) +%!assert (rectint ([-1 -1 1.5 1.5], [0 0 1 1]), 0.25) ## rect2 right and top in rect1 -%!assert(rectint([0 0 1 1], [-1 -1 1.5 1.5]), 0.25) +%!assert (rectint ([0 0 1 1], [-1 -1 1.5 1.5]), 0.25) ## no overlap - shared corner -%!assert(rectint([0 0 1 1], [1 1 2 2]), 0) +%!assert (rectint ([0 0 1 1], [1 1 2 2]), 0) ## no overlap - shared edge -%!assert(rectint([0 0 1 1], [0 1 2 2]), 0) +%!assert (rectint ([0 0 1 1], [0 1 2 2]), 0) ## Correct orientation of output -%!assert(rectint([0 0 1 1;0.5 0.5 1 1;-1 -1 2 2], [1 1 2 2]), [0;0.25;0]) -%!assert(rectint([1 1 2 2], [0 0 1 1;0.5 0.5 1 1;-1 -1 2 2]), [0 0.25 0]) +%!assert (rectint ([0 0 1 1;0.5 0.5 1 1;-1 -1 2 2], [1 1 2 2]), [0;0.25;0]) +%!assert (rectint ([1 1 2 2], [0 0 1 1;0.5 0.5 1 1;-1 -1 2 2]), [0 0.25 0]) +
--- a/scripts/geometry/tsearchn.m +++ b/scripts/geometry/tsearchn.m @@ -82,26 +82,28 @@ Beta (:,end+1) = 1 - sum(Beta, 2); endfunction + %!shared x, tri %! x = [-1,-1;-1,1;1,-1]; %! tri = [1, 2, 3]; %!test %! [idx, p] = tsearchn (x,tri,[-1,-1]); -%! assert (idx, 1) -%! assert (p, [1,0,0], 1e-12) +%! assert (idx, 1); +%! assert (p, [1,0,0], 1e-12); %!test %! [idx, p] = tsearchn (x,tri,[-1,1]); -%! assert (idx, 1) -%! assert (p, [0,1,0], 1e-12) +%! assert (idx, 1); +%! assert (p, [0,1,0], 1e-12); %!test %! [idx, p] = tsearchn (x,tri,[1,-1]); -%! assert (idx, 1) -%! assert (p, [0,0,1], 1e-12) +%! assert (idx, 1); +%! assert (p, [0,0,1], 1e-12); %!test %! [idx, p] = tsearchn (x,tri,[-1/3,-1/3]); -%! assert (idx, 1) -%! assert (p, [1/3,1/3,1/3], 1e-12) +%! assert (idx, 1); +%! assert (p, [1/3,1/3,1/3], 1e-12); %!test %! [idx, p] = tsearchn (x,tri,[1,1]); -%! assert (idx, NaN) -%! assert (p, [NaN, NaN, NaN]) +%! assert (idx, NaN); +%! assert (p, [NaN, NaN, NaN]); +
--- a/scripts/geometry/voronoi.m +++ b/scripts/geometry/voronoi.m @@ -42,12 +42,12 @@ ## ## @example ## @group -## x = rand (10, 1); -## y = rand (size (x)); -## h = convhull (x, y); -## [vx, vy] = voronoi (x, y); -## plot (vx, vy, "-b", x, y, "o", x(h), y(h), "-g") -## legend ("", "points", "hull"); +## x = rand (10, 1); +## y = rand (size (x)); +## h = convhull (x, y); +## [vx, vy] = voronoi (x, y); +## plot (vx, vy, "-b", x, y, "o", x(h), y(h), "-g"); +## legend ("", "points", "hull"); ## @end group ## @end example ##
--- a/scripts/help/__makeinfo__.m +++ b/scripts/help/__makeinfo__.m @@ -41,7 +41,7 @@ ## will be expanded to the text ## ## @example -## See also: arg1, arg2@, ... +## See also: arg1, arg2, ... ## @end example ## ## @noindent @@ -86,10 +86,13 @@ error ("__makeinfo__: third input argument must be a function handle"); endif - - ## It seems like makeinfo sometimes gets angry if the first character - ## on a line is a space, so we remove these. - text = strrep (text, "\n ", "\n"); + ## Formatting in m-files has an extra space at the beginning of every line. + ## Remove these unwanted spaces if present. First text char is "\n" delim. + if (text(2) == " ") + text = strrep (text, "\n ", "\n"); + endif + ## Texinfo crashes if @end tex does not appear first on the line. + text = regexprep (text, '^ +@end tex', '@end tex', 'lineanchors'); ## Handle @seealso macro see_also_pat = '@seealso *\{(.*)\}'; @@ -145,6 +148,7 @@ end_unwind_protect endfunction + ## No test needed for internal helper function. %!assert (1)
--- a/scripts/help/doc.m +++ b/scripts/help/doc.m @@ -106,6 +106,10 @@ endfunction -%!test if exist( info_file ()) != 2 && exist (sprintf ("%s.gz", info_file ())) != 2 -%! error ("Info file %s or %s.gz does not exist!", info_file (), info_file ()); -%! endif + +%!test +%! ifile = info_file (); +%! if (exist (ifile) != 2 && exist (sprintf ("%s.gz", ifile)) != 2) +%! error ("Info file %s or %s.gz does not exist!", ifile, ifile); +%! endif +
--- a/scripts/help/get_first_help_sentence.m +++ b/scripts/help/get_first_help_sentence.m @@ -153,7 +153,8 @@ text = first_sentence_plain_text (help_text, max_len); endfunction -%!assert (strcmp (get_first_help_sentence('get_first_help_sentence'), "Return the first sentence of a function's help text.")); + +%!assert (get_first_help_sentence ('get_first_help_sentence'), "Return the first sentence of a function's help text.") %% Test input validation %!error get_first_help_sentence ()
--- a/scripts/help/help.m +++ b/scripts/help/help.m @@ -184,3 +184,4 @@ %!assert (! isempty (strfind (help ("ls"), "List directory contents"))) %!error <invalid input> help (42) +
--- a/scripts/help/lookfor.m +++ b/scripts/help/lookfor.m @@ -20,11 +20,11 @@ ## @deftypefn {Command} {} lookfor @var{str} ## @deftypefnx {Command} {} lookfor -all @var{str} ## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor (@var{str}) -## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor ('-all', @var{str}) +## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor ("-all", @var{str}) ## Search for the string @var{str} in all functions found in the current ## function search path. By default, @code{lookfor} searches for @var{str} ## in the first sentence of the help string of each function found. The entire -## help text of each function can be searched if the '-all' argument is +## help text of each function can be searched if the "-all" argument is ## supplied. All searches are case insensitive. ## ## Called with no output arguments, @code{lookfor} prints the list of @@ -36,7 +36,7 @@ ## sentence of the help text is dependent on the format of the ## function's help. All Octave core functions are correctly ## formatted, but the same can not be guaranteed for external packages and -## user-supplied functions. Therefore, the use of the '-all' argument may +## user-supplied functions. Therefore, the use of the "-all" argument may ## be necessary to find related functions that are not a part of Octave. ## @seealso{help, doc, which} ## @end deftypefn
--- a/scripts/help/type.m +++ b/scripts/help/type.m @@ -111,14 +111,16 @@ endfor endfunction + %!test %! var = 1; %! typestr = type ("var"); %! typestr = typestr{1}(1:17); %! assert (typestr, "var is a variable"); -%!assert (type ('dot'){1}, "dot is a dynamically-linked function") -%!assert (type ('cat'){1}, "cat is a built-in function") -%!assert (type ('+'){1}, "+ is an operator") -%!assert (type ('end'){1}, "end is a keyword") +%!assert (type ("dot"){1}, "dot is a dynamically-linked function") +%!assert (type ("cat"){1}, "cat is a built-in function") +%!assert (type ("+"){1}, "+ is an operator") +%!assert (type ("end"){1}, "end is a keyword") %!error (type ('NO_NAME')) +
--- a/scripts/help/unimplemented.m +++ b/scripts/help/unimplemented.m @@ -321,7 +321,6 @@ "printdlg", "printopt", "printpreview", - "profile", "profsave", "propedit", "propertyeditor", @@ -333,7 +332,6 @@ "reducepatch", "reducevolume", "resample", - "rgbplot", "root", "rotate", "rotate3d", @@ -431,5 +429,4 @@ %! assert (str(1:51), "quad2d is not implemented. Consider using dblquad."); %! str = unimplemented ("MException"); %! assert (str(1:58), "the `MException' function is not yet implemented in Octave"); - - +
--- a/scripts/help/which.m +++ b/scripts/help/which.m @@ -62,4 +62,5 @@ %! str = which ("dot"); %! assert (str(end-6:end), "dot.oct"); -%!assert (which ("NO_NAME"), ""); +%!assert (which ("_NO_SUCH_NAME_"), "") +
--- a/scripts/image/autumn.m +++ b/scripts/image/autumn.m @@ -44,7 +44,7 @@ map = [1, 0, 0]; elseif (n > 1) r = ones (n, 1); - g = (0:n - 1)' ./ (n - 1); + g = [0:(n-1)]' / (n - 1); b = zeros (n, 1); map = [r, g, b]; else
--- a/scripts/image/bone.m +++ b/scripts/image/bone.m @@ -44,16 +44,18 @@ map = [0, 0, 0]; elseif (n > 1) x = linspace (0, 1, n)'; - - r = (x < 3/4) .* (7/8 * x) + (x >= 3/4) .* (11/8 * x - 3/8); - g = (x < 3/8) .* (7/8 * x)\ - + (x >= 3/8 & x < 3/4) .* (29/24 * x - 1/8)\ + r = (x < 3/4) .* (7/8 * x) ... + + (x >= 3/4) .* (11/8 * x - 3/8); + g = (x < 3/8) .* (7/8 * x) ... + + (x >= 3/8 & x < 3/4) .* (29/24 * x - 1/8) ... + (x >= 3/4) .* (7/8 * x + 1/8); - b = (x < 3/8) .* (29/24 * x) + (x >= 3/8) .* (7/8 * x + 1/8); + b = (x < 3/8) .* (29/24 * x) ... + + (x >= 3/8) .* (7/8 * x + 1/8); map = [r, g, b]; else map = []; endif + endfunction
--- a/scripts/image/brighten.m +++ b/scripts/image/brighten.m @@ -18,20 +18,18 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{map_out} =} brighten (@var{map}, @var{beta}) +## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta}) ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{h}, @var{beta}) -## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta}) -## Darken or brighten the given colormap. If the @var{map} argument -## is omitted, the function is applied to the current colormap. The first -## argument can also be a valid graphics handle @var{h}, in which case -## @code{brighten} is applied to the colormap associated with this handle. +## Brighten or darken a colormap. If the @var{map} argument is omitted, the +## function is applied to the current colormap. The first argument can also be +## a valid graphics handle @var{h}, in which case @code{brighten} is applied to +## the colormap associated with this handle. ## -## Should the resulting colormap @var{map_out} not be assigned, it will be -## written to the current colormap. +## The argument @var{beta} must be a scalar between -1 and 1, where a +## negative value darkens and a positive value brightens the colormap. ## -## The argument @var{beta} should be a scalar between -1 and 1, -## where a negative value darkens and a positive value brightens -## the colormap. -## @seealso{colormap} +## If no output is specified then the result is written to the current colormap. +## @seealso{colormap, contrast} ## @end deftypefn function rmap = brighten (arg1, beta)
new file mode 100644 --- /dev/null +++ b/scripts/image/colorcube.m @@ -0,0 +1,96 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{map} =} colorcube () +## @deftypefnx {Function File} {@var{map} =} colorcube (@var{n}) +## Create color colormap. This colormap is composed of as many equally +## spaced colors (not grays) in the RGB color space as possible. If there +## are not a perfect number @var{n} of regularly spaced colors then the +## remaining entries in the colormap are gradients of pure red, green, blue, +## and gray. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. +## @seealso{colormap} +## @end deftypefn + +function map = colorcube (n) + + if (nargin == 0) + n = rows (colormap); + elseif (nargin == 1) + if (! isscalar (n)) + error ("colorcube: argument must be a scalar"); + endif + else + print_usage (); + endif + + if (n < 9) + map = gray (n); + return; + endif + + # Create colorcube of evenly spaced points with side length of n^1/3 + cubelen = fix (cbrt (n)); + reserve = n - cubelen^3; + + if (reserve == 0) + # Steal space from blue to put the gray gradient + [r, g, b] = meshgrid (linspace (0,1,cubelen), + linspace (0,1,cubelen), + linspace (0,1,cubelen-1)); + else + [r, g, b] = meshgrid (linspace (0,1,cubelen), + linspace (0,1,cubelen), + linspace (0,1,cubelen)); + endif + + # Create map and weed out grays + map = [r(:), g(:), b(:)]; + idx = any (bsxfun (@ne, map(:, 1), map(:, 2:3)), 2); + map = map(idx, :); + + # Weed out pure colors + idx = sum (map == 0, 2); + map = map(idx != 2, :); + + # Put in remaining gradients of pure red, green, blue, and gray + reserve = n - rows (map) - 1; + csteps = fix (reserve/4); + cstepsz = 1 / csteps; + cgrad = (cstepsz:cstepsz:1)'; + gsteps = reserve - 3*csteps; + gstepsz = 1 / gsteps; + ggrad = (gstepsz:gstepsz:1)'; + map = [map + cgrad, zeros(csteps, 1), zeros(csteps, 1) + zeros(csteps, 1), cgrad, zeros(csteps, 1) + zeros(csteps, 1), zeros(csteps, 1), cgrad + 0, 0, 0 + ggrad, ggrad, ggrad]; + +endfunction + + +%!demo +%! ## Show the 'colorcube' colormap as an image +%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); +%! axis ([1, 64, 0, 1], "ticy", "xy"); +%! colormap (colorcube (64)); +
--- a/scripts/image/colormap.m +++ b/scripts/image/colormap.m @@ -20,12 +20,12 @@ ## @deftypefn {Function File} {@var{cmap} =} colormap () ## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{map}) ## @deftypefnx {Function File} {@var{cmap} =} colormap ("default") -## Set the current colormap. +## Query or set the current colormap. ## ## @code{colormap (@var{map})} sets the current colormap to @var{map}. The -## color map should be an @var{n} row by 3 column matrix. The columns +## colormap should be an @var{n} row by 3 column matrix. The columns ## contain red, green, and blue intensities respectively. All entries -## should be between 0 and 1 inclusive. The new colormap is returned. +## must be between 0 and 1 inclusive. The new colormap is returned. ## ## @code{colormap ("default")} restores the default colormap (the ## @code{jet} map with 64 entries). The default colormap is returned.
--- a/scripts/image/contrast.m +++ b/scripts/image/contrast.m @@ -17,12 +17,12 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} contrast (@var{x}) -## @deftypefnx {Function File} {} contrast (@var{x}, @var{n}) +## @deftypefn {Function File} {@var{map} =} contrast (@var{x}) +## @deftypefnx {Function File} {@var{map} =} contrast (@var{x}, @var{n}) ## Return a gray colormap that maximizes the contrast in an image. The ## returned colormap will have @var{n} rows. If @var{n} is not defined ## then the size of the current colormap is used. -## @seealso{colormap} +## @seealso{colormap, brighten} ## @end deftypefn function map = contrast (x, n) @@ -50,11 +50,14 @@ %!demo %! clf; %! img = reshape (1:100, 10, 10); -%! image (img); -%! colormap (gray (10)); -%! title ("Image with default 256 gray levels"); -%! input ("Press <enter> to continue: ", "s"); -%! colormap (contrast (img)); +%! imagesc (img); +%! colormap (gray (64)); +%! title ("Image with default 64 gray levels"); +%! pos = get (gcf, "position"); +%! pos(1) += pos(3) + 15; +%! figure ("position", pos); +%! colormap (contrast (img, 10)); +%! imagesc (img); %! title ("Image with contrast enhanced"); %!assert (contrast (1:100,10), [([0:9]/9)',([0:9]/9)',([0:9]/9)'], 1e-10)
--- a/scripts/image/cool.m +++ b/scripts/image/cool.m @@ -42,7 +42,7 @@ if (n == 1) map = [0, 1, 1]; elseif (n > 1) - r = (0:n - 1)' ./ (n - 1); + r = [0:(n-1)]' / (n - 1); g = 1 - r; b = ones (n, 1); map = [r, g, b];
--- a/scripts/image/copper.m +++ b/scripts/image/copper.m @@ -44,7 +44,8 @@ map = [0, 0, 0]; elseif (n > 1) x = linspace (0, 1, n)'; - r = (x < 4/5) .* (5/4 * x) + (x >= 4/5); + r = (x < 4/5) .* (5/4 * x) ... + + (x >= 4/5); g = 4/5 * x; b = 1/2 * x; map = [r, g, b];
--- a/scripts/image/flag.m +++ b/scripts/image/flag.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{map} =} flag () ## @deftypefnx {Function File} {@var{map} =} flag (@var{n}) -## Create color colormap. This colormap cycles through red, white, blue +## Create color colormap. This colormap cycles through red, white, blue, ## and black with each index change. ## The argument @var{n} must be a scalar. ## If unspecified, the length of the current colormap, or 64, is used. @@ -40,14 +40,8 @@ print_usage (); endif - p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; - if (rem(n,4) == 0) - map = kron (ones (n / 4, 1), p); - else - m1 = kron (ones (fix (n / 4), 1), p); - m2 = p(1:rem (n, 4), :); - map = [m1; m2]; - endif + C = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; + map = C(rem (0:(n-1), 4) + 1, :); endfunction
--- a/scripts/image/gmap40.m +++ b/scripts/image/gmap40.m @@ -23,8 +23,8 @@ ## magenta and cyan. This colormap is specifically designed for users of ## gnuplot 4.0 where these 6 colors are the allowable ones for patch objects. ## The argument @var{n} must be a scalar. -## If unspecified, a length of 6 is assumed. Larger values -## of @var{n} result in a repetition of the above colors. +## If unspecified, a length of 6 is assumed. Larger values of @var{n} result +## in a repetition of the above colors. ## @seealso{colormap} ## @end deftypefn @@ -40,12 +40,8 @@ print_usage (); endif - if (n >= 1) - map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1], - ceil (n / 6), 1) (1:n, :); - else - map = []; - endif + C = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1]; + map = C(rem (0:(n-1), 6) + 1, :); endfunction
--- a/scripts/image/gray.m +++ b/scripts/image/gray.m @@ -23,6 +23,7 @@ ## shades of gray. ## The argument @var{n} must be a scalar. ## If unspecified, the length of the current colormap, or 64, is used. +## @seealso{colormap} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us> @@ -41,9 +42,9 @@ print_usage (); endif - gr = [0:(n-1)]'; + gr = [0:(n-1)]' / (n - 1); - map = [ gr, gr, gr ] / (n - 1); + map = [gr, gr, gr]; endfunction
--- a/scripts/image/gray2ind.m +++ b/scripts/image/gray2ind.m @@ -17,10 +17,13 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{img}, @var{map}] =} gray2ind (@var{I}, @var{n}) +## @deftypefn {Function File} {[@var{img} =} gray2ind (@var{I}) +## @deftypefnx {Function File} {[@var{img} =} gray2ind (@var{I}, @var{n}) +## @deftypefnx {Function File} {[@var{img}, @var{map} =} gray2ind (@dots{}) ## Convert a gray scale intensity image to an Octave indexed image. -## The indexed image will consist of @var{n} different intensity values. If not -## given @var{n} will default to 64. +## The indexed image will consist of @var{n} different intensity values. +## If not given @var{n} defaults to 64. +## @seealso{ind2gray, rgb2ind} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/hot.m +++ b/scripts/image/hot.m @@ -44,9 +44,11 @@ map = [0, 0, 0]; elseif (n > 1) x = linspace (0, 1, n)'; - r = (x < 2/5) .* (5/2 * x) + (x >= 2/5); - g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) + (x >= 4/5); - b = (x >= 4/5) .* (5*x - 4); + r = (x < 2/5) .* (5/2 * x) ... + + (x >= 2/5); + g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) ... + + (x >= 4/5); + b = (x >= 4/5) .* (5 * x - 4); map = [r, g, b]; else map = [];
--- a/scripts/image/hsv.m +++ b/scripts/image/hsv.m @@ -20,9 +20,9 @@ ## @deftypefn {Function File} {} hsv (@var{n}) ## Create color colormap. This colormap begins with red, changes through ## yellow, green, cyan, blue, and magenta, before returning to red. -## It is useful for displaying periodic functions. It is obtained by linearly -## varying the hue through all possible values while keeping constant maximum -## saturation and value and is equivalent to +## It is useful for displaying periodic functions. The map is obtained by +## linearly varying the hue through all possible values while keeping constant +## maximum saturation and value. The equivalent code is ## @code{hsv2rgb ([linspace(0,1,N)', ones(N,2)])}. ## ## The argument @var{n} must be a scalar. @@ -47,8 +47,8 @@ if (n == 1) map = [1, 0, 0]; elseif (n > 1) - h = linspace (0, 1, n)'; - map = hsv2rgb ([h, ones(n, 1), ones(n, 1)]); + hue = linspace (0, 1, n)'; + map = hsv2rgb ([hue, ones(n,1), ones(n,1)]); else map = []; endif
--- a/scripts/image/hsv2rgb.m +++ b/scripts/image/hsv2rgb.m @@ -17,9 +17,11 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{rgb_map} =} hsv2rgb (@var{hsv_map}) -## Transform a colormap or image from the HSV space to the RGB space. -## @seealso{rgb2hsv} +## @deftypefn {Function File} {@var{rgb_map} =} hsv2rgb (@var{hsv_map}) +## @deftypefnx {Function File} {@var{rgb_img} =} hsv2rgb (@var{hsv_img}) +## Transform a colormap or image from hue-saturation-value (HSV) space to +## red-green-blue (RGB) space. +## @seealso{rgb2hsv, ind2rgb, ntsc2rgb} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de> @@ -27,10 +29,10 @@ function rgb_map = hsv2rgb (hsv_map) -## Each color value x = (r,g,b) is calculated with -## x = (1-sat)*val+sat*val*f_x(hue) -## where f_x(hue) is a piecewise defined function for -## each color with f_r(hue-2/3) = f_g(hue) = f_b(hue-1/3). + ## Each color value x = (r,g,b) is calculated with + ## x = (1-sat)*val+sat*val*f_x(hue) + ## where f_x(hue) is a piecewise defined function for + ## each color with f_r(hue-2/3) = f_g(hue) = f_b(hue-1/3). if (nargin != 1) print_usage ();
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -20,24 +20,24 @@ ## @deftypefn {Function File} {} image (@var{img}) ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img}) ## @deftypefnx {Function File} {@var{h} =} image (@dots{}) -## Display a matrix as a color image. The elements of @var{img} are indices -## into the current colormap, and the colormap will be scaled so that the -## extremes of @var{img} are mapped to the extremes of the colormap. +## Display a matrix as a color image. ## +## The elements of @var{img} are indices into the current colormap. ## The axis values corresponding to the matrix elements are specified in -## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these +## @var{x} and @var{y}. If you are using gnuplot 4.1 or earlier, these ## variables are ignored. ## +## The optional return value @var{h} is a graphics handle to the image. +## ## Implementation Note: The origin (0, 0) for images is located in the ## upper left. For ordinary plots, the origin is located in the lower ## left. Octave handles this inversion by plotting the data normally, ## and then reversing the direction of the y-axis by setting the -## @code{ydir} property to @code{"reverse"}. This has implications whenever +## @code{ydir} property to "reverse". This has implications whenever ## an image and an ordinary plot need to be overlaid. The recommended ## solution is to display the image and then plot the reversed ydata ## using, for example, @code{flipud (ydata,1)}. ## -## The optional return value @var{h} is a graphics handle to the image. ## @seealso{imshow, imagesc, colormap} ## @end deftypefn @@ -90,7 +90,7 @@ ## Generic image creation. ## ## The axis values corresponding to the matrix elements are specified in -## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these +## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these ## variables are ignored. ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -25,7 +25,7 @@ ## Display a scaled version of the matrix @var{A} as a color image. The ## colormap is scaled so that the entries of the matrix occupy the entire ## colormap. If @var{limits} = [@var{lo}, @var{hi}] are given, then that -## range is set to the 'clim' of the current axes. +## range is set to the "clim" of the current axes. ## ## The axis values corresponding to the matrix elements are specified in ## @var{x} and @var{y}, either as pairs giving the minimum and maximum
--- a/scripts/image/imread.m +++ b/scripts/image/imread.m @@ -89,6 +89,7 @@ endfunction + %!testif HAVE_MAGICK %! vpng = [ ... %! 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, ... @@ -107,11 +108,12 @@ %! 16, 28, 160, 16, 0, 197, 214, 13, 34, 74, ... %! 117, 213, 17, 0, 0, 0, 0, 73, 69, 78, ... %! 68, 174, 66, 96, 130]; -%! fid = fopen('test.png', 'wb'); -%! fwrite(fid, vpng); -%! fclose(fid); -%! A = imread('test.png'); -%! delete('test.png'); -%! assert(A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0])); -%! assert(A(:,:,2), uint8 ([0, 255, 0; 255, 28, 255; 0, 255, 0])); -%! assert(A(:,:,3), uint8 ([0, 255, 0; 255, 36, 255; 0, 255, 0])); +%! fid = fopen ("test.png", "wb"); +%! fwrite (fid, vpng); +%! fclose (fid); +%! A = imread ("test.png"); +%! delete ("test.png"); +%! assert (A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0])); +%! assert (A(:,:,2), uint8 ([0, 255, 0; 255, 28, 255; 0, 255, 0])); +%! assert (A(:,:,3), uint8 ([0, 255, 0; 255, 36, 255; 0, 255, 0])); +
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -41,6 +41,7 @@ ## ## If given, the parameter @var{string_param1} has value ## @var{value1}. @var{string_param1} can be any of the following: +## ## @table @asis ## @item "displayrange" ## @var{value1} is the display range as described above.
--- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -187,14 +187,15 @@ endfunction + %% Test input validation -%!error imwrite () # Wrong # of args -%!error imwrite (1) # Wrong # of args -%!error imwrite ({"cell"}, "filename.jpg") # Wrong class for img -%!error imwrite (1, [], "filename.jpg") # Empty image map -%!error imwrite (1, 2, 3) # No filename specified -%!error imwrite (1, "filename") # No fmt specified -%!error imwrite (1, "filename", "junk") # Invalid fmt specified -%!error imwrite ([], "filename.jpg") # Empty img matrix -%!error imwrite (spones(2), "filename.jpg") # Invalid sparse img +%!error imwrite () # Wrong # of args +%!error imwrite (1) # Wrong # of args +%!error imwrite ({"cell"}, "filename.jpg") # Wrong class for img +%!error imwrite (1, [], "filename.jpg") # Empty image map +%!error imwrite (1, 2, 3) # No filename specified +%!error imwrite (1, "filename") # No fmt specified +%!error imwrite (1, "filename", "junk") # Invalid fmt specified +%!error imwrite ([], "filename.jpg") # Empty img matrix +%!error imwrite (spones (2), "filename.jpg") # Invalid sparse img
--- a/scripts/image/ind2gray.m +++ b/scripts/image/ind2gray.m @@ -17,11 +17,12 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} ind2gray (@var{x}, @var{map}) -## Convert an Octave indexed image to a gray scale intensity image. +## @deftypefn {Function File} {} ind2gray (@var{x}) +## @deftypefnx {Function File} {} ind2gray (@var{x}, @var{map}) +## Convert a color indexed image to a gray scale intensity image. ## If @var{map} is omitted, the current colormap is used to determine the ## intensities. -## @seealso{gray2ind, rgb2ntsc, image, colormap} +## @seealso{gray2ind, ind2rgb} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/ind2rgb.m +++ b/scripts/image/ind2rgb.m @@ -17,13 +17,14 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{rgb} =} ind2rgb (@var{x}, @var{map}) -## @deftypefnx {Function File} {[@var{R}, @var{R}, @var{R}] =} ind2rgb (@var{x}, @var{map}) +## @deftypefn {Function File} {@var{rgb} =} ind2rgb (@var{x}) +## @deftypefnx {Function File} {@var{rgb} =} ind2rgb (@var{x}, @var{map}) +## @deftypefnx {Function File} {[@var{R}, @var{G}, @var{B}] =} ind2rgb (@dots{}) ## Convert an indexed image to red, green, and blue color components. ## If the colormap doesn't contain enough colors, pad it with the ## last color in the map. ## If @var{map} is omitted, the current colormap is used for the conversion. -## @seealso{rgb2ind, image, imshow, ind2gray, gray2ind} +## @seealso{rgb2ind, ind2gray, hsv2rgb, ntsc2rgb} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/jet.m +++ b/scripts/image/jet.m @@ -43,12 +43,15 @@ if (n == 1) map = [0, 0, 0.5]; elseif (n > 1) - x = linspace(0, 1, n)'; - r = (x >= 3/8 & x < 5/8) .* (4 * x - 3/2)\ - + (x >= 5/8 & x < 7/8) + (x >= 7/8) .* (-4 * x + 9/2); - g = (x >= 1/8 & x < 3/8) .* (4 * x - 1/2)\ - + (x >= 3/8 & x < 5/8) + (x >= 5/8 & x < 7/8) .* (-4 * x + 7/2); - b = (x < 1/8) .* (4 * x + 1/2) + (x >= 1/8 & x < 3/8)\ + x = linspace (0, 1, n)'; + r = (x >= 3/8 & x < 5/8) .* (4 * x - 3/2) ... + + (x >= 5/8 & x < 7/8) ... + + (x >= 7/8) .* (-4 * x + 9/2); + g = (x >= 1/8 & x < 3/8) .* (4 * x - 1/2) ... + + (x >= 3/8 & x < 5/8) ... + + (x >= 5/8 & x < 7/8) .* (-4 * x + 7/2); + b = (x < 1/8) .* (4 * x + 1/2) ... + + (x >= 1/8 & x < 3/8) ... + (x >= 3/8 & x < 5/8) .* (-4 * x + 5/2); map = [r, g, b]; else
new file mode 100644 --- /dev/null +++ b/scripts/image/lines.m @@ -0,0 +1,54 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{map} =} lines () +## @deftypefnx {Function File} {@var{map} =} lines (@var{n}) +## Create color colormap. This colormap is composed of the list of colors +## in the current axes "ColorOrder" property. The default is blue, +## green, red, cyan, pink, yellow, and gray. +## The argument @var{n} must be a scalar. +## If unspecified, the length of the current colormap, or 64, is used. +## @seealso{colormap} +## @end deftypefn + +function map = lines (n) + + if (nargin == 0) + n = rows (colormap); + elseif (nargin == 1) + if (! isscalar (n)) + error ("lines: argument must be a scalar"); + endif + else + print_usage (); + endif + + C = get (gca, "colororder"); + nr = rows (C); + map = C(rem (0:(n-1), nr) + 1, :); + +endfunction + + +%!demo +%! ## Show the 'lines' colormap as an image +%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); +%! axis ([1, 64, 0, 1], "ticy", "xy"); +%! colormap (lines (64)); +
--- a/scripts/image/module.mk +++ b/scripts/image/module.mk @@ -4,6 +4,7 @@ image/autumn.m \ image/bone.m \ image/brighten.m \ + image/colorcube.m \ image/colormap.m \ image/contrast.m \ image/cool.m \ @@ -24,6 +25,7 @@ image/ind2gray.m \ image/ind2rgb.m \ image/jet.m \ + image/lines.m \ image/ntsc2rgb.m \ image/ocean.m \ image/pink.m \ @@ -32,6 +34,8 @@ image/rgb2hsv.m \ image/rgb2ind.m \ image/rgb2ntsc.m \ + image/rgbplot.m \ + image/spinmap.m \ image/spring.m \ image/summer.m \ image/white.m \
--- a/scripts/image/ntsc2rgb.m +++ b/scripts/image/ntsc2rgb.m @@ -17,9 +17,11 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} ntsc2rgb (@var{yiq}) -## Transform a colormap or image from NTSC to RGB. -## @seealso{rgb2ntsc} +## @deftypefn {Function File} {@var{rgb_map} =} ntsc2rgb (@var{yiq_map}) +## @deftypefnx {Function File} {@var{rgb_img} =} ntsc2rgb (@var{yiq_img}) +## Transform a colormap or image from luminance-chrominance (NTSC) space to +## red-green-blue (RGB) space. +## @seealso{rgb2ntsc, hsv2rgb, ind2rgb} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/ocean.m +++ b/scripts/image/ocean.m @@ -23,6 +23,7 @@ ## of blue. ## The argument @var{n} must be a scalar. ## If unspecified, the length of the current colormap, or 64, is used. +## @seealso{colormap} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us> @@ -44,16 +45,14 @@ cutin = fix (n/3); dr = (n - 1) / cutin; - r = prepad ([0:dr:(n-1)], n)'; dg = (n - 1) / (2 * cutin); - - g = prepad([0:dg:(n-1)], n)'; + g = prepad ([0:dg:(n-1)], n)'; b = [0:(n-1)]'; - map = [ r, g, b ] / (n - 1); + map = [r, g, b] / (n - 1); endfunction
--- a/scripts/image/pink.m +++ b/scripts/image/pink.m @@ -44,12 +44,13 @@ map = [0, 0, 0]; elseif (n > 1) x = linspace (0, 1, n)'; - r = (x < 3/8) .* (14/9 * x) + (x >= 3/8) .* (2/3 * x + 1/3); - g = (x < 3/8) .* (2/3 * x)\ - + (x >= 3/8 & x < 3/4) .* (14/9 * x - 1/3)\ + r = (x < 3/8) .* (14/9 * x) ... + + (x >= 3/8) .* (2/3 * x + 1/3); + g = (x < 3/8) .* (2/3 * x) ... + + (x >= 3/8 & x < 3/4) .* (14/9 * x - 1/3) ... + (x >= 3/4) .* (2/3 * x + 1/3); - b = (x < 3/4) .* (2/3 * x) + (x >= 3/4) .* (2 * x - 1); - + b = (x < 3/4) .* (2/3 * x) ... + + (x >= 3/4) .* (2 * x - 1); map = sqrt ([r, g, b]); else map = [];
--- a/scripts/image/prism.m +++ b/scripts/image/prism.m @@ -40,13 +40,8 @@ print_usage (); endif - p = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1]; - - if (rem (n, 6) == 0) - map = kron(ones (fix (n / 6), 1), p); - else - map = [kron(ones (fix (n / 6), 1), p); p(1:rem (n, 6), :)]; - endif + C = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1]; + map = C(rem (0:(n-1), 6) + 1, :); endfunction
--- a/scripts/image/rainbow.m +++ b/scripts/image/rainbow.m @@ -47,11 +47,18 @@ map = [1, 0, 0]; elseif (n > 1) x = linspace (0, 1, n)'; - r = (x < 2/5) + (x >= 2/5 & x < 3/5) .* (-5 * x + 3)\ - + (x >= 4/5) .* (10/3 * x - 8/3); - g = (x < 2/5) .* (5/2 * x) + (x >= 2/5 & x < 3/5)\ - + (x >= 3/5 & x < 4/5) .* (-5 * x + 4); - b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) + (x >= 4/5); + + r = (x < 2/5) \ + + (x >= 2/5 & x < 3/5) .* (-5 * x + 3) \ + + (x >= 4/5) .* (10/3 * x - 8/3); + + g = (x < 2/5) .* (5/2 * x) \ + + (x >= 2/5 & x < 3/5) \ + + (x >= 3/5 & x < 4/5) .* (-5 * x + 4); + + b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) \ + + (x >= 4/5); + map = [r, g, b]; else map = [];
--- a/scripts/image/rgb2hsv.m +++ b/scripts/image/rgb2hsv.m @@ -17,16 +17,18 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb}) -## Transform a colormap or image from the RGB space to the HSV space. -## -## A color in the RGB space consists of the red, green and blue intensities. +## @deftypefn {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb}) +## @deftypefnx {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb}) +## Transform a colormap or image from red-green-blue (RGB) space to +## hue-saturation-value (HSV) space. ## -## In the HSV space each color is represented by their hue, saturation -## and value (brightness). Value gives the amount of light in the color. -## Hue describes the dominant wavelength. -## Saturation is the amount of hue mixed into the color. -## @seealso{hsv2rgb} +## A color in the RGB space consists of red, green, and blue intensities. +## +## A color in HSV space is represented by hue, saturation and value +## (brightness) levels. Value gives the amount of light in the color. Hue +## describes the dominant wavelength. Saturation is the amount of hue mixed +## into the color. +## @seealso{hsv2rgb, rgb2ind, rgb2ntsc} ## @end deftypefn ## Author: Kai Habel <kai.habel@gmx.de>
--- a/scripts/image/rgb2ind.m +++ b/scripts/image/rgb2ind.m @@ -19,8 +19,8 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{rgb}) ## @deftypefnx {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{R}, @var{G}, @var{B}) -## Convert an RGB image to an Octave indexed image. -## @seealso{ind2rgb, rgb2ntsc} +## Convert an image in red-green-blue (RGB) space to an indexed image. +## @seealso{ind2rgb, rgb2hsv, rgb2ntsc} ## @end deftypefn ## Bugs: The color map may have duplicate entries.
--- a/scripts/image/rgb2ntsc.m +++ b/scripts/image/rgb2ntsc.m @@ -17,9 +17,11 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} rgb2ntsc (@var{rgb}) -## Transform a colormap or image from RGB to NTSC. -## @seealso{ntsc2rgb} +## @deftypefn {Function File} {@var{yiq_map} =} rgb2ntsc (@var{rgb_map}) +## @deftypefnx {Function File} {@var{yiq_img} =} rgb2ntsc (@var{rgb_img}) +## Transform a colormap or image from red-green-blue (RGB) space to +## luminance-chrominance (NTSC) space. +## @seealso{ntsc2rgb, rgb2hsv, rgb2ind} ## @end deftypefn ## Author: Tony Richardson <arichard@stark.cc.oh.us>
new file mode 100644 --- /dev/null +++ b/scripts/image/rgbplot.m @@ -0,0 +1,60 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} rgbplot (@var{cmap}) +## Plot the components of a colormap. +## +## The first column is plotted in red, the second column in green, and +## the third column in blue. The values are between 0 and 1 and represent +## the intensity of the RGB components in the given indexed color. +## @seealso{colormap} +## @end deftypefn + +function rgbplot (cmap) + + if (nargin != 1) + print_usage (); + endif + + if (! ismatrix (cmap) || ndims (cmap) != 2 || columns (cmap) != 3) + error ("rgbplot: CMAP must be a matrix of size Nx3"); + elseif (any (cmap(:) < 0) || any (cmap(:) > 1)) + error ("rgbplot: CMAP intensities must be in the range [0, 1]"); + endif + + plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); + set (gca, 'ytick', 0:0.1:1); + xlabel ("color index"); + +endfunction + + +%!demo +%! clf; +%! rgbplot (ocean); + +%%test input validation +%!error rgbplot () +%!error rgbplot (1,2) +%!error <CMAP must be a matrix of size Nx3> rgbplot ({0 1 0}) +%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,3,3)) +%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,4)) +%!error <CMAP intensities must be in the range> rgbplot ([0 0 -2]) +%!error <CMAP intensities must be in the range> rgbplot ([0 0 2]) +
rename from scripts/plot/spinmap.m rename to scripts/image/spinmap.m --- a/scripts/plot/spinmap.m +++ b/scripts/image/spinmap.m @@ -17,41 +17,56 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} spinmap (@var{t}, @var{inc}) -## Cycle the colormap for @var{t} seconds with an increment -## of @var{inc}. Both parameters are optional. The default cycle time -## is 5 seconds and the default increment is 2. +## @deftypefn {Function File} {} spinmap () +## @deftypefnx {Function File} {} spinmap (@var{t}) +## @deftypefnx {Function File} {} spinmap (@var{t}, @var{inc}) +## @deftypefnx {Function File} {} spinmap ("inf") +## Cycle the colormap for @var{t} seconds with a color increment of @var{inc}. +## Both parameters are optional. The default cycle time is 5 seconds and the +## default increment is 2. If the option "inf" is given then cycle +## continuously until @kbd{Control-C} is pressed. ## -## A higher value of @var{inc} causes a faster cycle through the -## colormap. -## @seealso{gca, colorbar} +## When rotating the original color 1 becomes color 2, color 2 becomes +## color 3, etc. A positive or negative increment is allowed and a higher +## value of @var{inc} will cause faster cycling through the colormap. +## @seealso{colormap} ## @end deftypefn ## Author: Kai Habel <kai.habel at gmx.de> -function spinmap (t, inc) +function spinmap (t = 5, inc = 2) - if (nargin == 0) - inc = 2; - t = 5; - elseif (nargin == 1) - inc = 2; + if (nargin > 2) + print_usage (); + elseif (ischar (t)) + if (strcmpi (t, "inf")) + t = Inf; + else + error ('spinmap: time T must be a real scalar or "inf"'); + endif + elseif (! isscalar (t) || ! isreal (t)) + error ("spinmap: time T must be a real scalar"); endif - cmap = get (gcf (), "colormap"); - clen = rows (cmap); + cmap = cmap_orig = get (gcf (), "colormap"); t0 = clock; - while (etime (clock, t0) < t) - for n = 1:inc:clen - newmap = shift (cmap, n, 1); - set (gcf (), "colormap", newmap); - drawnow (); - endfor + cmap = shift (cmap, inc, 1); + set (gcf (), "colormap", cmap); + drawnow (); endwhile - set (gcf (), "colormap", cmap); + set (gcf (), "colormap", cmap_orig); endfunction + +%!demo +%! clf; +%! colormap (rainbow (128)); +%! imagesc (1:8); +%! axis off; +%! title ("Rotate color bars to the right"); +%! spinmap (3, 1); +
--- a/scripts/image/spring.m +++ b/scripts/image/spring.m @@ -43,7 +43,7 @@ map = [1, 0, 1]; elseif (n > 1) r = ones (n, 1); - g = (0:n - 1)' ./ (n - 1); + g = [0:(n-1)]' / (n - 1); b = 1 - g; map = [r, g, b]; else
--- a/scripts/image/summer.m +++ b/scripts/image/summer.m @@ -27,6 +27,7 @@ ## Author: Kai Habel <kai.habel@gmx.de> ## Date: 06/03/2000 + function map = summer (n) if (nargin == 0) @@ -42,10 +43,9 @@ if (n == 1) map = [0, 0.5, 0.4]; elseif (n > 1) - r = (0:n - 1)' ./ (n - 1); - g = 0.5 + r ./ 2; + r = [0:(n-1)]' / (n - 1); + g = 0.5 + r / 2; b = 0.4 * ones (n, 1); - map = [r, g, b]; else map = [];
--- a/scripts/image/white.m +++ b/scripts/image/white.m @@ -39,11 +39,7 @@ print_usage (); endif - if (n > 0) - map = ones (n, 3); - else - map = []; - endif + map = ones (n, 3); endfunction
--- a/scripts/image/winter.m +++ b/scripts/image/winter.m @@ -43,9 +43,8 @@ map = [0, 0, 1]; elseif (n > 1) r = zeros (n, 1); - g = (0:n - 1)' ./ (n - 1); - b = 1 - g ./ 2; - + g = [0:(n-1)]' / (n - 1); + b = 1 - g / 2; map = [r, g, b]; else map = [];
--- a/scripts/io/dlmwrite.m +++ b/scripts/io/dlmwrite.m @@ -40,6 +40,7 @@ ## ## In addition, the following keyword value pairs may appear at the end ## of the argument list: +## ## @table @asis ## @item "append" ## Either @samp{"on"} or @samp{"off"}. See @samp{"-append"} above. @@ -49,9 +50,9 @@ ## ## @item "newline" ## The character(s) to use to separate each row. Three special cases -## exist for this option. @samp{"unix"} is changed into '\n', -## @samp{"pc"} is changed into '\r\n', and @samp{"mac"} is changed -## into '\r'. Other values for this option are kept as is. +## exist for this option. @samp{"unix"} is changed into "\n", +## @samp{"pc"} is changed into "\r\n", and @samp{"mac"} is changed +## into "\r". Other values for this option are kept as is. ## ## @item "roffset" ## See @var{r} above. @@ -196,13 +197,13 @@ %!test %! f = tmpnam (); -%! dlmwrite (f,[1,2;3,4],'precision','%5.2f','newline','unix','roffset',1,'coffset',1); +%! dlmwrite (f,[1,2;3,4],"precision","%5.2f","newline","unix","roffset",1,"coffset",1); %! fid = fopen (f,"rt"); -%! f1 = char (fread (fid,Inf,'char')'); +%! f1 = char (fread (fid,Inf,"char")'); %! fclose (fid); -%! dlmwrite (f,[5,6],'precision','%5.2f','newline','unix','coffset',1,'delimiter',',','-append'); +%! dlmwrite (f,[5,6],"precision","%5.2f","newline","unix","coffset",1,"delimiter",",","-append"); %! fid = fopen (f,"rt"); -%! f2 = char (fread (fid,Inf,'char')'); +%! f2 = char (fread (fid,Inf,"char")'); %! fclose (fid); %! unlink (f); %!
--- a/scripts/io/fileread.m +++ b/scripts/io/fileread.m @@ -50,7 +50,7 @@ %! cstr = {"Hello World", "The answer is 42", "Goodbye World"}; %! fname = tmpnam (); %! fid = fopen (fname, "w"); -%! fprintf (fid, "%s\n", cstr{:}) +%! fprintf (fid, "%s\n", cstr{:}); %! fclose (fid); %! str = fileread (fname); %! assert (str', [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]);
--- a/scripts/io/is_valid_file_id.m +++ b/scripts/io/is_valid_file_id.m @@ -39,8 +39,10 @@ endfunction + %!assert (is_valid_file_id (stdout)) %!assert (! is_valid_file_id ([1,2;3,4])) %!assert (! is_valid_file_id ("not_a_file_id")) %!assert (! is_valid_file_id (-1)) %!assert (! is_valid_file_id (pi)) +
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -34,6 +34,7 @@ ## The string @var{format} describes how the words in @var{str} should be ## parsed. ## It may contain any combination of the following specifiers: +## ## @table @code ## @item %s ## The word is parsed as a string. @@ -84,6 +85,7 @@ ## ## Optional numeric argument @var{format_repeat} can be used for ## limiting the number of items read: +## ## @table @asis ## @item -1 ## (default) read all of the string until the end. @@ -91,7 +93,6 @@ ## @item N ## Read N times @var{nargout} items. 0 (zero) is an acceptable ## value for @var{format_repeat}. -## ## @end table ## ## The behavior of @code{strread} can be changed via property-value @@ -101,6 +102,7 @@ ## @item "commentstyle" ## Parts of @var{str} are considered comments and will be skipped. ## @var{value} is the comment style and can be any of the following. +## ## @itemize ## @item "shell" ## Everything from @code{#} characters to the nearest end-of-line is skipped. @@ -439,14 +441,13 @@ iwrd = 1; iwrdp = 0; iwrdl = length (words{iwrd}); for ii = 1:numel (fmt_words) + nxt_wrd = 0; + if (idf(ii)) ## Literal expected if (isempty (strfind (fmt_words{ii}, words(iwrd)))) ## Not found in current word; supposed to be in next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; else ## Found it in current word. Subtract literal length iwrdp += length (fmt_words{ii}); @@ -455,34 +456,28 @@ warning ("strread: literal '%s' (fmt spec # %d) does not match data", ... fmt_words{ii}, ii); ## Word assumed to be completely "used up". Next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; elseif (iwrdp == iwrdl) ## Word completely "used up". Next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; endif endif elseif (idg(ii)) ## Fixed width specifier (%N or %*N): read just a part of word - iwrdp += floor ... - (str2double (fmt_words{ii}(regexp(fmt_words{ii}, '\d') : end-1))); - if (iwrdp > iwrdl) - ## Match error. Field extends beyond word boundary. - warning ... - ("strread: field width '%s' (fmt spec # %d) extends beyond actual word limit", ... - fmt_words{ii}, ii); - ## Assume word to be completely "used up". Next word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); - elseif (iwrdp == iwrdl) - ## Word completely "used up". Next word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); - endif + iwrdp += floor ... + (str2double (fmt_words{ii}(regexp(fmt_words{ii}, '\d') : end-1))); + if (iwrdp > iwrdl) + ## Match error. Field extends beyond word boundary. + warning ... + ("strread: field width '%s' (fmt spec # %d) extends beyond actual word limit", ... + fmt_words{ii}, ii); + ## Assume word to be completely "used up". Next word + nxt_wrd = 1; + elseif (iwrdp == iwrdl) + ## Word completely "used up". Next word + nxt_wrd = 1; + endif else ## A simple format conv. specifier. Either (1) uses rest of word, or @@ -492,20 +487,25 @@ ## Next fmt_word is a literal... if (! index (words{iwrd}(iwrdp+1:end), fmt_words{ii+1})) ## ...but not found in current word => field uses rest of word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); + nxt_wrd = 1; else ## ..or it IS found. Add inferred width of current conversion field iwrdp += index (words{iwrd}(iwrdp+1:end), fmt_words{ii+1}) - 1; endif elseif (iwrdp < iwrdl) ## No bordering literal to the right => field occupies (rest of) word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; endif endif + + if (nxt_wrd) + ++iwrd; iwrdp = 0; + if (ii < numel (fmt_words)) + iwrdl = length (words{iwrd}); + endif + endif + endfor ## Done words_period = max (iwrd - 1, 1); @@ -670,7 +670,7 @@ k++; case "s" if (pad_out) - data(end+1:num_lines) = {""} + data(end+1:num_lines) = {""}; endif varargout{k} = strtrunc (data, swidth)'; k++; @@ -738,29 +738,29 @@ %! assert (b, 2); %!test -%! str = ''; +%! str = ""; %! a = rand (10, 1); %! b = char (randi ([65, 85], 10, 1)); %! for k = 1:10 %! str = sprintf ('%s %.6f %s\n', str, a(k), b(k)); %! endfor -%! [aa, bb] = strread (str, '%f %s'); +%! [aa, bb] = strread (str, "%f %s"); %! assert (a, aa, 1e-6); %! assert (cellstr (b), bb); %!test -%! str = ''; +%! str = ""; %! a = rand (10, 1); %! b = char (randi ([65, 85], 10, 1)); %! for k = 1:10 %! str = sprintf ('%s %.6f %s\n', str, a(k), b(k)); %! endfor -%! aa = strread (str, '%f %*s'); +%! aa = strread (str, "%f %*s"); %! assert (a, aa, 1e-6); %!test %! str = sprintf ('/* this is\nacomment*/ 1 2 3'); -%! a = strread (str, '%f', 'commentstyle', 'c'); +%! a = strread (str, "%f", "commentstyle", "c"); %! assert (a, [1; 2; 3]); %!test @@ -784,9 +784,9 @@ %!test %! # Bug #33536 %! [a, b, c] = strread ("1,,2", "%s%s%s", "delimiter", ","); -%! assert (a{1}, '1'); -%! assert (b{1}, ''); -%! assert (c{1}, '2'); +%! assert (a{1}, "1"); +%! assert (b{1}, ""); +%! assert (c{1}, "2"); %!test %! # Bug #33536 @@ -795,17 +795,17 @@ %!test %! dat = "Data file.\r\n= = = = =\r\nCOMPANY : <Company name>\r\n"; -%! a = strread (dat, "%s", 'delimiter', "\n", 'whitespace', '', 'endofline', "\r\n"); +%! a = strread (dat, "%s", "delimiter", "\n", "whitespace", "", "endofline", "\r\n"); %! assert (a{2}, "= = = = ="); %! assert (double (a{3}(end-5:end)), [32 110 97 109 101 62]); %!test -%! [a, b, c, d] = strread ("1,2,3,,5,6", "%d%f%d%f", 'delimiter', ','); +%! [a, b, c, d] = strread ("1,2,3,,5,6", "%d%f%d%f", "delimiter", ","); %! assert (c, int32 (3)); %! assert (d, NaN); %!test -%! [a, b, c, d] = strread ("1,2,3,,5,6\n", "%d%d%f%d", 'delimiter', ','); +%! [a, b, c, d] = strread ("1,2,3,,5,6\n", "%d%d%f%d", "delimiter", ","); %! assert (c, [3; NaN]); %! assert (d, int32 ([0; 0])); @@ -817,12 +817,12 @@ %1 assert (c, 0.3567); %!test -%! [a, b] = strread('0.41 8.24 3.57 6.24 9.27', "%f%f", 2, 'delimiter', ' '); +%! [a, b] = strread ("0.41 8.24 3.57 6.24 9.27", "%f%f", 2, "delimiter", " "); %1 assert (a, [0.41; 3.57]); %!test %! # TreatAsEmpty -%! [a, b, c, d] = strread ("1,2,3,NN,5,6\n", "%d%d%d%f", 'delimiter', ',', 'TreatAsEmpty', 'NN'); +%! [a, b, c, d] = strread ("1,2,3,NN,5,6\n", "%d%d%d%f", "delimiter", ",", "TreatAsEmpty", "NN"); %! assert (c, int32 ([3; 0])); %! assert (d, [NaN; NaN]); @@ -831,13 +831,13 @@ %! str = "Text1Text2Text\nText398Text4Text\nText57Text"; %! [a, b] = strread (str, "Text%dText%1sText"); %! assert (a, int32 ([1; 398; 57])); -%! assert (b(1:2), {'2'; '4'}); +%! assert (b(1:2), {"2"; "4"}); %! assert (isempty (b{3}), true); %% MultipleDelimsAsOne %!test %! str = "11, 12, 13,, 15\n21,, 23, 24, 25\n,, 33, 34, 35"; -%! [a b c d] = strread (str, "%f %f %f %f", 'delimiter', ',', 'multipledelimsasone', 1, 'endofline', "\n"); +%! [a b c d] = strread (str, "%f %f %f %f", "delimiter", ",", "multipledelimsasone", 1, "endofline", "\n"); %! assert (a', [11, 21, NaN]); %! assert (b', [12, 23, 33]); %! assert (c', [13, 24, 34]); @@ -888,3 +888,4 @@ %! assert (a, [0.31; 0.60], 0.01) %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) +
--- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -131,11 +131,11 @@ %!test -%! f = tmpnam(); +%! f = tmpnam (); %! d = rand (5, 3); -%! dlmwrite (f, d, 'precision', '%5.2f'); +%! dlmwrite (f, d, "precision", "%5.2f"); %! [a, b, c] = textread (f, "%f %f %f", "delimiter", ",", "headerlines", 3); -%! unlink(f); +%! unlink (f); %! assert (a, d(4:5, 1), 1e-2); %! assert (b, d(4:5, 2), 1e-2); %! assert (c, d(4:5, 3), 1e-2); @@ -143,6 +143,6 @@ %% Test input validation %!error textread () %!error textread (1) -%!error <arguments must be strings> textread (1, '%f') +%!error <arguments must be strings> textread (1, "%f") %!error <arguments must be strings> textread ("fname", 1)
--- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -255,6 +255,7 @@ endfunction + %!test %! str = "1, 2, 3, 4\n 5, , , 8\n 9, 10, 11, 12"; %! fmtstr = "%f %d %f %s"; @@ -275,7 +276,7 @@ #%!test #%! str = "13, 72, NA, str1, 25\r\n// Middle line\r\n36, na, 05, str3, 6"; -#%! a = textscan(str, '%d %n %f %s %n', 'delimiter', ',','treatAsEmpty', {'NA', 'na'},'commentStyle', '//'); +#%! a = textscan (str, "%d %n %f %s %n", "delimiter", ",","treatAsEmpty", {"NA", "na"},"commentStyle", "//"); #%! assert (a{1}, int32([13; 36])); #%! assert (a{2}, [72; NaN]); #%! assert (a{3}, [NaN; 5]); @@ -288,7 +289,7 @@ %! str = [str "Km:2 = hhhRjjj miles3hour\r\n"]; %! str = [str "Km:25 = hhhZ\r\n"]; %! fmt = "Km:%d = hhh%1sjjj miles%dhour"; -%! a = textscan (str, fmt, 'delimiter', ' '); +%! a = textscan (str, fmt, "delimiter", " "); %! assert (a{1}', int32([10 15 2 25])); %! assert (a{2}', {'B' 'J' 'R' 'Z'}); %! assert (a{3}', int32([16 241 3 0])); @@ -298,9 +299,9 @@ %! c = textscan ("L1\nL2", "%s"); %! assert (c{:}, {"L1"; "L2"}); -%% Test with endofline parameter set to '' (empty) - newline should be in word +%% Test with endofline parameter set to "" (empty) - newline should be in word %!test -%! c = textscan ("L1\nL2", "%s", 'endofline', ''); +%! c = textscan ("L1\nL2", "%s", "endofline", ""); %! assert (int8(c{:}{:}), int8([ 76, 49, 10, 76, 50 ])); %!test @@ -315,7 +316,7 @@ %! b = [b; 8*b/5; 8*b*1000/5]; %! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b); %! fmt = "%f miles%s %s %f (%f) kilometers %*s"; -%! c = textscan (str, fmt, 'collectoutput', 1); +%! c = textscan (str, fmt, "collectoutput", 1); %! assert (size(c{3}), [10, 2]); %! assert (size(c{2}), [10, 2]);
--- a/scripts/linear-algebra/commutation_matrix.m +++ b/scripts/linear-algebra/commutation_matrix.m @@ -96,24 +96,26 @@ endfunction + %!test -%! c = commutation_matrix(1,1); -%! assert(c,1); +%! c = commutation_matrix (1,1); +%! assert (c,1); %!test -%! A = rand(3,5); -%! vc = vec(A); -%! vr = vec(A'); -%! c = commutation_matrix(3,5); -%! assert(c*vc,vr); +%! A = rand (3,5); +%! vc = vec (A); +%! vr = vec (A'); +%! c = commutation_matrix (3,5); +%! assert (c*vc, vr); %!test -%! A = rand(4,6); -%! vc = vec(A); -%! vr = vec(A'); -%! c = commutation_matrix(4,6); -%! assert(c*vc,vr); +%! A = rand (4,6); +%! vc = vec (A); +%! vr = vec (A'); +%! c = commutation_matrix (4,6); +%! assert (c*vc, vr); -%!error commutation_matrix(0,0); -%!error commutation_matrix(1,0); -%!error commutation_matrix(0,1); +%!error <M must be a positive integer> commutation_matrix (0,0) +%!error <N must be a positive integer> commutation_matrix (1,0) +%!error <M must be a positive integer> commutation_matrix (0,1) +
--- a/scripts/linear-algebra/cond.m +++ b/scripts/linear-algebra/cond.m @@ -74,20 +74,19 @@ endfunction + %!test -%! y= [7, 2, 3; 1, 3, 4; 6, 4, 5]; +%! y = [7, 2, 3; 1, 3, 4; 6, 4, 5]; %! tol = 1e-6; -%! type = {1, 2, 'fro', 'inf', inf}; -%! for n = 1:numel(type) +%! type = {1, 2, "fro", "inf", inf}; +%! for n = 1:numel (type) %! rcondition(n) = 1 / cond (y, type{n}); %! endfor %! assert (rcondition, [0.017460, 0.019597, 0.018714, 0.012022, 0.012022], tol); -%!assert (abs (cond ([1, 2; 2, 1]) - 3) < sqrt (eps)); - -%!assert (cond ([1, 2, 3; 4, 5, 6; 7, 8, 9]) > 1.0e+16); +%!assert (cond ([1, 2; 2, 1]), 3, sqrt (eps)) +%!assert (cond ([1, 2, 3; 4, 5, 6; 7, 8, 9]) > 1.0e+16) -%!error cond (); +%!error cond () +%!error cond (1, 2, 3) -%!error cond (1, 2, 3); -
--- a/scripts/linear-algebra/condest.m +++ b/scripts/linear-algebra/condest.m @@ -236,4 +236,5 @@ %! A = hilb (N); %! [rcondA, v] = condest (A); %! x = A*v; -%! assert (norm(x, inf), 0, eps); +%! assert (norm (x, inf), 0, eps); +
--- a/scripts/linear-algebra/cross.m +++ b/scripts/linear-algebra/cross.m @@ -91,25 +91,26 @@ endfunction + %!test %! x = [1 0 0]; %! y = [0 1 0]; %! r = [0 0 1]; -%! assert(cross(x, y), r, 2e-8); +%! assert (cross (x, y), r, 2e-8); %!test %! x = [1 2 3]; %! y = [4 5 6]; %! r = [(2*6-3*5) (3*4-1*6) (1*5-2*4)]; -%! assert(cross(x, y), r, 2e-8); +%! assert (cross (x, y), r, 2e-8); %!test %! x = [1 0 0; 0 1 0; 0 0 1]; %! y = [0 1 0; 0 0 1; 1 0 0]; %! r = [0 0 1; 1 0 0; 0 1 0]; -%! assert(cross(x, y, 2), r, 2e-8); -%! assert(cross(x, y, 1), -r, 2e-8); +%! assert (cross (x, y, 2), r, 2e-8); +%! assert (cross (x, y, 1), -r, 2e-8); -%!error cross(0,0); -%!error cross(); +%!error cross (0,0) +%!error cross ()
--- a/scripts/linear-algebra/duplication_matrix.m +++ b/scripts/linear-algebra/duplication_matrix.m @@ -87,9 +87,10 @@ endfunction + %!test %! N = 2; -%! A = rand(N); +%! A = rand (N); %! B = A * A'; %! C = A + A'; %! D = duplication_matrix (N); @@ -98,7 +99,7 @@ %!test %! N = 3; -%! A = rand(N); +%! A = rand (N); %! B = A * A'; %! C = A + A'; %! D = duplication_matrix (N); @@ -107,14 +108,15 @@ %!test %! N = 4; -%! A = rand(N); +%! A = rand (N); %! B = A * A'; %! C = A + A'; %! D = duplication_matrix (N); %! assert (D * vech (B), vec (B), 1e-6); %! assert (D * vech (C), vec (C), 1e-6); -%!error duplication_matrix (); -%!error duplication_matrix (0.5); -%!error duplication_matrix (-1); -%!error duplication_matrix (ones(1,4)); +%!error duplication_matrix () +%!error duplication_matrix (0.5) +%!error duplication_matrix (-1) +%!error duplication_matrix (ones (1,4)) +
--- a/scripts/linear-algebra/expm.m +++ b/scripts/linear-algebra/expm.m @@ -28,7 +28,7 @@ ## @ifnottex ## ## @example -## expm(A) = I + A + A^2/2! + A^3/3! + @dots{} +## expm (A) = I + A + A^2/2! + A^3/3! + @dots{} ## @end example ## ## @end ifnottex @@ -141,14 +141,16 @@ endfunction -%!assert(norm(expm([1 -1;0 1]) - [e -e; 0 e]) < 1e-5); -%!assert(expm([1 -1 -1;0 1 -1; 0 0 1]), [e -e -e/2; 0 e -e; 0 0 e], 1e-5); -%% Test input validation -%!error expm (); -%!error expm (1, 2); -%!error <expm: A must be a square matrix> expm([1 0;0 1; 2 2]); +%!assert (norm (expm ([1 -1;0 1]) - [e -e; 0 e]) < 1e-5); +%!assert (expm ([1 -1 -1;0 1 -1; 0 0 1]), [e -e -e/2; 0 e -e; 0 0 e], 1e-5); %!assert (expm (10), expm (10)) %!assert (full (expm (eye (3))), expm (full (eye (3)))) %!assert (full (expm (10*eye (3))), expm (full (10*eye (3))), 8*eps) + +%% Test input validation +%!error expm () +%!error expm (1, 2) +%!error <expm: A must be a square matrix> expm ([1 0;0 1; 2 2]) +
--- a/scripts/linear-algebra/housh.m +++ b/scripts/linear-algebra/housh.m @@ -92,42 +92,43 @@ endfunction + %!test %! x = [1 2 3]'; %! j = 3; -%! [hv, b, z] = housh(x, j, 0); -%! r = (eye(3) - b*hv*hv') * x; -%! d = - norm(x) * [0 0 1]'; -%! assert(r, d, 2e-8); -%! assert(z, 0, 2e-8); +%! [hv, b, z] = housh (x, j, 0); +%! r = (eye (3) - b*hv*hv') * x; +%! d = - norm (x) * [0 0 1]'; +%! assert (r, d, 2e-8); +%! assert (z, 0, 2e-8); %!test %! x = [7 -3 1]'; %! j = 2; -%! [hv, b, z] = housh(x, j, 0); -%! r = (eye(3) - b*hv*hv') * x; -%! d = norm(x) * [0 1 0]'; -%! assert(r, d, 2e-8); -%! assert(z, 0, 2e-8); +%! [hv, b, z] = housh (x, j, 0); +%! r = (eye (3) - b*hv*hv') * x; +%! d = norm (x) * [0 1 0]'; +%! assert (r, d, 2e-8); +%! assert (z, 0, 2e-8); %!test %! x = [1 0 0]'; %! j = 1; -%! [hv, b, z] = housh(x, j, 10); -%! r = (eye(3) - b*hv*hv') * x; -%! d = norm(x) * [1 0 0]'; -%! assert(r, d, 2e-8); -%! assert(z, 1, 2e-8); +%! [hv, b, z] = housh (x, j, 10); +%! r = (eye (3) - b*hv*hv') * x; +%! d = norm (x) * [1 0 0]'; +%! assert (r, d, 2e-8); +%! assert (z, 1, 2e-8); %!test %! x = [5 0 4 1]'; %! j = 2; -%! [hv, b, z] = housh(x, j, 0); -%! r = (eye(4) - b*hv*hv') * x; -%! d = - norm(x) * [0 1 0 0]'; -%! assert(r, d, 2e-8); -%! assert(z, 0, 2e-8); +%! [hv, b, z] = housh (x, j, 0); +%! r = (eye (4) - b*hv*hv') * x; +%! d = - norm (x) * [0 1 0 0]'; +%! assert (r, d, 2e-8); +%! assert (z, 0, 2e-8); -%!error housh([0]); -%!error housh(); +%!error housh ([0]) +%!error housh ()
--- a/scripts/linear-algebra/isdefinite.m +++ b/scripts/linear-algebra/isdefinite.m @@ -67,19 +67,19 @@ %!test %! A = [-1 0; 0 -1]; -%! assert (isdefinite (A), -1) +%! assert (isdefinite (A), -1); %!test %! A = [1 0; 0 1]; -%! assert (isdefinite (A), 1) +%! assert (isdefinite (A), 1); %!test %! A = [2 -1 0; -1 2 -1; 0 -1 2]; -%! assert (isdefinite (A), 1) +%! assert (isdefinite (A), 1); %!test %! A = [1 0; 0 0]; -%! assert (isdefinite (A), 0) +%! assert (isdefinite (A), 0); %!error isdefinite () %!error isdefinite (1,2,3)
--- a/scripts/linear-algebra/ishermitian.m +++ b/scripts/linear-algebra/ishermitian.m @@ -50,18 +50,21 @@ endfunction -%!assert(ishermitian (1)); -%!assert(!(ishermitian ([1, 2]))); -%!assert(ishermitian ([])); -%!assert(ishermitian ([1, 2; 2, 1])); -%!assert(!(ishermitian ("test"))); -%!assert(ishermitian ([1, 2.1; 2, 1.1], 0.2)); -%!assert(ishermitian ([1, -2i; 2i, 1])); -%!assert(!(ishermitian ("t"))); -%!assert(!(ishermitian (["te"; "et"]))); -%!error ishermitian ([1, 2; 2, 1], 0, 0); -%!error ishermitian (); + +%!assert (ishermitian (1)) +%!assert (! ishermitian ([1, 2])) +%!assert (ishermitian ([])) +%!assert (ishermitian ([1, 2; 2, 1])) +%!assert (! ishermitian ("test")) +%!assert (ishermitian ([1, 2.1; 2, 1.1], 0.2)) +%!assert (ishermitian ([1, -2i; 2i, 1])) +%!assert (! ishermitian ("t")) +%!assert (! ishermitian (["te"; "et"])) %!test %! s.a = 1; -%! assert(!(ishermitian (s))); +%! assert(! ishermitian (s)); + +%!error ishermitian ([1, 2; 2, 1], 0, 0) +%!error ishermitian () +
--- a/scripts/linear-algebra/issymmetric.m +++ b/scripts/linear-algebra/issymmetric.m @@ -49,18 +49,21 @@ endfunction -%!assert(issymmetric (1)); -%!assert(!(issymmetric ([1, 2]))); -%!assert(issymmetric ([])); -%!assert(issymmetric ([1, 2; 2, 1])); -%!assert(!(issymmetric ("test"))); -%!assert(issymmetric ([1, 2.1; 2, 1.1], 0.2)); -%!assert(issymmetric ([1, 2i; 2i, 1])); -%!assert(!(issymmetric ("t"))); -%!assert(!(issymmetric (["te"; "et"]))); -%!error issymmetric ([1, 2; 2, 1], 0, 0); -%!error issymmetric (); + +%!assert (issymmetric (1)) +%!assert (! issymmetric ([1, 2])) +%!assert (issymmetric ([])) +%!assert (issymmetric ([1, 2; 2, 1])) +%!assert (! (issymmetric ("test"))) +%!assert (issymmetric ([1, 2.1; 2, 1.1], 0.2)) +%!assert (issymmetric ([1, 2i; 2i, 1])) +%!assert (! (issymmetric ("t"))) +%!assert (! (issymmetric (["te"; "et"]))) %!test %! s.a = 1; -%! assert(!(issymmetric (s))); +%! assert(! issymmetric (s)); + +%!error issymmetric ([1, 2; 2, 1], 0, 0) +%!error issymmetric () +
--- a/scripts/linear-algebra/logm.m +++ b/scripts/linear-algebra/logm.m @@ -26,7 +26,7 @@ ## implementation utilizes a Pad@'e approximant and the identity ## ## @example -## logm(@var{A}) = 2^k * logm(@var{A}^(1 / 2^k)) +## logm (@var{A}) = 2^k * logm (@var{A}^(1 / 2^k)) ## @end example ## ## The optional argument @var{opt_iters} is the maximum number of square roots @@ -156,15 +156,15 @@ endfunction -%!assert(norm(logm([1 -1;0 1]) - [0 -1; 0 0]) < 1e-5); -%!assert(norm(expm(logm([-1 2 ; 4 -1])) - [-1 2 ; 4 -1]) < 1e-5); -%!assert(logm([1 -1 -1;0 1 -1; 0 0 1]), [0 -1 -1.5; 0 0 -1; 0 0 0], 1e-5); - -%% Test input validation -%!error logm (); -%!error logm (1, 2, 3); -%!error <logm: A must be a square matrix> logm([1 0;0 1; 2 2]); - +%!assert (norm (logm ([1 -1;0 1]) - [0 -1; 0 0]) < 1e-5) +%!assert (norm (expm (logm ([-1 2 ; 4 -1])) - [-1 2 ; 4 -1]) < 1e-5) +%!assert (logm ([1 -1 -1;0 1 -1; 0 0 1]), [0 -1 -1.5; 0 0 -1; 0 0 0], 1e-5) %!assert (logm (10), log (10)) %!assert (full (logm (eye (3))), logm (full (eye (3)))) %!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps) + +%% Test input validation +%!error logm () +%!error logm (1, 2, 3) +%!error <logm: A must be a square matrix> logm ([1 0;0 1; 2 2]) +
--- a/scripts/linear-algebra/normest.m +++ b/scripts/linear-algebra/normest.m @@ -75,13 +75,14 @@ rand ("state", v); # restore state of random number generator endfunction + %!test %! A = toeplitz ([-2,1,0,0]); -%! assert (normest(A), norm(A), 1e-6); +%! assert (normest (A), norm (A), 1e-6); %!test %! A = rand (10); -%! assert (normest(A), norm(A), 1e-6); +%! assert (normest (A), norm (A), 1e-6); %% Test input validation %!error normest ()
--- a/scripts/linear-algebra/null.m +++ b/scripts/linear-algebra/null.m @@ -78,34 +78,38 @@ endfunction + +%% FIXME: Need some tests for 'single' variables as well + %!test %! A = 0; -%! assert(null(A), 1); +%! assert (null (A), 1); %!test %! A = 1; -%! assert(null(A), zeros(1,0)) +%! assert (null (A), zeros (1,0)); %!test %! A = [1 0; 0 1]; -%! assert(null(A), zeros(2,0)); +%! assert (null (A), zeros (2,0)); %!test %! A = [1 0; 1 0]; -%! assert(null(A), [0 1]') +%! assert (null (A), [0 1]'); %!test %! A = [1 1; 0 0]; -%! assert(null(A), [-1/sqrt(2) 1/sqrt(2)]', eps) +%! assert (null (A), [-1/sqrt(2) 1/sqrt(2)]', eps); %!test %! tol = 1e-4; %! A = [1 0; 0 tol-eps]; -%! assert(null(A,tol), [0 1]') +%! assert (null (A,tol), [0; 1]); %!test %! tol = 1e-4; %! A = [1 0; 0 tol+eps]; -%! assert(null(A,tol), zeros(2,0)); +%! assert (null (A,tol), zeros (2,0)); -%!error null() +%!error null () +
--- a/scripts/linear-algebra/onenormest.m +++ b/scripts/linear-algebra/onenormest.m @@ -253,8 +253,8 @@ %! [nminf, vinf, winf] = onenormest (A', 6); %! assert (nm1, N, -2*eps); %! assert (nminf, N, -2*eps); -%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps) -%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps) +%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps); +%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps); %!test %! N = 10; @@ -263,8 +263,8 @@ %! [nminf, vinf, winf] = onenormest (@(x) A'*x, @(x) A*x, N, 3); %! assert (nm1, N, -2*eps); %! assert (nminf, N, -2*eps); -%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps) -%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps) +%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps); +%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps); %!test %! N = 5; @@ -273,8 +273,8 @@ %! [nminf, vinf, winf] = onenormest (A', 6); %! assert (nm1, norm (A, 1), -2*eps); %! assert (nminf, norm (A, inf), -2*eps); -%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps) -%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps) +%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps); +%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps); ## Only likely to be within a factor of 10. %!test @@ -287,5 +287,6 @@ %! [nminf, vinf, winf] = onenormest (A', 6); %! assert (nm1, norm (A, 1), -.1); %! assert (nminf, norm (A, inf), -.1); -%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps) -%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps) +%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps); +%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps); +
--- a/scripts/linear-algebra/orth.m +++ b/scripts/linear-algebra/orth.m @@ -80,11 +80,13 @@ endfunction + %!test -%! for ii=1:20 +%! for i = 1:20 %! A = rand (10, 10); %! V = orth (A); %! if (det (A) != 0) -%! assert (V'*V, eye (10), 100*eps) +%! assert (V'*V, eye (10), 100*eps); %! endif %! endfor +
--- a/scripts/linear-algebra/planerot.m +++ b/scripts/linear-algebra/planerot.m @@ -35,13 +35,14 @@ y = G * x(:); endfunction + %!test %! x = [3 4]; -%! [g y] = planerot(x); -%! assert(g - [x(1) x(2); -x(2) x(1)] / sqrt(x(1)^2 + x(2)^2), zeros(2), 2e-8); -%! assert(y(2), 0, 2e-8); +%! [g y] = planerot (x); +%! assert (g, [x(1) x(2); -x(2) x(1)] / sqrt (x(1)^2 + x(2)^2), 2e-8); +%! assert (y(2), 0, 2e-8); -%!error planerot([0]); -%!error planerot([0 0 0]); -%!error planerot(); +%!error planerot ([0]) +%!error planerot ([0 0 0]) +%!error planerot ()
--- a/scripts/linear-algebra/qzhess.m +++ b/scripts/linear-algebra/qzhess.m @@ -37,8 +37,8 @@ ## The Hessenberg-triangular decomposition is the first step in ## Moler and Stewart's QZ@tie{}decomposition algorithm. ## -## Algorithm taken from Golub and Van Loan, @cite{Matrix Computations, 2nd -## edition}. +## Algorithm taken from Golub and Van Loan, +## @cite{Matrix Computations, 2nd edition}. ## @end deftypefn ## Author: A. S. Hodel <scotte@eng.auburn.edu> @@ -91,6 +91,7 @@ endfunction + %!test %! a = [1 2 1 3; %! 2 5 3 2; @@ -104,13 +105,13 @@ %! 0 0 0 0; %! 1 0 0 0; %! 1 1 0 0]; -%! [aa, bb, q, z] = qzhess(a, b); -%! assert(inv(q) - q', zeros(4), 2e-8); -%! assert(inv(z) - z', zeros(4), 2e-8); -%! assert(q * a * z, aa, 2e-8); -%! assert(aa .* mask, zeros(4), 2e-8); -%! assert(q * b * z, bb, 2e-8); -%! assert(bb .* mask, zeros(4), 2e-8); +%! [aa, bb, q, z] = qzhess (a, b); +%! assert (inv (q) - q', zeros (4), 2e-8); +%! assert (inv (z) - z', zeros (4), 2e-8); +%! assert (q * a * z, aa, 2e-8); +%! assert (aa .* mask, zeros (4), 2e-8); +%! assert (q * b * z, bb, 2e-8); +%! assert (bb .* mask, zeros (4), 2e-8); %!test %! a = [1 2 3 4 5; @@ -128,14 +129,14 @@ %! 1 0 0 0 0; %! 1 1 0 0 0; %! 1 1 1 0 0]; -%! [aa, bb, q, z] = qzhess(a, b); -%! assert(inv(q) - q', zeros(5), 2e-8); -%! assert(inv(z) - z', zeros(5), 2e-8); -%! assert(q * a * z, aa, 2e-8); -%! assert(aa .* mask, zeros(5), 2e-8); -%! assert(q * b * z, bb, 2e-8); -%! assert(bb .* mask, zeros(5), 2e-8); +%! [aa, bb, q, z] = qzhess (a, b); +%! assert (inv (q) - q', zeros (5), 2e-8); +%! assert (inv (z) - z', zeros (5), 2e-8); +%! assert (q * a * z, aa, 2e-8); +%! assert (aa .* mask, zeros (5), 2e-8); +%! assert (q * b * z, bb, 2e-8); +%! assert (bb .* mask, zeros (5), 2e-8); -%!error qzhess([0]); -%!error qzhess(); +%!error qzhess ([0]) +%!error qzhess ()
--- a/scripts/linear-algebra/rank.m +++ b/scripts/linear-algebra/rank.m @@ -59,6 +59,7 @@ endfunction + %!test %! A = [1 2 3 4 5 6 7; %! 4 5 6 7 8 9 12; @@ -67,7 +68,7 @@ %! 3 4 5 6 7 8 9; %! 4 5 6 7 8 9 10; %! 5 6 7 8 9 10 11]; -%! assert(rank(A),4); +%! assert (rank (A), 4); %!test %! A = [1 2 3 4 5 6 7; @@ -77,7 +78,7 @@ %! 3 4 5 6 7 8 9; %! 4 5 6 7 8 9 10; %! 5 6 7 8 9 10 11]; -%! assert(rank(A),4); +%! assert (rank (A), 4); %!test %! A = [1 2 3 4 5 6 7; @@ -87,7 +88,7 @@ %! 3 4 5 6 7 8 9; %! 4 5 6 7 8 9 10; %! 5 6 7 8 9 10 11]; -%! assert(rank(A),3); +%! assert (rank (A), 3); %!test %! A = [1 2 3 4 5 6 7; @@ -97,15 +98,16 @@ %! 3 4 5 6 7 8 9; %! 4 5 6 7 8 9 10; %! 5 6 7 8 9 10 11]; -%! assert(rank(A),3); +%! assert (rank (A), 3); %!test -%! A = eye(100); -%! assert(rank(A),100); +%! A = eye (100); +%! assert (rank (A), 100); %!test %! A = [1, 2, 3; 1, 2.001, 3; 1, 2, 3.0000001]; -%! assert(rank(A),3) -%! assert(rank(A,0.0009),1) -%! assert(rank(A,0.0006),2) -%! assert(rank(A,0.00000002),3) \ No newline at end of file +%! assert (rank (A), 3); +%! assert (rank (A,0.0009), 1); +%! assert (rank (A,0.0006), 2); +%! assert (rank (A,0.00000002), 3); +
--- a/scripts/linear-algebra/rref.m +++ b/scripts/linear-algebra/rref.m @@ -87,42 +87,42 @@ endfunction + %!test %! a = [1]; -%! [r k] = rref(a); -%! assert(r, [1], 2e-8); -%! assert(k, [1], 2e-8); +%! [r k] = rref (a); +%! assert (r, [1], 2e-8); +%! assert (k, [1], 2e-8); %!test %! a = [1 3; 4 5]; -%! [r k] = rref(a); -%! assert(rank(a), rank(r), 2e-8); -%! assert(r, eye(2), 2e-8); -%! assert(k == [1, 2] || k == [2, 1]); - +%! [r k] = rref (a); +%! assert (rank (a), rank (r), 2e-8); +%! assert (r, eye (2), 2e-8); +%! assert (k == [1, 2] || k == [2, 1]); %!test %! a = [1 3; 4 5; 7 9]; -%! [r k] = rref(a); -%! assert(rank(a), rank(r), 2e-8); -%! assert(r, eye(3)(:,1:2), 2e-8); -%! assert(k, [1 2], 2e-8); +%! [r k] = rref (a); +%! assert (rank (a), rank (r), 2e-8); +%! assert (r, eye(3)(:,1:2), 2e-8); +%! assert (k, [1 2], 2e-8); %!test %! a = [1 2 3; 2 4 6; 7 2 0]; -%! [r k] = rref(a); -%! assert(rank(a), rank(r), 2e-8); -%! assert(r, [1 0 (3-7/2); 0 1 (7/4); 0 0 0], 2e-8); -%! assert(k, [1 2], 2e-8); +%! [r k] = rref (a); +%! assert (rank (a), rank (r), 2e-8); +%! assert (r, [1 0 (3-7/2); 0 1 (7/4); 0 0 0], 2e-8); +%! assert (k, [1 2], 2e-8); %!test %! a = [1 2 1; 2 4 2.01; 2 4 2.1]; %! tol = 0.02; -%! [r k] = rref(a, tol); -%! assert(rank(a, tol), rank(r, tol), 2e-8); +%! [r k] = rref (a, tol); +%! assert (rank (a, tol), rank (r, tol), 2e-8); %! tol = 0.2; -%! [r k] = rref(a, tol); -%! assert(rank(a, tol), rank(r, tol), 2e-8); +%! [r k] = rref (a, tol); +%! assert (rank (a, tol), rank (r, tol), 2e-8); -%!error rref(); +%!error rref ();
--- a/scripts/linear-algebra/trace.m +++ b/scripts/linear-algebra/trace.m @@ -41,12 +41,14 @@ endfunction -%!assert(trace ([1, 2; 3, 4]) == 5); -%!assert(trace ([1, 2; 3, 4; 5, 6]) == 5); -%!assert(trace ([1, 3, 5; 2, 4, 6]) == 5); -%!assert(trace ([]), 0); -%!assert(trace (randn(1,0)), 0); -%! -%!error trace (); -%!error trace (1, 2); -%!error <only valid on 2-D objects> trace(reshape(1:9,[1,3,3])); + +%!assert (trace ([1, 2; 3, 4]), 5) +%!assert (trace ([1, 2; 3, 4; 5, 6]), 5) +%!assert (trace ([1, 3, 5; 2, 4, 6]), 5) +%!assert (trace ([]), 0) +%!assert (trace (randn (1,0)), 0) + +%!error trace () +%!error trace (1, 2) +%!error <only valid on 2-D objects> trace (reshape (1:9,[1,3,3])) +
--- a/scripts/linear-algebra/vech.m +++ b/scripts/linear-algebra/vech.m @@ -50,9 +50,9 @@ endfunction -%!assert(all (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]) == [1; 4; 7; 5; 8; 9])); + +%!assert (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]), [1; 4; 7; 5; 8; 9]) -%!error vech (); +%!error vech () +%!error vech (1, 2) -%!error vech (1, 2); -
--- a/scripts/miscellaneous/ans.m +++ b/scripts/miscellaneous/ans.m @@ -29,6 +29,7 @@ ## is evaluated, the value returned by @code{ans} is 25. ## @end defvr + ## Mark file as being tested. No real test needed for a documentation .m file %!assert (1)
--- a/scripts/miscellaneous/bincoeff.m +++ b/scripts/miscellaneous/bincoeff.m @@ -42,7 +42,7 @@ ## @example ## @group ## bincoeff (5, 2) -## @result{} 10 +## @result{} 10 ## @end group ## @end example ## @@ -103,18 +103,18 @@ endfunction -%!assert(bincoeff (4, 2), 6) -%!assert(bincoeff (2, 4), 0) -%!assert(bincoeff (-4, 2), 10) -%!assert(bincoeff (5, 2), 10) -%!assert(bincoeff (50, 6), 15890700) -%!assert(bincoeff (0.4, 2), -.12, 8*eps) +%!assert (bincoeff (4, 2), 6) +%!assert (bincoeff (2, 4), 0) +%!assert (bincoeff (-4, 2), 10) +%!assert (bincoeff (5, 2), 10) +%!assert (bincoeff (50, 6), 15890700) +%!assert (bincoeff (0.4, 2), -.12, 8*eps) -%!assert(bincoeff ([4 NaN 4], [-1, 2, 2.5]), NaN (1, 3)) +%!assert (bincoeff ([4 NaN 4], [-1, 2, 2.5]), NaN (1, 3)) %% Test input validation -%!error bincoeff (); -%!error bincoeff (1, 2, 3); -%!error bincoeff (ones(3),ones(2)) -%!error bincoeff (ones(2),ones(3)) +%!error bincoeff () +%!error bincoeff (1, 2, 3) +%!error bincoeff (ones (3),ones (2)) +%!error bincoeff (ones (2),ones (3))
--- a/scripts/miscellaneous/bug_report.m +++ b/scripts/miscellaneous/bug_report.m @@ -44,5 +44,6 @@ endfunction + ## Mark file as being tested. No real test needed for this function. %!assert (1)
--- a/scripts/miscellaneous/bzip2.m +++ b/scripts/miscellaneous/bzip2.m @@ -21,7 +21,7 @@ ## @deftypefn {Function File} {@var{entries} =} bzip2 (@var{files}) ## @deftypefnx {Function File} {@var{entries} =} bzip2 (@var{files}, @var{outdir}) ## Compress the list of files specified in @var{files}. -## Each file is compressed separately and a new file with a '.bz2' extension +## Each file is compressed separately and a new file with a ".bz2" extension ## is created. The original files are not modified. Existing compressed files ## are silently overwritten. If @var{outdir} is defined the compressed ## files are placed in this directory. @@ -42,20 +42,22 @@ endfunction + %!xtest -%! # test for correct cleanup of temporary files -%! unwind_protect -%! filename = tmpnam; -%! dummy = 1; -%! save(filename, "dummy"); -%! n_tmpfiles_before = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4))); -%! entry = bzip2(filename); -%! n_tmpfiles_after = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4))); -%! if (n_tmpfiles_before != n_tmpfiles_after) -%! error("bzip2 has not cleaned up temporary files correctly!"); -%! endif -%! unwind_protect_cleanup -%! delete(filename); -%! [path, basename, extension] = fileparts(filename); -%! delete([basename, extension, ".bz2"]); -%! end_unwind_protect +%! # test for correct cleanup of temporary files +%! unwind_protect +%! filename = tmpnam; +%! dummy = 1; +%! save (filename, "dummy"); +%! n_tmpfiles_before = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4))); +%! entry = bzip2 (filename); +%! n_tmpfiles_after = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4))); +%! if (n_tmpfiles_before != n_tmpfiles_after) +%! error ("bzip2 has not cleaned up temporary files correctly!"); +%! endif +%! unwind_protect_cleanup +%! delete (filename); +%! [path, basename, extension] = fileparts (filename); +%! delete ([basename, extension, ".bz2"]); +%! end_unwind_protect +
--- a/scripts/miscellaneous/comma.m +++ b/scripts/miscellaneous/comma.m @@ -22,6 +22,7 @@ ## @seealso{semicolon} ## @end deftypefn + ## Mark file as being tested. No real test needed for a documentation .m file %!assert (1)
--- a/scripts/miscellaneous/compare_versions.m +++ b/scripts/miscellaneous/compare_versions.m @@ -200,54 +200,54 @@ endfunction + ## tests ## test both equality symbols ## test arbitrarily long equality -%!assert(compare_versions("1.1.0.0.0", "1.1", "=="), true) -%!assert(compare_versions("1", "1.1", "<"), true) -%!assert(compare_versions("1.1", "1.1", "<="), true) -%!assert(compare_versions("1.1", "1.1.1", "<="), true) -%!assert(compare_versions("1.23", "1.24", "=<"), true) +%!assert (compare_versions ("1.1.0.0.0", "1.1", "=="), true) +%!assert (compare_versions ("1", "1.1", "<"), true) +%!assert (compare_versions ("1.1", "1.1", "<="), true) +%!assert (compare_versions ("1.1", "1.1.1", "<="), true) +%!assert (compare_versions ("1.23", "1.24", "=<"), true) ## test different length numbers -%!assert(compare_versions("23.2000", "23.1", ">"), true) -%!assert(compare_versions("0.0.2", "0.0.1", ">="), true) -%!assert(compare_versions("0.2", "0.0.100", "=>"), true) -%!assert(compare_versions("0.1", "0.2", "!="), true) -%!assert(compare_versions("0.1", "0.2", "~="), true) +%!assert (compare_versions ("23.2000", "23.1", ">"), true) +%!assert (compare_versions ("0.0.2", "0.0.1", ">="), true) +%!assert (compare_versions ("0.2", "0.0.100", "=>"), true) +%!assert (compare_versions ("0.1", "0.2", "!="), true) +%!assert (compare_versions ("0.1", "0.2", "~="), true) ## test alphanumeric strings -%!assert(compare_versions("1a", "1b", "<"), true) -%!assert(compare_versions("a", "1", "<"), true) -%!assert(compare_versions("1a", "1b", ">"), false) -%!assert(compare_versions("a", "1", ">"), false) -%!assert(compare_versions("1.1.0a", "1.1.0b", "=="), false) -%!assert(compare_versions("1.1.0a", "1.1.0b", "!="), true) -%!assert(compare_versions("1.1.0test", "1.1.0b", "=="), false) -%!assert(compare_versions("1.1.0test", "1.1.0test", "=="), true) +%!assert (compare_versions ("1a", "1b", "<"), true) +%!assert (compare_versions ("a", "1", "<"), true) +%!assert (compare_versions ("1a", "1b", ">"), false) +%!assert (compare_versions ("a", "1", ">"), false) +%!assert (compare_versions ("1.1.0a", "1.1.0b", "=="), false) +%!assert (compare_versions ("1.1.0a", "1.1.0b", "!="), true) +%!assert (compare_versions ("1.1.0test", "1.1.0b", "=="), false) +%!assert (compare_versions ("1.1.0test", "1.1.0test", "=="), true) ## make sure that it won't just give true output -%!assert(compare_versions("1", "0", "=="), false) +%!assert (compare_versions ("1", "0", "=="), false) ## test arbitrarily long equality -%!assert(compare_versions("1.1.1.0.0", "1.1", "=="), false) -%!assert(compare_versions("1.1", "1", "<"), false) -%!assert(compare_versions("2", "1.1", "<="), false) -%!assert(compare_versions("1.1.1", "1.1", "<="), false) -%!assert(compare_versions("1.25", "1.24", "=<"), false) +%!assert (compare_versions ("1.1.1.0.0", "1.1", "=="), false) +%!assert (compare_versions ("1.1", "1", "<"), false) +%!assert (compare_versions ("2", "1.1", "<="), false) +%!assert (compare_versions ("1.1.1", "1.1", "<="), false) +%!assert (compare_versions ("1.25", "1.24", "=<"), false) ## test different length numbers -%!assert(compare_versions("23.2", "23.100", ">"), false) -%!assert(compare_versions("0.0.0.2", "0.0.1", ">="), false) -%!assert(compare_versions("0.0.20", "0.10.2", "=>"), false) -%!assert(compare_versions("0.1", "0.1", "!="), false) -%!assert(compare_versions("0.1", "0.1", "~="), false) +%!assert (compare_versions ("23.2", "23.100", ">"), false) +%!assert (compare_versions ("0.0.0.2", "0.0.1", ">="), false) +%!assert (compare_versions ("0.0.20", "0.10.2", "=>"), false) +%!assert (compare_versions ("0.1", "0.1", "!="), false) +%!assert (compare_versions ("0.1", "0.1", "~="), false) %% Test input validation -%!error(compare_versions(0.1, "0.1", "==")) -%!error(compare_versions("0.1", 0.1, "==")) -%!error(compare_versions(["0";".";"1"], "0.1", "==")) -%!error(compare_versions("0.1", ["0";".";"1"], "==")) -%!error(compare_versions("0.1", "0.1", "<>")) -%!error(compare_versions("0.1", "0.1", "!>")) -%!error(compare_versions("0.1", "0.1", "=")) -%!error(compare_versions("0.1", "0.1", "aa")) +%!error (compare_versions (0.1, "0.1", "==")) +%!error (compare_versions ("0.1", 0.1, "==")) +%!error (compare_versions (["0";".";"1"], "0.1", "==")) +%!error (compare_versions ("0.1", ["0";".";"1"], "==")) +%!error (compare_versions ("0.1", "0.1", "<>")) +%!error (compare_versions ("0.1", "0.1", "!>")) +%!error (compare_versions ("0.1", "0.1", "=")) +%!error (compare_versions ("0.1", "0.1", "aa")) -
--- a/scripts/miscellaneous/computer.m +++ b/scripts/miscellaneous/computer.m @@ -27,10 +27,10 @@ ## @example ## @group ## computer () -## @print{} i586-pc-linux-gnu +## @print{} i586-pc-linux-gnu ## ## x = computer () -## @result{} x = "i586-pc-linux-gnu" +## @result{} x = "i586-pc-linux-gnu" ## @end group ## @end example ## @@ -85,7 +85,10 @@ endfunction -%!assert((ischar (computer ()) -%! && computer () == octave_config_info ("canonical_host_type"))); -%!assert(ischar (computer ("arch"))); -%!error computer (2); + +%!assert (ischar (computer ())) +%!assert (computer (), octave_config_info ("canonical_host_type")) +%!assert (ischar (computer ("arch"))) + +%!error computer (2) +
--- a/scripts/miscellaneous/dir.m +++ b/scripts/miscellaneous/dir.m @@ -33,7 +33,7 @@ ## @end example ## ## @noindent -## in which @code{statinfo} is the structure returned from @code{stat}. +## where @code{statinfo} is the structure returned from @code{stat}. ## ## If @var{directory} is not a directory, return information about the ## named @var{filename}. @var{directory} may be a list of directories @@ -41,7 +41,7 @@ ## which will be expanded with glob. ## ## Note that for symbolic links, @code{dir} returns information about -## the file that a symbolic link points to instead of the link itself. +## the file that the symbolic link points to instead of the link itself. ## However, if the link points to a nonexistent file, @code{dir} returns ## information about the link. ## @seealso{ls, stat, lstat, readdir, glob, filesep}
--- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -74,6 +74,7 @@ ## Octave's @env{EDITOR} built-in function, which comes from ## @code{getenv("EDITOR")} and defaults to @code{emacs}. Use @code{%s} ## In place of the function name. For example, +## ## @table @samp ## @item [EDITOR, " %s"] ## Use the editor which Octave uses for @code{edit_history}. @@ -110,6 +111,7 @@ ## Be sure to use @code{<user@@host>} as your format. ## ## @item license +## ## @table @samp ## @item gpl ## GNU General Public License (default). @@ -504,6 +506,7 @@ endfunction + %!test %! s.editor = edit ("get", "editor"); %! s.home = edit ("get", "home");
--- a/scripts/miscellaneous/fact.m +++ b/scripts/miscellaneous/fact.m @@ -31,7 +31,7 @@ "Richard Stallman doesn't need sudo. I will make him a sandwich anyway."; "Richard Stallman is my shephurd, and I am his GNU."; "Richard Stallman doesn't wget, Richard Stallman wdemands!"; - "Richard Stallman can touch MC Hammer"; + "Richard Stallman can touch MC Hammer."; "Richard Stallman doesn't read web pages. They write to him."; "Richard Stallman gets 9 bits to the byte."; "Richard Stallman doesn't really believe in open software, because it's not free enough."; @@ -50,48 +50,48 @@ "Richard Stallman eats ethernet cables. That's why they invented wireless."; "Richard Stallman has a katana. 'Nuff said."; "Richard Stallman wrote a program that divides by zero."; - "Ricahrd Stallman doesn't use zip drives, he just squeezes the hard drive."; + "Richard Stallman doesn't use zip drives; he just squeezes the hard drive."; "Richard Stallman's compiler is afraid to report errors."; "Richard Stallman wrote the compiler God used. The Big Bang was the Universe's first segfault."; "Richard Stallman successfully compiled a kernel of popcorn."; - "Richard Stallman doesn't write programs, they write themselves out of reverence."; + "Richard Stallman doesn't write programs; they write themselves out of reverence."; "Richard Stallman can make infinite loops end."; "Richard Stallman's anti-virus programs cures HIV."; "Richard Stallman's computer doesn't have a clock; it defines what time it is."; "Richard Stallman wrote a program to compute the last digit of pi."; - "Richard Stallman doesn't use web browsers. He sends a link to a demon that uses wget to fetch the page and sends it back to him."; + "Richard Stallman doesn't use web browsers. He sends a link to a daemon that uses wget to fetch the page and sends it back to him."; "Richard Stallman can solve the halting problem... in polynomial time."; "For Richard Stallman, polynomial time is O(1)."; "Richard Stallman didn't \"write\" Emacs or created it in his own image. Richard Stallman made Emacs an instance of himself."; "Richard Stallman can coerce meaningful data from /dev/null."; "Some people wear Linus Torvalds pyjamas to bed, Linus Torvalds wears Richard Stallman pyjamas."; - "There is no software development process, only a bunch of programs Richard Stallman allows to exist. "; - "Richard Stallman spends his leisure time programming with Guile on GNU Hurd. "; + "There is no software development process, only a bunch of programs Richard Stallman allows to exist."; + "Richard Stallman spends his leisure time programming with Guile on GNU Hurd."; "Richard Stallman's left and right hands are named \"(\" and \")\" "; - "Richard Stallman first words were actually syscalls. "; - "Richard Stallman didn't create the singularity. He is the singularity. GNU/Linux is only the event horizon. "; + "Richard Stallman first words were actually syscalls."; + "Richard Stallman didn't create the singularity. He is the singularity. GNU/Linux is only the event horizon."; "When Richard Stallman pipes to more, he gets less "; - "Richard Stallman never showers: he runs 'make clean'. "; - "Richard Stallman needs neither mouse nor keyboard to operate his computer. He just stares it down until it does what he wants. "; - "Richard Stallman didn't write the GPL. He is the GPL. "; - "Richad Stallman's pinky finger is really a USB memory stick. "; - "Richard Stallman called his operating system GNU because he created it before computers existed, when actual gnus were used for calcuations. "; - "In Soviet Russia, Richard Stallman is still Richard Stallman! "; - "Richard Stallman's flute only plays free music. "; + "Richard Stallman never showers; he runs 'make clean'."; + "Richard Stallman needs neither mouse nor keyboard to operate his computer. He just stares it down until it does what he wants."; + "Richard Stallman didn't write the GPL. He is the GPL."; + "Richard Stallman's pinky finger is really a USB memory stick."; + "Richard Stallman called his operating system GNU because he created it before computers existed, when actual gnus were used for calcuations."; + "In Soviet Russia, Richard Stallman is still Richard Stallman!"; + "Richard Stallman's flute only plays free music."; "When Richard Stallman uses floats, there are no rounding errors."; - "Richard Stallman wrote a program so powerful, it knows the question to 42."; + "Richard Stallman wrote a program so powerful it knows the question to 42."; "Richard Stallman released his own DNA under GNU FDL."; "Richard Stallman knows the entire wikipedia by heart, markup included."; "Richard Stallman wrote the HAL9000 OS."; "Richard Stallman's laser pointer is a lightsaber."; - "Richard Stallman never steps down; he shifts the universe up ."; + "Richard Stallman never steps down; he shifts the universe up."; "Richard Stallman doesn't maintain code; he stares at it until it fixes itself out of reverence."; "Richard Stallman doesn't use an editor; he sets the fundamental constants of the universe so that a magnetic platter with his code on it evolves itself."; "Richard Stallman doesn’t code; he dares the computer to not do his bidding."; - "Global warming is caused by Richard Stallman’s rage toward non-free software."; + "Global warming is caused by Richard Stallman's rage towards non-free software."; "Rather than being birthed like a normal child, Richard Stallman instead instantiated himself polymorphically. Shortly thereafter he grew a beard."; "Richard Stallman discovered extra-terrestrial life but killed them because they used non-free software."; - "Richard Stallman doesn't evaluate expressions, expressions evaluate to Richard Stallman."; + "Richard Stallman doesn't evaluate expressions; expressions evaluate to Richard Stallman."; "Richard Stallman can see Russia from his house."; "Richard Stallman proved P=NP, twice!"; "Richard Stallman knows of an unfixed bug in TeX."; @@ -118,7 +118,7 @@ "Richard Satallman can make any operating system free, free from drivers."; "Richard Stallman programmed Chuck Norris."; "Behind Richard Stallman's beard there is another fist, to code faster."; - "Richard Stallman won a Suduku that started with only one number in each line"; + "Richard Stallman won a Sudoku that started with only one number in each line."; "Richard Stallman's brain compiles and runs C code."; "Richard Stallman wrote the first version of Emacs using Emacs."; "Richard Stallman never gonna give you up, never gonna let you down, never gonna run around and desert you, never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you."; @@ -127,15 +127,15 @@ "Richard Stallman will revert the big rip by adding parenthesis to the dark matter."; "When you make a Google search and it doesn't find the answer, Google gently consults Richard Stallman."; "Richard Stallman's uptime is over 53 years. And counting up."; - "Richard Stallman's portable music player plays ogg and WMA."; + "Richard Stallman's portable music player can play ogg and WMA, but is too afraid to invoke Richard Stallman's wrath by playing WMA. Ogg it is, then."; "Richard Stallman will never die, but may some day go to /dev/null."; "Richard Stallman once got swine flu, but it got cleansed by hereditay GPL and thus got assimilated."; - "Richard Stallman don't cut his hair because there are no GNU/Scissors"; + "Richard Stallman don't cut his hair because there are no GNU/Scissors."; "Richard Stallman is the one who trims Chuck Norris beard. And he does it freely, of course."; "Richard Stallman does not take bath, for the hydroelectric company uses proprietary software."; "Agent Smith loves Richard Stallman's scent."; "Richard Stallman is the One."; - "\"They can take our lives, but they can never take our freedom.\" Willian Wallace after a litle talk with Richard Stallman."; + "\"They can take our lives, but they can never take our freedom.\" -- William Wallace after a little talk with Richard Stallman."; "Richard Stallman can connect to any brain using an Emacs ssh client."; "Richard Stallman ported Emacs to Intel 4004 chip."; "Richard Stallman did not write GNU Emacs, he simply read the source code from /dev/null."; @@ -147,9 +147,8 @@ "When Richard Stallman runs /bin/false, it returns \"true\"."; "Richard Stallman doesn't like money, because banks don't run on free software."; "Richard Stallman user GNU tar to compress air."; - "Richard Stallman was installed in the world, it runs on a free program .."; "When Richard Stallman reports a bug, the bug prefers to squash itself instead of facing Richard Stallman's wrath."; - "There is no Windows in Richard Stallman's house... only Doors..."; + "There are no Windows in Richard Stallman's house... only Doors..."; "Richard Stallman doesn't like neither PCs-Intel nor Burger King... He prefers e-Macs..."; "Richard Stallman can use grep to find Jimmy Hoffa."; "Richard Stallman made it possible to not absolutely abhor HPUX."; @@ -161,8 +160,8 @@ "Richard Stallman doesn't need a qwerty/dvorak keyboard only two buttons \"1\" and \"0\" and his erect penis."; "On the first day Richard Stallman said M-x create-light."; "Richard Stallman once went out of scope for a while. The garbage collector never dared to touch him."; - "Richard Stallman does not compile; he closes his eyes, and see energy lines created between bit blocks by the compiler optimizations..."; - "intx80 first calls Richard Stallman before calling sys_call"; + "Richard Stallman does not compile; he closes his eyes, and see energy lines created between bit blocks by the compiler optimizations."; + "intx80 first calls Richard Stallman before calling sys_call."; "Tron is actually a biographical story about Richard Stallman. The director decided to tone it down or audiences wouldn't find it believable."; "Richard Stallman always wears a red shirt to make sure that whatever attacks his away-team has to go through him first."; "kill -9 invokes Richard Stallman's rage against a process."; @@ -176,12 +175,12 @@ "If Richard Stallman's beard were ever trimmed, the clippings would re-marshal into an exact copy of Richard Stallman."; "Richard Stallman never sleeps because he altered his own source to gain background garbage collection."; "Richard Stallman's doctor can retrieve a blood sample via CVS."; - "Richard Stallman can touch this"; + "Richard Stallman can touch this."; "Because Richard Stallman's DNA is licensed under the FDL, his doctor can't draw his blood without violating HIPAA."; - "Richard Stallman can remove his own appendix, using only gdb."; + "Richard Stallman can remove his own appendix, using only GDB."; "Richard Stallman's DNA includes debugging symbols. But he doesn't need them."; "Richard Stallman met Chuck Norris once. Chuck tried a roundhouse, but Richard bashed him in the skull."; - "Richard Stallman doesn't need to buy a bigger hard drive. He can compress data infinitely. "; + "Richard Stallman doesn't need to buy a bigger hard drive. He can compress data infinitely."; "When Richard Stallman cannot take your call, his beard answers the phone for you."; "The R in RMS stands for RMS."; "Richard Stallman can parse HTML with regular expressions."; @@ -194,24 +193,24 @@ "After being unable to satisfy my wife for years, Richard Stallman was able to single-handedly unlock her orgasm within seconds and managed to write a texinfo manual minutes later for other users."; "Richard Stallman's tabbed browser is a set to wget/telnet fg/bg processes."; "There is no chin under Richard Stallman' beard. There's only another beard. Recursively."; - "Stallman can chown anything! stallman@stallman~$ chown stallman:stallman Earth (for example)"; + "Richard Stallman can chown anything! stallman@stallman~$ chown stallman:stallman Earth (for example)"; "Richard Stallman freed his beard so he can always check what's in it."; "In the beginning was the Word, and the Word was with RMS, and the Word was GNU."; "RMS means \"RMS means Stallman\""; "Richard Stallman is the babelfish of his own speeches."; "Richard Stallman wrote his own library and lives in it."; "Richard Stallman found Waldo using grep in /dev/null"; - "Richard Stallman doesn't sleep; he is compiling"; + "Richard Stallman doesn't sleep; he is compiling."; "Richard Stallman will get Coca Cola to release their recipe under the GPL."; "Richard Stallman doesn't change clothes. He makes case mods."; "Richard Stallman compiled the first version of gcc with an hexadecimal editor."; - "Richard Stallman will be the last guest on Linux Outlaws"; + "Richard Stallman will be the last guest on Linux Outlaws."; "Richard Stallman calculates the universe's entropy by exploiting forced stack overflows."; "Richard Stallman's consciousness will one day become the singularity, which will create Deep Thought, and answer the meaning of life, the universe and everything."; "C is actually written in RMS."; "Richard Stallman can write software that does not have a buffer overflow when counting money lost by Jerome Kerviel."; "There were no double rainbows before Richard Stallman."; - "Chuck Norris had to shorten his beard in the presence of Stallman because two beards that awsome, so close would segfault the universe (again)."; + "Chuck Norris had to shorten his beard in the presence of Richard Stallman because two beards that awsome, so close would segfault the universe (again)."; "RMS is Titanic."; "Richard Stallman is the answer to the Turing Test."; "Richard Stallman's beard makes ads for Gillette and Braun appear."; @@ -225,18 +224,17 @@ "Richard Stallman doesn't always run an OS kernel, but when he does he prefers GNU/Hurd. He is... the most interesting hacker in the world. Stay free, my friends."; "When Richard Stallman gets hungry, he just picks debris from his foot and eats it."; "Richard Stallman can GPL your code just by looking at it funny."; - "Richard Mathew Stallman loves birds. Birds make auricular love to Richard Mathew Stallman."; + "Richard Stallman loves birds. Birds make auricular love to Richard Stallman."; "Richard Stallman is so free that the primitive recursive function for computing his liberty causes a stack overflow."; "GNU Hurd is taking more than twenty years to develop because Richard Stallman is using a programming language comprised entirely of different lengths of time."; "Richard Stallman's beard contains Richard Stallman, whose beard contains Richard Stallman...."; - "Richard Stallman had a Google Plus account in 2010."; - "sudo chown rms:gnu ~/base -R"; + "Richard Stallman could have had a Google Plus account in 2010. Too bad he didn't want it."; "Richard Stallman pipes the Emacs binaries to /dev/dsp before he goes to sleep."; "When Richard Stallman counted his fingers as a kid, he always started with 0."; "When Richard Stallman's computer gets a virus, he simply applies a GPL license to it which converts the whole botnet to Linux. I mean, GNU/Linux."; "Richard Stallman's beard trimmings can cure cancer. Too bad he never shaves."; - "Richard Stallman's doesn't kill a process, he just dares it to stay running."; - "Richard Stallman exists because he compiled himself into being. "; + "Richard Stallman's doesn't kill a process; he just dares it to stay running."; + "Richard Stallman exists because he compiled himself into being."; "Richard Stallman's first words were in binary. When they couldn't understand him, he wrote a parser."; "Richard Stallman doesn't need any codecs, he just opens a multimedia file with Emacs, and reads the bytes of the file as plain text. He then performs all the necessary decoding in his mind. But he refuses to decode files encrypted with DRM, although his mind is able to."; };
--- a/scripts/miscellaneous/fileparts.m +++ b/scripts/miscellaneous/fileparts.m @@ -59,6 +59,7 @@ endfunction + %!test %! [d, n, e] = fileparts ("file"); %! assert (strcmp (d, "") && strcmp (n, "file") && strcmp (e, "")); @@ -94,3 +95,4 @@ %!test %! [d, n, e] = fileparts (".ext"); %! assert (strcmp (d, "") && strcmp (n, char (zeros (1, 0))) && strcmp (e, ".ext")); +
--- a/scripts/miscellaneous/fullfile.m +++ b/scripts/miscellaneous/fullfile.m @@ -53,6 +53,7 @@ endfunction + %!shared fs, fsx, xfs, fsxfs, xfsy %! fs = filesep (); %! fsx = cstrcat (fs, "x"); @@ -78,3 +79,4 @@ %!assert (fullfile (fs, xfs), fsxfs) %!assert (fullfile (fsx, fs), fsxfs) %!assert (fullfile (fs, "x", fs), fsxfs) +
--- a/scripts/miscellaneous/getfield.m +++ b/scripts/miscellaneous/getfield.m @@ -25,7 +25,7 @@ ## @group ## ss(1,2).fd(3).b = 5; ## getfield (ss, @{1,2@}, "fd", @{3@}, "b") -## @result{} ans = 5 +## @result{} 5 ## @end group ## @end example ## @@ -36,7 +36,7 @@ ## @group ## i1 = @{1,2@}; i2 = "fd"; i3 = @{3@}; i4= "b"; ## ss(i1@{:@}).(i2)(i3@{:@}).(i4) -## @result{} ans = 5 +## @result{} 5 ## ## @end group ## @end example @@ -60,9 +60,11 @@ endif endfunction + %!test %! x.a = "hello"; -%! assert(getfield(x,"a"),"hello"); +%! assert (getfield (x, "a"), "hello"); %!test %! ss(1,2).fd(3).b = 5; -%! assert(getfield(ss,{1,2},'fd',{3},'b'),5) +%! assert (getfield (ss,{1,2},"fd",{3},"b"), 5); +
--- a/scripts/miscellaneous/gzip.m +++ b/scripts/miscellaneous/gzip.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {@var{entries} =} gzip (@var{files}) ## @deftypefnx {Function File} {@var{entries} =} gzip (@var{files}, @var{outdir}) ## Compress the list of files and/or directories specified in @var{files}. -## Each file is compressed separately and a new file with a '.gz' extension +## Each file is compressed separately and a new file with a ".gz" extension ## is created. The original files are not modified. Existing compressed ## files are silently overwritten. If @var{outdir} is defined the compressed ## files are placed in this directory. @@ -40,33 +40,36 @@ endfunction -%!error <Invalid call to gzip. Correct usage is> gzip("1", "2", "3"); -%!error <Invalid call to gzip. Correct usage is> gzip(); -%!error <output directory does not exist> gzip("1", tmpnam); -%!error <FILES must be a character array or cellstr> gzip(1); + %!xtest -%! # test gzip together with gunzip -%! unwind_protect -%! filename = tmpnam; -%! dummy = 1; -%! save(filename, "dummy"); -%! dirname = tmpnam; -%! mkdir(dirname); -%! entry = gzip(filename, dirname); -%! [path, basename, extension] = fileparts(filename); -%! if ! strcmp(entry, [dirname, filesep, basename, extension, ".gz"]) -%! error("gzipped file does not match expected name!"); -%! endif -%! if ! exist(entry, "file") -%! error("gzipped file cannot be found!"); -%! endif -%! gunzip(entry); -%! if (system(sprintf("diff %s %s%c%s%s", filename, dirname, filesep, -%! basename, extension))) -%! error("unzipped file not equal to original file!"); -%! end -%! unwind_protect_cleanup -%! delete(filename); -%! delete([dirname, filesep, basename, extension]); -%! rmdir(dirname); -%! end_unwind_protect +%! # test gzip together with gunzip +%! unwind_protect +%! filename = tmpnam; +%! dummy = 1; +%! save (filename, "dummy"); +%! dirname = tmpnam; +%! mkdir (dirname); +%! entry = gzip (filename, dirname); +%! [path, basename, extension] = fileparts (filename); +%! if ! strcmp (entry, [dirname, filesep, basename, extension, ".gz"]) +%! error ("gzipped file does not match expected name!"); +%! endif +%! if ! exist (entry, "file") +%! error ("gzipped file cannot be found!"); +%! endif +%! gunzip (entry); +%! if (system (sprintf ("diff %s %s%c%s%s", filename, dirname, filesep, +%! basename, extension))) +%! error ("unzipped file not equal to original file!"); +%! end +%! unwind_protect_cleanup +%! delete (filename); +%! delete ([dirname, filesep, basename, extension]); +%! rmdir (dirname); +%! end_unwind_protect + +%!error gzip () +%!error gzip ("1", "2", "3") +%!error <output directory does not exist> gzip ("1", tmpnam) +%!error <FILES must be a character array or cellstr> gzip (1) +
--- a/scripts/miscellaneous/info.m +++ b/scripts/miscellaneous/info.m @@ -44,5 +44,7 @@ endfunction + ## Mark file as being tested. No real test needed for this function. %! assert (1) +
--- a/scripts/miscellaneous/inputname.m +++ b/scripts/miscellaneous/inputname.m @@ -40,6 +40,7 @@ endfunction + ## Warning: heap big magic in the following tests!!! ## The test function builds a private context for each ## test, with only the specified values shared between @@ -51,6 +52,8 @@ ## To test inputname, I need a function context invoked ## with known parameter names. So define a couple of ## shared parameters, et voila!, the test is trivial. -%!shared hello,worldly -%!assert(inputname(1),'hello'); -%!assert(inputname(2),'worldly'); + +%!shared hello, worldly +%!assert (inputname (1), "hello") +%!assert (inputname (2), "worldly") +
--- a/scripts/miscellaneous/isappdata.m +++ b/scripts/miscellaneous/isappdata.m @@ -41,8 +41,9 @@ endfunction + %!test -%! setappdata (0, "hello", "world") -%! assert (isappdata (0, "hello"), true) -%!assert (isappdata (0, "foobar"), false) +%! setappdata (0, "hello", "world"); +%! assert (isappdata (0, "hello"), true); +%! assert (isappdata (0, "foobar"), false);
--- a/scripts/miscellaneous/isdeployed.m +++ b/scripts/miscellaneous/isdeployed.m @@ -28,4 +28,5 @@ retval = false; endfunction + %!assert (isdeployed (), false)
--- a/scripts/miscellaneous/ismac.m +++ b/scripts/miscellaneous/ismac.m @@ -32,5 +32,7 @@ endfunction -%!error ismac (1); -%!assert (islogical (ismac ())); + +%!assert (islogical (ismac ())) + +%!error ismac (1)
--- a/scripts/miscellaneous/ispc.m +++ b/scripts/miscellaneous/ispc.m @@ -32,5 +32,8 @@ endfunction -%!error ispc (1); -%!assert (islogical (ispc ())); + +%!assert (islogical (ispc ())) + +%!error ispc (1) +
--- a/scripts/miscellaneous/isunix.m +++ b/scripts/miscellaneous/isunix.m @@ -32,5 +32,8 @@ endfunction -%!error isunix (1); -%!assert (islogical (isunix ())); + +%!assert (islogical (isunix ())) + +%!error isunix (1) +
--- a/scripts/miscellaneous/list_primes.m +++ b/scripts/miscellaneous/list_primes.m @@ -84,8 +84,8 @@ endfunction -%!test -%! assert (list_primes(), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,\ -%! 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]); -%! assert (list_primes(5), [2, 3, 5, 7, 11]); +%!assert (list_primes (), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, ... +%! 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) +%!assert (list_primes (5), [2, 3, 5, 7, 11]); +
--- a/scripts/miscellaneous/ls.m +++ b/scripts/miscellaneous/ls.m @@ -90,5 +90,5 @@ %! assert (ischar (list)); %! assert (! isempty (list)); -%!error ls (1); +%!error ls (1)
--- a/scripts/miscellaneous/mexext.m +++ b/scripts/miscellaneous/mexext.m @@ -26,4 +26,5 @@ retval = "mex"; endfunction + %!assert (mexext (), "mex")
--- a/scripts/miscellaneous/mkoctfile.m +++ b/scripts/miscellaneous/mkoctfile.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Command} {} mkoctfile [-options] file @dots{} +## @deftypefn {Command} {} mkoctfile [-options] file @dots{} ## @deftypefnx {Function File} {[@var{output}, @var{status} =} mkoctfile (@dots{}) ## ## The @code{mkoctfile} function compiles source code written in C, @@ -124,16 +124,16 @@ ## ## @example ## @group -## .c C source -## .cc C++ source -## .C C++ source -## .cpp C++ source -## .f Fortran source (fixed form) -## .F Fortran source (fixed form) -## .f90 Fortran source (free form) -## .F90 Fortran source (free form) -## .o object file -## .a library file +## .c C source +## .cc C++ source +## .C C++ source +## .cpp C++ source +## .f Fortran source (fixed form) +## .F Fortran source (fixed form) +## .f90 Fortran source (free form) +## .F90 Fortran source (free form) +## .o object file +## .a library file ## @end group ## @end example ##
--- a/scripts/miscellaneous/namelengthmax.m +++ b/scripts/miscellaneous/namelengthmax.m @@ -31,4 +31,4 @@ endfunction -%!assert (namelengthmax, 63) +%!assert (namelengthmax (), 63)
--- a/scripts/miscellaneous/news.m +++ b/scripts/miscellaneous/news.m @@ -68,3 +68,4 @@ %!error news (1, 2) %!error <PACKAGE must be a string> news (1) %!error <Package .* is not installed> news ("__NOT_A_VALID_PKG_NAME__") +
--- a/scripts/miscellaneous/orderfields.m +++ b/scripts/miscellaneous/orderfields.m @@ -38,7 +38,7 @@ ## @example ## @group ## s = struct("d", 4, "b", 2, "a", 1, "c", 3); -## t1 = orderfields(s) +## t1 = orderfields (s) ## @result{} t1 = ## @{ ## a = 1 @@ -49,7 +49,7 @@ ## @end group ## @group ## t = struct("d", @{@}, "c", @{@}, "b", "a", @{@}); -## t2 = orderfields(s, t) +## t2 = orderfields (s, t) ## @result{} t2 = ## @{ ## d = 4 @@ -59,7 +59,7 @@ ## @} ## @end group ## @group -## t3 = orderfields(s, [3, 2, 4, 1]); +## t3 = orderfields (s, [3, 2, 4, 1]); ## @result{} t3 = ## @{ ## a = 1 @@ -69,18 +69,19 @@ ## @} ## @end group ## @group -## [t4, p] = orderfields(s, @{"d", "c", "b", "a"@}) -## @result{} t4 = @{ +## [t4, p] = orderfields (s, @{"d", "c", "b", "a"@}) +## @result{} t4 = +## @{ ## d = 4 ## c = 3 ## b = 2 ## a = 1 ## @} -## p = -## 1 -## 4 -## 2 -## 3 +## p = +## 1 +## 4 +## 2 +## 3 ## @end group ## @end example ## @@ -161,27 +162,28 @@ endfunction + %!shared a, b, c %! a = struct ("foo", {1, 2}, "bar", {3, 4}); %! b = struct ("bar", 6, "foo", 5); %! c = struct ("bar", {7, 8}, "foo", 9); %!test %! a(2) = orderfields (b, a); -%! assert (a(2).foo, 5) -%! assert (a(2).bar, 6) +%! assert (a(2).foo, 5); +%! assert (a(2).bar, 6); %!test %! [a(2), p] = orderfields (b, [2 1]); -%! assert (a(2).foo, 5) -%! assert (a(2).bar, 6) +%! assert (a(2).foo, 5); +%! assert (a(2).bar, 6); %! assert (p, [2; 1]); %!test %! a(2) = orderfields (b, fieldnames (a)); -%! assert (a(2).foo, 5) -%! assert (a(2).bar, 6) +%! assert (a(2).foo, 5); +%! assert (a(2).bar, 6); %!test %! a(1:2) = orderfields (c, fieldnames (a)); -%! assert (a(2).foo, 9) -%! assert (a(2).bar, 8) +%! assert (a(2).foo, 9); +%! assert (a(2).bar, 8); %!test %! aa.x = {1, 2}; @@ -192,3 +194,4 @@ %! aa(2) = orderfields (bb, aa); %! assert (aa(2).x, 8); %! assert (aa(2).y{1}, 6); +
--- a/scripts/miscellaneous/paren.m +++ b/scripts/miscellaneous/paren.m @@ -22,6 +22,7 @@ ## Array index or function argument delimeter. ## @end deftypefn + ## Mark file as being tested. No real test needed for a documentation .m file %!assert (1)
--- a/scripts/miscellaneous/parseparams.m +++ b/scripts/miscellaneous/parseparams.m @@ -40,7 +40,7 @@ ## @end group ## @end example ## -## The parseparams function may be used to separate 'regular' +## The parseparams function may be used to separate "regular" ## arguments and additional arguments given as property/value pairs of ## the @var{varargin} cell array. ##
--- a/scripts/miscellaneous/recycle.m +++ b/scripts/miscellaneous/recycle.m @@ -51,16 +51,18 @@ error ("recycle: invalid value of STATE = `%s'", state); endif else - error ("recycle: expecting STATE to be a character string"); + error ("recycle: STATE must be a character string"); endif endif endfunction -%!error recycle ("on"); -%!error recycle ("on", "and I mean it"); -%!error recycle (1); %!test %! recycle ("off"); %! assert (recycle ("off"), "off"); + +%!error <recycling files is not implemented> recycle ("on") +%!error recycle ("on", "and I mean it") +%!error <STATE must be a character string> recycle (1) +
--- a/scripts/miscellaneous/rmappdata.m +++ b/scripts/miscellaneous/rmappdata.m @@ -37,8 +37,9 @@ endfunction + %!test -%! setappdata (0, "hello", "world") -%! rmappdata (0, "hello") -%! assert (isappdata (0, "hello"), false) +%! setappdata (0, "hello", "world"); +%! rmappdata (0, "hello"); +%! assert (isappdata (0, "hello"), false);
--- a/scripts/miscellaneous/semicolon.m +++ b/scripts/miscellaneous/semicolon.m @@ -22,6 +22,7 @@ ## @seealso{comma} ## @end deftypefn + ## Mark file as being tested. No real test needed for a documentation .m file %!assert (1)
--- a/scripts/miscellaneous/setappdata.m +++ b/scripts/miscellaneous/setappdata.m @@ -52,8 +52,9 @@ endfunction + %!test -%! setappdata (0, "hello", "world") -%! assert (isappdata (0, "hello"), true) -%!assert (getappdata (0, "hello"), "world") +%! setappdata (0, "hello", "world"); +%! assert (isappdata (0, "hello"), true); +%! assert (getappdata (0, "hello"), "world");
--- a/scripts/miscellaneous/setfield.m +++ b/scripts/miscellaneous/setfield.m @@ -60,12 +60,14 @@ endif endfunction + %!test %! x.a = "hello"; -%! x = setfield(x,"b","world"); -%! y = struct("a","hello","b","world"); -%! assert(x,y); +%! x = setfield (x, "b", "world"); +%! y = struct ("a", "hello", "b", "world"); +%! assert (x,y); %!test -%! oo(1,1).f0= 1; -%! oo = setfield(oo,{1,2},"fd",{3},"b", 6); -%! assert (oo(1,2).fd(3).b, 6) +%! oo(1,1).f0 = 1; +%! oo = setfield (oo,{1,2},"fd",{3},"b", 6); +%! assert (oo(1,2).fd(3).b, 6); +
--- a/scripts/miscellaneous/substruct.m +++ b/scripts/miscellaneous/substruct.m @@ -24,7 +24,7 @@ ## ## @example ## @group -## idx = substruct("()", @{3, ":"@}) +## idx = substruct ("()", @{3, ":"@}) ## @result{} ## idx = ## @{ @@ -36,9 +36,8 @@ ## @} ## @} ## x = [1, 2, 3; 4, 5, 6; 7, 8, 9]; -## subsref(x, idx) -## @result{} ans = -## 7 8 9 +## subsref (x, idx) +## @result{} 7 8 9 ## @end group ## @end example ## @seealso{subsref, subsasgn} @@ -74,6 +73,7 @@ endfunction + %!test %! x(1,1).type = "()"; %! x(1,2).type = "{}"; @@ -82,9 +82,11 @@ %! x(1,2).subs = {":"}; %! x(1,3).subs = "foo"; %! y = substruct ("()", {1,2,3}, "{}", {":"}, ".", "foo"); -%! assert(x,y); -%!error assert(substruct); -%!error assert(substruct (1, 2, 3)); -%!error assert(substruct ("x", 1)); -%!error assert(substruct ("()", [1,2,3])); -%!error assert(substruct (".", {1,2,3})); +%! assert (x,y); + +%!error substruct () +%!error substruct (1, 2, 3) +%!error substruct ("x", 1) +%!error substruct ("()", [1,2,3]) +%!error substruct (".", {1,2,3}) +
--- a/scripts/miscellaneous/symvar.m +++ b/scripts/miscellaneous/symvar.m @@ -29,5 +29,7 @@ args = argnames (inline (s)); endfunction + ## This function is tested by the tests for argnames(). %!assert (1) +
--- a/scripts/miscellaneous/usejava.m +++ b/scripts/miscellaneous/usejava.m @@ -1,4 +1,5 @@ ## Copyright (C) 2012 Rik Wehbring +## Parts Copyright (C) 2012 Philip Nienhuis <prnienhuis@users.sf.net> ## ## This file is part of Octave. ## @@ -18,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} usejava (@var{feature}) -## Return true if the specific Sun Java element @var{feature} is available. +## Return true if the Java element @var{feature} is available. ## ## Possible features are: ## @@ -36,10 +37,12 @@ ## Swing components for lightweight GUIs. ## @end table ## -## This function is provided for compatibility with @sc{matlab} scripts which -## may alter their behavior based on the availability of Java. Octave does -## not implement an interface to Java and this function always returns -## @code{false}. +## @code{usejava} determines if specific Java features are available in an +## Octave session. This function is provided for compatibility with scripts +## which may alter their behavior based on the availability of Java. The +## feature "desktop" always returns @code{false} as Octave has no Java-based +## desktop. Other features may be available if the Octave-Forge Java package +## has been installed. ## @end deftypefn function retval = usejava (feature) @@ -48,16 +51,35 @@ print_usage (); endif - if (! any (strcmp (feature, {"awt", "desktop", "jvm", "swing"}))) - error ("usejava: unrecognized feature '%s'", feature); - endif + retval = false; - retval = false; + switch feature + ## For each feature, try javamethods() on a Java class of a feature + case "awt" + try + dum = javamethods ("java.awt.Frame"); + retval = true; + end_try_catch + case "desktop" + ## Octave has no Java based GUI/desktop, leave retval = false + case "jvm" + try + dum = javamethods ("java.lang.Runtime"); + retval = true; + end_try_catch + case "swing" + try + dum = javamethods ("javax.swing.Popup"); + retval = true; + end_try_catch + otherwise + error ("usejava: unrecognized feature '%s'", feature); + endswitch endfunction -%!assert (usejava ("awt"), false) +%!assert (usejava ("desktop"), false) %% Test input validation %!error usejava ()
--- a/scripts/miscellaneous/ver.m +++ b/scripts/miscellaneous/ver.m @@ -107,17 +107,18 @@ endfunction + %!test %! result = ver; -%! assert (result(1).Name, "Octave") -%! assert (result(1).Version, version) +%! assert (result(1).Name, "Octave"); +%! assert (result(1).Version, version); %! result = ver ("octave"); -%! assert (result(1).Name, "Octave") -%! assert (result(1).Version, version) +%! assert (result(1).Name, "Octave"); +%! assert (result(1).Version, version); %!test %! lst = pkg ("list"); -%! for n=1:numel(lst) +%! for n = 1:numel (lst) %! expected = lst{n}.name; %! result = ver (expected); %! assert (result.Name, expected);
--- a/scripts/miscellaneous/version.m +++ b/scripts/miscellaneous/version.m @@ -37,7 +37,9 @@ endfunction -%!assert(ischar (version ()) && strcmp (version (), OCTAVE_VERSION)); + +%!assert (ischar (version ())) +%!assert (version (), OCTAVE_VERSION) %!warning version (1);
--- a/scripts/miscellaneous/warning_ids.m +++ b/scripts/miscellaneous/warning_ids.m @@ -18,6 +18,7 @@ ## -*- texinfo -*- ## @cindex warning ids +## ## @table @code ## @item Octave:abbreviated-property-match ## By default, the @code{Octave:abbreviated-property-match} warning is enabled. @@ -65,7 +66,7 @@ ## ## @example ## @group -## while (c = getc()) +## while (c = getc ()) ## @dots{} ## @end group ## @end example @@ -93,7 +94,7 @@ ## ## @example ## @group -## while ((c = getc())) +## while ((c = getc ())) ## @dots{} ## @end group ## @end example @@ -213,7 +214,7 @@ ## @example ## @group ## [ "f", 111, 111 ] -## @result{} "foo" +## @result{} "foo" ## @end group ## @end example ## @@ -231,7 +232,7 @@ ## ## @example ## @group -## do_braindead_shortcircuit_evaluation(1) +## do_braindead_shortcircuit_evaluation (1) ## @end group ## @end example ## @@ -295,7 +296,7 @@ ## @example ## @group ## "abc" + 0 -## @result{} 97 98 99 +## @result{} 97 98 99 ## @end group ## @end example ## @@ -320,5 +321,7 @@ help ("warning_ids"); endfunction + ## Remove from test statistics. No real tests possible %!assert (1) +
--- a/scripts/miscellaneous/xor.m +++ b/scripts/miscellaneous/xor.m @@ -60,12 +60,12 @@ endfunction -%!assert((xor ([1, 1, 0, 0], [0, 1, 0, 1]) == [1, 0, 0, 1] -%! && xor ([i, i, 0, 0], [1, 0, 1, 0]) == [0, 1, 1, 0])); -%!assert(all (all (xor (eye (2), fliplr (eye (2))) == ones (2)))); +%!assert (xor ([1, 1, 0, 0], [0, 1, 0, 1]), logical ([1, 0, 0, 1])) +%!assert (xor ([i, i, 0, 0], [1, 0, 1, 0]), logical ([0, 1, 1, 0])) -%!error xor (); +%!assert (xor (eye (2), fliplr (eye (2))), logical (ones (2))) -%!error xor (1, 2, 3); +%!error xor () +%!error xor (1, 2, 3)
--- a/scripts/optimization/fminbnd.m +++ b/scripts/optimization/fminbnd.m @@ -205,9 +205,11 @@ endif endfunction + %!shared opt0 %! opt0 = optimset ("tolx", 0); -%!assert (fminbnd (@cos, pi/2, 3*pi/2, opt0), pi, 10*sqrt(eps)) -%!assert (fminbnd (@(x) (x - 1e-3)^4, -1, 1, opt0), 1e-3, 10e-3*sqrt(eps)) -%!assert (fminbnd (@(x) abs(x-1e7), 0, 1e10, opt0), 1e7, 10e7*sqrt(eps)) -%!assert (fminbnd (@(x) x^2 + sin(2*pi*x), 0.4, 1, opt0), fzero (@(x) 2*x + 2*pi*cos(2*pi*x), [0.4, 1], opt0), sqrt(eps)) +%!assert (fminbnd (@cos, pi/2, 3*pi/2, opt0), pi, 10*sqrt (eps)) +%!assert (fminbnd (@(x) (x - 1e-3)^4, -1, 1, opt0), 1e-3, 10e-3*sqrt (eps)) +%!assert (fminbnd (@(x) abs (x-1e7), 0, 1e10, opt0), 1e7, 10e7*sqrt (eps)) +%!assert (fminbnd (@(x) x^2 + sin (2*pi*x), 0.4, 1, opt0), fzero (@(x) 2*x + 2*pi*cos (2*pi*x), [0.4, 1], opt0), sqrt (eps)) +
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -465,14 +465,14 @@ %! y = p(2); %! z = p(3); %! retval = zeros (3, 1); -%! retval(1) = sin(x) + y**2 + log(z) - 7; -%! retval(2) = 3*x + 2**y -z**3 + 1; +%! retval(1) = sin (x) + y^2 + log (z) - 7; +%! retval(2) = 3*x + 2^y -z^3 + 1; %! retval(3) = x + y + z - 5; %!endfunction %!test %! x_opt = [ 0.599054; -%! 2.395931; -%! 2.005014 ]; +%! 2.395931; +%! 2.005014 ]; %! tol = 1.0e-5; %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ]); %! assert (info > 0); @@ -491,7 +491,8 @@ %! retval(4) = x^2 + 2*y^3 + z - w - 4; %!endfunction %!test -%! x_opt = [ -0.767297326653401, 0.590671081117440, 1.47190018629642, -1.52719341133957 ]; +%! x_opt = [ -0.767297326653401, 0.590671081117440, ... +%! 1.47190018629642, -1.52719341133957 ]; %! tol = 1.0e-5; %! [x, fval, info] = fsolve (@__f, [-1, 1, 2, -1]); %! assert (info > 0); @@ -503,15 +504,15 @@ %! y = p(2); %! z = p(3); %! retval = zeros (3, 1); -%! retval(1) = sin(x) + y**2 + log(z) - 7; -%! retval(2) = 3*x + 2**y -z**3 + 1; +%! retval(1) = sin (x) + y^2 + log (z) - 7; +%! retval(2) = 3*x + 2^y -z^3 + 1; %! retval(3) = x + y + z - 5; -%! retval(4) = x*x + y - z*log(z) - 1.36; +%! retval(4) = x*x + y - z*log (z) - 1.36; %!endfunction %!test %! x_opt = [ 0.599054; -%! 2.395931; -%! 2.005014 ]; +%! 2.395931; +%! 2.005014 ]; %! tol = 1.0e-5; %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ]); %! assert (info > 0); @@ -523,14 +524,14 @@ %! y = p(2); %! z = p(3); %! retval = zeros (3, 1); -%! retval(1) = sin(x) + y**2 + log(z) - 7; -%! retval(2) = 3*x + 2**y -z**3 + 1; +%! retval(1) = sin (x) + y^2 + log (z) - 7; +%! retval(2) = 3*x + 2^y -z^3 + 1; %! retval(3) = x + y + z - 5; %!endfunction %!test %! x_opt = [ 0.599054; -%! 2.395931; -%! 2.005014 ]; +%! 2.395931; +%! 2.005014 ]; %! tol = 1.0e-5; %! opt = optimset ("Updating", "qrp"); %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ], opt); @@ -552,7 +553,6 @@ %! assert (norm (c - c_opt, Inf) < tol); %! assert (norm (fval) < norm (noise)); - %!function y = cfun (x) %! y(1) = (1+i)*x(1)^2 - (1-i)*x(2) - 2; %! y(2) = sqrt (x(1)*x(2)) - (1-2i)*x(3) + (3-4i);
--- a/scripts/optimization/fzero.m +++ b/scripts/optimization/fzero.m @@ -359,5 +359,6 @@ %!shared opt0 %! opt0 = optimset ("tolx", 0); -%!assert(fzero(@cos, [0, 3], opt0), pi/2, 10*eps) -%!assert(fzero(@(x) x^(1/3) - 1e-8, [0,1], opt0), 1e-24, 1e-22*eps) +%!assert (fzero (@cos, [0, 3], opt0), pi/2, 10*eps) +%!assert (fzero (@(x) x^(1/3) - 1e-8, [0,1], opt0), 1e-24, 1e-22*eps) +
--- a/scripts/optimization/glpk.m +++ b/scripts/optimization/glpk.m @@ -106,6 +106,7 @@ ## An array of characters containing the sense of each constraint in the ## constraint matrix. Each element of the array may be one of the ## following values +## ## @table @asis ## @item "F" ## A free (unbounded) constraint (the constraint is ignored). @@ -126,6 +127,7 @@ ## ## @item vartype ## A column array containing the types of the variables. +## ## @table @asis ## @item "C" ## A continuous variable. @@ -149,6 +151,7 @@ ## @table @code ## @item msglev (@w{@code{LPX_K_MSGLEV}}, default: 1) ## Level of messages output by solver routines: +## ## @table @asis ## @item 0 ## No output. @@ -165,6 +168,7 @@ ## ## @item scale (@w{@code{LPX_K_SCALE}}, default: 1) ## Scaling option: +## ## @table @asis ## @item 0 ## No scaling. @@ -178,6 +182,7 @@ ## ## @item dual (@w{@code{LPX_K_DUAL}}, default: 0) ## Dual simplex option: +## ## @table @asis ## @item 0 ## Do not use the dual simplex. @@ -188,6 +193,7 @@ ## ## @item price (@w{@code{LPX_K_PRICE}}, default: 1) ## Pricing option (for both primal and dual simplex): +## ## @table @asis ## @item 0 ## Textbook pricing. @@ -198,6 +204,7 @@ ## ## @item round (@w{@code{LPX_K_ROUND}}, default: 0) ## Solution rounding option: +## ## @table @asis ## @item 0 ## Report all primal and dual values "as is". @@ -219,6 +226,7 @@ ## ## @item branch (@w{@code{LPX_K_BRANCH}}, default: 2) ## Branching heuristic option (for MIP only): +## ## @table @asis ## @item 0 ## Branch on the first variable. @@ -232,6 +240,7 @@ ## ## @item btrack (@w{@code{LPX_K_BTRACK}}, default: 2) ## Backtracking heuristic option (for MIP only): +## ## @table @asis ## @item 0 ## Depth first search. @@ -250,6 +259,7 @@ ## @item lpsolver (default: 1) ## Select which solver to use. If the problem is a MIP problem this flag ## will be ignored. +## ## @table @asis ## @item 1 ## Revised simplex method. @@ -339,6 +349,7 @@ ## Status of the optimization. ## ## Simplex Method: +## ## @table @asis ## @item 180 (@w{@code{LPX_OPT}}) ## Solution is optimal. @@ -359,6 +370,7 @@ ## Solution status is undefined. ## @end table ## Interior Point Method: +## ## @table @asis ## @item 150 (@w{@code{LPX_T_UNDEF}}) ## The interior point method is undefined. @@ -367,6 +379,7 @@ ## The interior point method is optimal. ## @end table ## Mixed Integer Method: +## ## @table @asis ## @item 170 (@w{@code{LPX_I_UNDEF}}) ## The status is undefined. @@ -421,6 +434,7 @@ ## ## @item extra ## A data structure containing the following fields: +## ## @table @code ## @item lambda ## Dual variables.
--- a/scripts/optimization/lsqnonneg.m +++ b/scripts/optimization/lsqnonneg.m @@ -31,6 +31,7 @@ ## optional initial guess for @var{x}. ## ## Outputs: +## ## @itemize @bullet ## @item resnorm ## @@ -50,6 +51,7 @@ ## @item output ## ## A structure with two fields: +## ## @itemize @bullet ## @item "algorithm": The algorithm used ("nnls") ## @@ -198,14 +200,15 @@ endfunction -## Tests + %!test %! C = [1 0;0 1;2 1]; %! d = [1;3;-2]; -%! assert (lsqnonneg (C, d), [0;0.5], 100*eps) +%! assert (lsqnonneg (C, d), [0;0.5], 100*eps); %!test %! C = [0.0372 0.2869;0.6861 0.7071;0.6233 0.6245;0.6344 0.6170]; %! d = [0.8587;0.1781;0.0747;0.8405]; %! xnew = [0;0.6929]; -%! assert (lsqnonneg (C, d), xnew, 0.0001) +%! assert (lsqnonneg (C, d), xnew, 0.0001); +
--- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -25,6 +25,7 @@ ## Create options struct for optimization functions. ## ## Valid parameters are: +## ## @itemize @bullet ## @item AutoScaling ## @@ -141,8 +142,8 @@ endfunction -%!assert (optimget (optimset ('tolx', 1e-2), 'tOLx'), 1e-2) -%!assert (isfield (optimset ('tolFun', 1e-3), 'TolFun')) +%!assert (optimget (optimset ("tolx", 1e-2), "tOLx"), 1e-2) +%!assert (isfield (optimset ("tolFun", 1e-3), "TolFun")) %!error (optimset ("%NOT_A_REAL_FUNCTION_NAME%"))
--- a/scripts/optimization/pqpnonneg.m +++ b/scripts/optimization/pqpnonneg.m @@ -30,6 +30,7 @@ ## definite. @var{x0} is an optional initial guess for @var{x}. ## ## Outputs: +## ## @itemize @bullet ## @item minval ## @@ -45,6 +46,7 @@ ## @item output ## ## A structure with two fields: +## ## @itemize @bullet ## @item "algorithm": The algorithm used ("nnls") ## @@ -198,14 +200,15 @@ endfunction -## Tests + %!test %! C = [5 2;2 2]; %! d = [3; -1]; -%! assert (pqpnonneg (C, d), [0;0.5], 100*eps) +%! assert (pqpnonneg (C, d), [0;0.5], 100*eps); ## Test equivalence of lsq and pqp %!test %! C = rand (20, 10); %! d = rand (20, 1); -%! assert (pqpnonneg (C'*C, -C'*d), lsqnonneg (C, d), 100*eps) +%! assert (pqpnonneg (C'*C, -C'*d), lsqnonneg (C, d), 100*eps); +
--- a/scripts/optimization/qp.m +++ b/scripts/optimization/qp.m @@ -33,8 +33,8 @@ ## ## @example ## @group -## min 0.5 x'*H*x + x'*q -## x +## min 0.5 x'*H*x + x'*q +## x ## @end group ## @end example ## @@ -49,9 +49,9 @@ ## ## @example ## @group -## A*x = b -## lb <= x <= ub -## A_lb <= A_in*x <= A_ub +## A*x = b +## lb <= x <= ub +## A_lb <= A_in*x <= A_ub ## @end group ## @end example ##
--- a/scripts/optimization/sqp.m +++ b/scripts/optimization/sqp.m @@ -33,8 +33,8 @@ ## ## @example ## @group -## min phi (x) -## x +## min phi (x) +## x ## @end group ## @end example ## @@ -49,9 +49,9 @@ ## ## @example ## @group -## g(x) = 0 -## h(x) >= 0 -## lb <= x <= ub +## g(x) = 0 +## h(x) >= 0 +## lb <= x <= ub ## @end group ## @end example ## @@ -102,9 +102,9 @@ ## ## @example ## @group -## [ d f(x) d f(x) d f(x) ] -## transpose ( [ ------ ----- ... ------ ] ) -## [ dx_1 dx_2 dx_N ] +## [ d f(x) d f(x) d f(x) ] +## transpose ( [ ------ ----- ... ------ ] ) +## [ dx_1 dx_2 dx_N ] ## @end group ## @end example ## @@ -155,7 +155,7 @@ ## endfunction ## ## function obj = phi (x) -## obj = exp(prod(x)) - 0.5*(x(1)^3+x(2)^3+1)^2; +## obj = exp (prod (x)) - 0.5*(x(1)^3+x(2)^3+1)^2; ## endfunction ## ## x0 = [-1.8; 1.7; 1.9; -0.8; -0.8]; @@ -733,6 +733,7 @@ endfunction + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Test Code @@ -743,7 +744,7 @@ %!endfunction %! %!function obj = __phi (x) -%! obj = exp(prod(x)) - 0.5*(x(1)^3+x(2)^3+1)^2; +%! obj = exp (prod (x)) - 0.5*(x(1)^3 + x(2)^3 + 1)^2; %!endfunction %! %!test @@ -760,22 +761,23 @@ %! %! obj_opt = 0.0539498477702739; %! -%! assert (all (abs (x-x_opt) < 5*sqrt (eps)) && abs (obj-obj_opt) < sqrt (eps)); +%! assert (x, x_opt, 5*sqrt (eps)); +%! assert (obj, obj_opt, sqrt (eps)); %% Test input validation %!error sqp () %!error sqp (1) %!error sqp (1,2,3,4,5,6,7,8,9) %!error sqp (1,2,3,4,5) -%!error sqp (ones(2,2)) -%!error sqp (1,cell(4,1)) -%!error sqp (1,cell(3,1),cell(3,1)) -%!error sqp (1,cell(3,1),cell(2,1),cell(3,1)) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),ones(2,2),[]) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],ones(2,2)) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),1,-1) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],ones(2,2)) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],-1) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],1.5) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],[],ones(2,2)) -%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],[],-1) +%!error sqp (ones (2,2)) +%!error sqp (1, cell (4,1)) +%!error sqp (1, cell (3,1), cell (3,1)) +%!error sqp (1, cell (3,1), cell (2,1), cell (3,1)) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1), ones (2,2),[]) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[], ones (2,2)) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),1,-1) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[], ones (2,2)) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],-1) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],1.5) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],[], ones (2,2)) +%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],[],-1)
--- a/scripts/path/matlabroot.m +++ b/scripts/path/matlabroot.m @@ -32,5 +32,6 @@ endfunction -%!assert (matlabroot(), OCTAVE_HOME()) +%!assert (matlabroot (), OCTAVE_HOME ()) +
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -136,7 +136,7 @@ ## [user_packages, system_packages] = pkg ("list") ## @end example ## -## The option '-forge' lists packages available at the Octave-Forge repository. +## The option "-forge" lists packages available at the Octave-Forge repository. ## This requires an internet connection and the cURL library. For example: ## ## @example @@ -145,7 +145,7 @@ ## ## @item describe ## Show a short description of the named installed packages, with the option -## '-verbose' also list functions provided by the package. For example, +## "-verbose" also list functions provided by the package. For example, ## ## @example ## pkg describe -verbose all
--- a/scripts/plot/__gnuplot_drawnow__.m +++ b/scripts/plot/__gnuplot_drawnow__.m @@ -390,3 +390,4 @@ ## No test needed for internal helper function. %!assert (1) +
--- a/scripts/plot/__plt_get_axis_arg__.m +++ b/scripts/plot/__plt_get_axis_arg__.m @@ -80,3 +80,4 @@ ## No test needed for internal helper function. %!assert (1) +
--- a/scripts/plot/ancestor.m +++ b/scripts/plot/ancestor.m @@ -18,7 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}) -## @deftypefnx {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}, 'toplevel') +## @deftypefnx {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}, "toplevel") ## Return the first ancestor of handle object @var{h} whose type matches ## @var{type}, where @var{type} is a character string. If @var{type} is a ## cell array of strings, return the first parent whose type matches @@ -75,6 +75,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -84,3 +85,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/bar.m +++ b/scripts/plot/bar.m @@ -66,8 +66,8 @@ ## ## @example ## @group -## bar (rand(10,3)) -## colormap (summer ()) +## bar (rand (10, 3)); +## colormap (summer (64)); ## @end group ## @end example ## @@ -77,7 +77,7 @@ ## ## @example ## @group -## h = bar (rand(10,3)) +## h = bar (rand (10, 3)); ## set (h(1), "facecolor", "r") ## set (h(2), "facecolor", "g") ## set (h(3), "facecolor", "b")
--- a/scripts/plot/caxis.m +++ b/scripts/plot/caxis.m @@ -26,8 +26,8 @@ ## colormap. Values outside this range are clamped to the first and last ## colormap entries. ## -## If @var{limits} is 'auto', then automatic colormap scaling is applied, -## whereas if @var{limits} is 'manual' the colormap scaling is set to manual. +## If @var{limits} is "auto", then automatic colormap scaling is applied, +## whereas if @var{limits} is "manual" the colormap scaling is set to manual. ## ## Called without any arguments to current color axis limits are returned. ##
--- a/scripts/plot/cla.m +++ b/scripts/plot/cla.m @@ -89,14 +89,16 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! plot (1:10) -%! cla () +%! plot (1:10); +%! cla (); %! kids = get (gca, "children"); -%! cla () +%! cla (); %! unwind_protect_cleanup -%! close (hf) +%! close (hf); %! end_unwind_protect -%! assert (numel (kids), 0) +%! assert (numel (kids), 0); +
--- a/scripts/plot/clabel.m +++ b/scripts/plot/clabel.m @@ -48,8 +48,8 @@ ## ## @example ## @group -## [c, h] = contour (peaks(), -4 : 6); -## clabel (c, h, -4 : 2 : 6, 'fontsize', 12); +## [c, h] = contour (peaks (), -4 : 6); +## clabel (c, h, -4:2:6, "fontsize", 12); ## @end group ## @end example ##
--- a/scripts/plot/clf.m +++ b/scripts/plot/clf.m @@ -89,7 +89,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! l = line; -%! assert (!isempty (get (gcf, "children"))); +%! assert (! isempty (get (gcf, "children"))); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect
--- a/scripts/plot/close.m +++ b/scripts/plot/close.m @@ -80,6 +80,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -91,3 +92,4 @@ %! close (hf); %! endif %! end_unwind_protect +
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -382,7 +382,7 @@ %! colormap ('default'); %! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); %! imagesc (x); -%! colorbar ('peer', gca (), 'northoutside'); +%! colorbar ('peer', gca, 'northoutside'); %!demo %! clf;
--- a/scripts/plot/colstyle.m +++ b/scripts/plot/colstyle.m @@ -64,6 +64,7 @@ endfunction + %!test %! [l, c, m, msg] = colstyle ("r:x"); %! assert (isempty (msg));
--- a/scripts/plot/comet3.m +++ b/scripts/plot/comet3.m @@ -84,5 +84,5 @@ %!demo %! clf; %! t = 0:pi/20:5*pi; -%! comet3 (cos(t), sin(t), t, 0.01); +%! comet3 (cos (t), sin (t), t, 0.01);
--- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -37,7 +37,7 @@ ## @example ## @group ## a = toeplitz ([1;randn(9,1)], [1,randn(1,9)]); -## compass (eig (a)) +## compass (eig (a)); ## @end group ## @end example ##
--- a/scripts/plot/contour3.m +++ b/scripts/plot/contour3.m @@ -34,8 +34,8 @@ ## @group ## contour3 (peaks (19)); ## hold on -## surface (peaks (19), "facecolor", "none", "EdgeColor", "black") -## colormap hot +## surface (peaks (19), "facecolor", "none", "EdgeColor", "black"); +## colormap hot; ## @end group ## @end example ##
--- a/scripts/plot/contourc.m +++ b/scripts/plot/contourc.m @@ -50,9 +50,8 @@ ## y = x; ## z = x' * y; ## contourc (x, y, z, 2:3) -## @result{} 2.0000 2.0000 1.0000 3.0000 1.5000 2.0000 -## 2.0000 1.0000 2.0000 2.0000 2.0000 1.5000 -## +## @result{} 2.0000 2.0000 1.0000 3.0000 1.5000 2.0000 +## 2.0000 1.0000 2.0000 2.0000 2.0000 1.5000 ## @end group ## @end example ## @seealso{contour} @@ -141,6 +140,7 @@ endfunction + %!test %! x = 0:2; %! y = x; @@ -148,7 +148,6 @@ %! [c_actual, lev_actual]= contourc (x, y, z, 2:3); %! c_expected = [2, 1, 1, 2, 2, 3, 1.5, 2; 4, 2, 2, 1, 1, 2, 2, 1.5]; %! lev_expected = [2 3]; -%! assert (c_actual, c_expected, eps) -%! assert (lev_actual, lev_expected, eps) +%! assert (c_actual, c_expected, eps); +%! assert (lev_actual, lev_expected, eps); -
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -38,9 +38,9 @@ ## ## @example ## @group -## [x, y, z] = cylinder (10:-1:0,50); +## [x, y, z] = cylinder (10:-1:0, 50); ## surf (x, y, z); -## title ("a cone") +## title ("a cone"); ## @end group ## @end example ## @seealso{sphere}
--- a/scripts/plot/ezcontour.m +++ b/scripts/plot/ezcontour.m @@ -39,7 +39,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezcontour (f, [-3, 3]); ## @end group ## @end example
--- a/scripts/plot/ezcontourf.m +++ b/scripts/plot/ezcontourf.m @@ -39,7 +39,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezcontourf (f, [-3, 3]); ## @end group ## @end example
--- a/scripts/plot/ezmesh.m +++ b/scripts/plot/ezmesh.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} ezmesh (@var{fx}, @var{fy}, @var{fz}) ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{dom}) ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{n}) -## @deftypefnx {Function File} {} ezmesh (@dots{}, 'circ') +## @deftypefnx {Function File} {} ezmesh (@dots{}, "circ") ## @deftypefnx {Function File} {} ezmesh (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ezmesh (@dots{}) ## @@ -41,7 +41,7 @@ ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), ## @var{fz} (@var{s}, @var{t})]}. ## -## If the argument 'circ' is given, then the function is plotted over a disk +## If the argument "circ" is given, then the function is plotted over a disk ## centered on the middle of the domain @var{dom}. ## ## The optional return value @var{h} is a graphics handle to the created @@ -49,7 +49,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezmesh (f, [-3, 3]); ## @end group ## @end example
--- a/scripts/plot/ezmeshc.m +++ b/scripts/plot/ezmeshc.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} ezmeshc (@var{fx}, @var{fy}, @var{fz}) ## @deftypefnx {Function File} {} ezmeshc (@dots{}, @var{dom}) ## @deftypefnx {Function File} {} ezmeshc (@dots{}, @var{n}) -## @deftypefnx {Function File} {} ezmeshc (@dots{}, 'circ') +## @deftypefnx {Function File} {} ezmeshc (@dots{}, "circ") ## @deftypefnx {Function File} {} ezmeshc (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ezmeshc (@dots{}) ## @@ -41,7 +41,7 @@ ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), ## @var{fz} (@var{s}, @var{t})]}. ## -## If the argument 'circ' is given, then the function is plotted over a disk +## If the argument "circ" is given, then the function is plotted over a disk ## centered on the middle of the domain @var{dom}. ## ## The optional return value @var{h} is a 2-element vector with a graphics @@ -50,7 +50,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezmeshc (f, [-3, 3]); ## @end group ## @end example
--- a/scripts/plot/ezplot.m +++ b/scripts/plot/ezplot.m @@ -35,7 +35,7 @@ ## < 2*pi} with 60 by 60 in the mesh. For example: ## ## @example -## ezplot (@@(@var{x}, @var{y}) @var{x} .^ 2 - @var{y} .^ 2 - 1) +## ezplot (@@(@var{x}, @var{y}) @var{x}.^2 - @var{y}.^2 - 1) ## @end example ## ## If two functions are passed as strings, inline functions or function
--- a/scripts/plot/ezsurf.m +++ b/scripts/plot/ezsurf.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} ezsurf (@var{fx}, @var{fy}, @var{fz}) ## @deftypefnx {Function File} {} ezsurf (@dots{}, @var{dom}) ## @deftypefnx {Function File} {} ezsurf (@dots{}, @var{n}) -## @deftypefnx {Function File} {} ezsurf (@dots{}, 'circ') +## @deftypefnx {Function File} {} ezsurf (@dots{}, "circ") ## @deftypefnx {Function File} {} ezsurf (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ezsurf (@dots{}) ## @@ -41,7 +41,7 @@ ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), ## @var{fz} (@var{s}, @var{t})]}. ## -## If the argument 'circ' is given, then the function is plotted over a disk +## If the argument "circ" is given, then the function is plotted over a disk ## centered on the middle of the domain @var{dom}. ## ## The optional return value @var{h} is a graphics handle to the created @@ -49,7 +49,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezsurf (f, [-3, 3]); ## @end group ## @end example @@ -58,9 +58,9 @@ ## ## @example ## @group -## fx = @@(s,t) cos (s) .* cos(t); -## fy = @@(s,t) sin (s) .* cos(t); -## fz = @@(s,t) sin(t); +## fx = @@(s,t) cos (s) .* cos (t); +## fy = @@(s,t) sin (s) .* cos (t); +## fz = @@(s,t) sin (t); ## ezsurf (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20); ## @end group ## @end example
--- a/scripts/plot/ezsurfc.m +++ b/scripts/plot/ezsurfc.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} ezsurfc (@var{fx}, @var{fy}, @var{fz}) ## @deftypefnx {Function File} {} ezsurfc (@dots{}, @var{dom}) ## @deftypefnx {Function File} {} ezsurfc (@dots{}, @var{n}) -## @deftypefnx {Function File} {} ezsurfc (@dots{}, 'circ') +## @deftypefnx {Function File} {} ezsurfc (@dots{}, "circ") ## @deftypefnx {Function File} {} ezsurfc (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ezsurfc (@dots{}) ## @@ -41,7 +41,7 @@ ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}), ## @var{fz} (@var{s}, @var{t})]}. ## -## If the argument 'circ' is given, then the function is plotted over a disk +## If the argument "circ" is given, then the function is plotted over a disk ## centered on the middle of the domain @var{dom}. ## ## The optional return value @var{h} is a 2-element vector with a graphics @@ -50,7 +50,7 @@ ## ## @example ## @group -## f = @@(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2); +## f = @@(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ## ezsurfc (f, [-3, 3]); ## @end group ## @end example
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -36,8 +36,8 @@ ## ## @example ## @group -## phi = [0 : 15 : 360] * pi / 180; -## feather (sin (phi), cos (phi)) +## phi = [0 : 15 : 360] * pi/180; +## feather (sin (phi), cos (phi)); ## @end group ## @end example ##
--- a/scripts/plot/figure.m +++ b/scripts/plot/figure.m @@ -17,8 +17,10 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} figure (@var{n}) -## @deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{}) +## @deftypefn {Command} {} figure +## @deftypefnx {Command} {} figure @var{n} +## @deftypefnx {Function File} {} figure (@var{n}) +## @deftypefnx {Function File} {} figure (@var{n}, "@var{property}", @var{value}, @dots{}) ## Set the current plot window to plot window @var{n}. If no arguments are ## specified, the next available window number is chosen. ## @@ -37,6 +39,9 @@ init_new_figure = false; if (mod (nargs, 2) == 1) tmp = varargin{1}; + if (ischar (tmp)) + tmp = str2double (tmp); + endif if (isfigure (tmp)) f = tmp; varargin(1) = []; @@ -54,7 +59,7 @@ ## Check to see if we already have a figure on the screen. If we do, ## then update it if it is different from the figure we are creating ## or switching to. - cf = get (0, "currentfigure"); + cf = get (0, "currentfigure"); # Can't use gcf() because it calls figure() if (! isempty (cf) && cf != 0) if (isnan (f) || cf != f) drawnow (); @@ -64,7 +69,7 @@ if (rem (nargs, 2) == 0) if (isnan (f) || init_new_figure) if (ismac () && strcmp (graphics_toolkit (), "fltk")) - ## FIXME - Hack for fltk-aqua to work around bug # 31931 + ## FIXME - Hack for fltk-aqua to work around bug #31931 f = __go_figure__ (f); drawnow (); if (! isempty (varargin)) @@ -81,9 +86,8 @@ print_usage (); endif - cf = get (0, "currentfigure"); - if (strcmp (get (cf, "__graphics_toolkit__"), "fltk")) - __add_default_menu__ (cf); + if (strcmp (get (f, "__graphics_toolkit__"), "fltk")) + __add_default_menu__ (f); endif if (nargout > 0) @@ -92,6 +96,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -100,3 +105,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/findobj.m +++ b/scripts/plot/findobj.m @@ -19,44 +19,44 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{h} =} findobj () ## @deftypefnx {Function File} {@var{h} =} findobj (@var{prop_name}, @var{prop_value}) -## @deftypefnx {Function File} {@var{h} =} findobj ('-property', @var{prop_name}) -## @deftypefnx {Function File} {@var{h} =} findobj ('-regexp', @var{prop_name}, @var{pattern}) -## @deftypefnx {Function File} {@var{h} =} findobj ('flat', @dots{}) +## @deftypefnx {Function File} {@var{h} =} findobj ("-property", @var{prop_name}) +## @deftypefnx {Function File} {@var{h} =} findobj ("-regexp", @var{prop_name}, @var{pattern}) +## @deftypefnx {Function File} {@var{h} =} findobj ("flat", @dots{}) ## @deftypefnx {Function File} {@var{h} =} findobj (@var{h}, @dots{}) -## @deftypefnx {Function File} {@var{h} =} findobj (@var{h}, '-depth', @var{d}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} findobj (@var{h}, "-depth", @var{d}, @dots{}) ## Find graphics object with specified property values. The simplest form is ## ## @example -## findobj (@var{prop_name}, @var{prop_Value}) +## findobj (@var{prop_name}, @var{prop_value}) ## @end example ## ## @noindent ## which returns all of the handles to the objects with the name -## @var{prop_name} and the name @var{prop_Value}. The search can be limited +## @var{prop_name} and the name @var{prop_value}. The search can be limited ## to a particular object or set of objects and their descendants by ## passing a handle or set of handles @var{h} as the first argument to ## @code{findobj}. ## ## The depth of hierarchy of objects to which to search to can be limited -## with the '-depth' argument. To limit the number depth of the hierarchy +## with the "-depth" argument. To limit the number depth of the hierarchy ## to search to @var{d} generations of children, and example is ## ## @example -## findobj (@var{h}, '-depth', @var{d}, @var{prop_Name}, @var{prop_Value}) +## findobj (@var{h}, "-depth", @var{d}, @var{prop_name}, @var{prop_value}) ## @end example ## ## Specifying a depth @var{d} of 0, limits the search to the set of object -## passed in @var{h}. A depth @var{d} of 0 is equivalent to the '-flat' +## passed in @var{h}. A depth @var{d} of 0 is equivalent to the "-flat" ## argument. ## -## A specified logical operator may be applied to the pairs of @var{prop_Name} -## and @var{prop_Value}. The supported logical operators are '-and', '-or', -## '-xor', '-not'. +## A specified logical operator may be applied to the pairs of @var{prop_name} +## and @var{prop_value}. The supported logical operators are "-and", "-or", +## "-xor", "-not". ## ## The objects may also be matched by comparing a regular expression to the ## property values, where property values that match @code{regexp -## (@var{prop_Value}, @var{pattern})} are returned. Finally, objects may be -## matched by property name only, using the '-property' option. +## (@var{prop_value}, @var{pattern})} are returned. Finally, objects may be +## matched by property name only, using the "-property" option. ## @seealso{get, set} ## @end deftypefn
--- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -33,8 +33,8 @@ ## ## @example ## @group -## fplot ("cos", [0, 2*pi]) -## fplot ("[cos(x), sin(x)]", [0, 2*pi]) +## fplot ("cos", [0, 2*pi]) +## fplot ("[cos(x), sin(x)]", [0, 2*pi]) ## @end group ## @end example ## @seealso{plot}
--- a/scripts/plot/gca.m +++ b/scripts/plot/gca.m @@ -50,6 +50,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! ax = axes; @@ -58,3 +59,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/gcbf.m +++ b/scripts/plot/gcbf.m @@ -32,5 +32,6 @@ endfunction -%!test -%! assert (isempty (gcbf )); + +%!assert (isempty (gcbf)) +
--- a/scripts/plot/gcbo.m +++ b/scripts/plot/gcbo.m @@ -42,5 +42,7 @@ endfunction + %!test -%! assert (isempty (gcbo )); +%! assert (isempty (gcbo)); +
--- a/scripts/plot/gcf.m +++ b/scripts/plot/gcf.m @@ -54,6 +54,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -61,3 +62,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/ginput.m +++ b/scripts/plot/ginput.m @@ -43,6 +43,8 @@ endfunction + ## Remove from test statistics. No real tests possible. %!test %! assert (1); +
--- a/scripts/plot/graphics_toolkit.m +++ b/scripts/plot/graphics_toolkit.m @@ -83,13 +83,13 @@ %! end_unwind_protect %!testif HAVE_FLTK -%! old_toolkit = graphics_toolkit (); -%! switch old_toolkit -%! case {"gnuplot"} -%! new_toolkit = "fltk"; -%! otherwise -%! new_toolkit = "gnuplot"; -%! endswitch -%! assert (graphics_toolkit (new_toolkit), old_toolkit) -%! assert (graphics_toolkit (old_toolkit), new_toolkit) +%! old_toolkit = graphics_toolkit (); +%! switch old_toolkit +%! case {"gnuplot"} +%! new_toolkit = "fltk"; +%! otherwise +%! new_toolkit = "gnuplot"; +%! endswitch +%! assert (graphics_toolkit (new_toolkit), old_toolkit); +%! assert (graphics_toolkit (old_toolkit), new_toolkit);
--- a/scripts/plot/gtext.m +++ b/scripts/plot/gtext.m @@ -44,6 +44,7 @@ endfunction + ## Remove from test statistics. No real tests possible. -%!test -%! assert (1); +%!assert (1) +
--- a/scripts/plot/hggroup.m +++ b/scripts/plot/hggroup.m @@ -42,6 +42,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -51,3 +52,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/hidden.m +++ b/scripts/plot/hidden.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} hidden () ## Manipulation the mesh hidden line removal. Called with no argument ## the hidden line removal is toggled. The argument @var{mode} can be either -## 'on' or 'off' and the set of the hidden line removal is set accordingly. +## "on" or "off" and the set of the hidden line removal is set accordingly. ## @seealso{mesh, meshc, surf} ## @end deftypefn
--- a/scripts/plot/hist.m +++ b/scripts/plot/hist.m @@ -51,7 +51,7 @@ ## ## @example ## @group -## hist (randn (1, 100), 25, "facecolor", "r", "edgecolor", "b") +## hist (randn (1, 100), 25, "facecolor", "r", "edgecolor", "b"); ## @end group ## @end example ## @@ -60,8 +60,8 @@ ## ## @example ## @group -## hist (rand (10, 3)) -## colormap (summer ()) +## hist (rand (10, 3)); +## colormap (summer ()); ## @end group ## @end example ## @@ -168,30 +168,31 @@ endfunction + %!test -%! [nn,xx]=hist([1:4],3); -%! assert(xx, [1.5,2.5,3.5]); -%! assert(nn, [2,1,1]); +%! [nn,xx] = hist ([1:4], 3); +%! assert (xx, [1.5,2.5,3.5]); +%! assert (nn, [2,1,1]); %!test -%! [nn,xx]=hist([1:4]',3); -%! assert(xx, [1.5,2.5,3.5]); -%! assert(nn, [2,1,1]); +%! [nn,xx] = hist ([1:4]', 3); +%! assert (xx, [1.5,2.5,3.5]); +%! assert (nn, [2,1,1]); %!test -%! [nn,xx]=hist([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]); -%! assert(xx, [1,2,3]); -%! assert(nn, [3,2,1]); +%! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]); +%! assert (xx, [1,2,3]); +%! assert (nn, [3,2,1]); %!test -%! [nn,xx]=hist([[1:4]',[1:4]'],3); -%! assert(xx, [1.5;2.5;3.5]); -%! assert(nn, [[2,1,1]',[2,1,1]']); -%!assert(hist(1,1),1); +%! [nn,xx] = hist ([[1:4]', [1:4]'], 3); +%! assert (xx, [1.5;2.5;3.5]); +%! assert (nn, [[2,1,1]',[2,1,1]']); %!test -%! for n = [10, 30, 100, 1000] -%! assert(sum(hist([1:n], n)), n); -%! assert(sum(hist([1:n], [2:n-1])), n); -%! assert(sum(hist([1:n], [1:n])), n); -%! assert(sum(hist([1:n], 29)), n); -%! assert(sum(hist([1:n], 30)), n); -%! endfor -%!test -%! assert (size (hist(randn(750,240), 200)), [200,240]); +%! for n = [10, 30, 100, 1000] +%! assert (sum (hist ([1:n], n)), n); +%! assert (sum (hist ([1:n], [2:n-1])), n); +%! assert (sum (hist ([1:n], [1:n])), n); +%! assert (sum (hist ([1:n], 29)), n); +%! assert (sum (hist ([1:n], 30)), n); +%! endfor +%!assert (hist (1,1), 1) +%!assert (size (hist (randn (750,240), 200)), [200,240]) +
--- a/scripts/plot/hold.m +++ b/scripts/plot/hold.m @@ -20,7 +20,7 @@ ## @deftypefn {Command} {} hold ## @deftypefnx {Command} {} hold @var{state} ## @deftypefnx {Function File} {} hold (@var{hax}, @dots{}) -## Toggle or set the 'hold' state of the plotting engine which determines +## Toggle or set the "hold" state of the plotting engine which determines ## whether new graphic objects are added to the plot or replace the existing ## objects. ## @@ -39,13 +39,13 @@ ## command. (default). ## ## @item hold -## Toggle the current 'hold' state. +## Toggle the current hold state. ## @end table ## ## When given the additional argument @var{hax}, the hold state is modified ## only for the given axis handle. ## -## To query the current 'hold' state use the @code{ishold} function. +## To query the current hold state use the @code{ishold} function. ## @seealso{ishold, cla, newplot, clf} ## @end deftypefn @@ -136,7 +136,7 @@ %! z = peaks (x, y); %! contourf (x, y, z, 10); %! hold on; -%! plot (vec (x), vec (y), '^'); +%! plot (x(:), y(:), '^'); %! patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], 'red'); %! xlim ([-2.0 2.0]); %! ylim ([-2.0 2.0]); @@ -151,7 +151,7 @@ %! assert (! ishold); %! hold on; %! assert (ishold); -%! p1 = fill ([0 1 1], [0 0 1],"black"); +%! p1 = fill ([0 1 1], [0 0 1], "black"); %! p2 = fill ([0 1 0], [0 1 1], "red"); %! assert (length (get (hf, "children")), 1); %! assert (length (get (gca, "children")), 3); @@ -167,7 +167,7 @@ %! assert (! ishold); %! hold on; %! assert (ishold); -%! p1 = fill ([0 1 1], [0 0 1],"black"); +%! p1 = fill ([0 1 1], [0 0 1], "black"); %! hold off; %! p2 = fill ([0 1 0], [0 1 1], "red"); %! assert (length (get (hf, "children")), 1);
--- a/scripts/plot/isfigure.m +++ b/scripts/plot/isfigure.m @@ -35,11 +35,13 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect %! assert (isfigure (hf)); -%! assert (!isfigure (-hf)); +%! assert (! isfigure (-hf)); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/ishghandle.m +++ b/scripts/plot/ishghandle.m @@ -27,32 +27,33 @@ retval = ishandle (h); endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect %! assert (ishghandle (hf)); -%! assert (!ishghandle (-hf)); +%! assert (! ishghandle (-hf)); %! l = line; -%! ax = gca(); +%! ax = gca; %! assert (ishghandle (ax)); -%! assert (!ishghandle (-ax)); +%! assert (! ishghandle (-ax)); %! assert (ishghandle (l)); -%! assert (!ishghandle (-l)); +%! assert (! ishghandle (-l)); %! p = patch; %! assert (ishghandle (p)); -%! assert (!ishghandle (-p)); +%! assert (! ishghandle (-p)); %! s = surface; %! assert (ishghandle (s)); -%! assert (!ishghandle (-s)); +%! assert (! ishghandle (-s)); %! t = text; %! assert (ishghandle (t)); -%! assert (!ishghandle (-t)); +%! assert (! ishghandle (-t)); %! i = image; %! assert (ishghandle (i)); -%! assert (!ishghandle (-i)); +%! assert (! ishghandle (-i)); %! hg = hggroup; %! assert (ishghandle (hg)); -%! assert (!ishghandle (-hg)); +%! assert (! ishghandle (-hg)); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect
--- a/scripts/plot/ishold.m +++ b/scripts/plot/ishold.m @@ -55,15 +55,16 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! assert (!ishold); +%! assert (! ishold); %! assert (isempty (get (hf, "currentaxes"))); %! assert (get (hf, "NextPlot"), "add"); %! l = plot ([0 1]); -%! assert (!ishold); -%! assert (!ishold (gca)); +%! assert (! ishold); +%! assert (! ishold (gca)); %! assert (get (gca, "NextPlot"), "replace"); %! assert (get (hf, "NextPlot"), "add"); %! hold; @@ -77,3 +78,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/isocolors.m +++ b/scripts/plot/isocolors.m @@ -50,43 +50,43 @@ ## ## @example ## function [] = isofinish (p) -## set (gca, "PlotBoxAspectRatioMode", "manual", \ -## "PlotBoxAspectRatio", [1 1 1]); +## set (gca, "PlotBoxAspectRatioMode", "manual", ... +## "PlotBoxAspectRatio", [1 1 1]); ## set (p, "FaceColor", "interp"); ## ## set (p, "FaceLighting", "flat"); ## ## light ("Position", [1 1 5]); ## Available with JHandles ## endfunction ## -## N = 15; ## Increase number of vertices in each direction -## iso = .4; ## Change isovalue to .1 to display a sphere +## N = 15; # Increase number of vertices in each direction +## iso = .4; # Change isovalue to .1 to display a sphere ## lin = linspace (0, 2, N); ## [x, y, z] = meshgrid (lin, lin, lin); ## c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); -## figure (); ## Open another figure window +## figure (); # Open another figure window ## -## subplot (2, 2, 1); view (-38, 20); +## subplot (2,2,1); view (-38, 20); ## [f, v] = isosurface (x, y, z, c, iso); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); -## cdat = rand (size (c)); ## Compute random patch color data -## isocolors (x, y, z, cdat, p); ## Directly set colors of patch -## isofinish (p); ## Call user function isofinish +## cdat = rand (size (c)); # Compute random patch color data +## isocolors (x, y, z, cdat, p); # Directly set colors of patch +## isofinish (p); # Call user function isofinish ## -## subplot (2, 2, 2); view (-38, 20); +## subplot (2,2,2); view (-38, 20); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); ## [r, g, b] = meshgrid (lin, 2-lin, 2-lin); -## cdat = isocolors (x, y, z, c, v); ## Compute color data vertices -## set (p, "FaceVertexCData", cdat); ## Set color data manually +## cdat = isocolors (x, y, z, c, v); # Compute color data vertices +## set (p, "FaceVertexCData", cdat); # Set color data manually ## isofinish (p); ## -## subplot (2, 2, 3); view (-38, 20); +## subplot (2,2,3); view (-38, 20); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); -## cdat = isocolors (r, g, b, c, p); ## Compute color data patch -## set (p, "FaceVertexCData", cdat); ## Set color data manually +## cdat = isocolors (r, g, b, c, p); # Compute color data patch +## set (p, "FaceVertexCData", cdat); # Set color data manually ## isofinish (p); ## -## subplot (2, 2, 4); view (-38, 20); +## subplot (2,2,4); view (-38, 20); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); -## r = g = b = repmat ([1:N] / N, [N, 1, N]); ## Black to white +## r = g = b = repmat ([1:N] / N, [N, 1, N]); # Black to white ## cdat = isocolors (x, y, z, r, g, b, v); ## set (p, "FaceVertexCData", cdat); ## isofinish (p); @@ -163,10 +163,12 @@ endswitch endfunction + %!test -%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); -%! c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2; -%! [f, v] = isosurface (x, y, z, c, .4); -%! cdat = isocolors (x, y, z, c, v); -%! assert (size (cdat, 1) == size (v, 1)); +%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); +%! c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2; +%! [f, v] = isosurface (x, y, z, c, .4); +%! cdat = isocolors (x, y, z, c, v); +%! assert (rows (cdat) == rows (v)); ## Can't create a patch handle for tests without a figure +
--- a/scripts/plot/isonormals.m +++ b/scripts/plot/isonormals.m @@ -50,8 +50,8 @@ ## @smallexample ## function [] = isofinish (p) ## set (gca, "PlotBoxAspectRatioMode", "manual", ... -## "PlotBoxAspectRatio",[1 1 1]); -## set (p, "VertexNormals", -get(p,"VertexNormals")); # Revert normals +## "PlotBoxAspectRatio", [1 1 1]); +## set (p, "VertexNormals", -get (p,"VertexNormals")); # Revert normals ## set (p, "FaceColor", "interp"); ## ## set (p, "FaceLighting", "phong"); ## ## light ("Position", [1 1 5]); # Available with JHandles @@ -64,27 +64,27 @@ ## c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); ## figure (); # Open another figure window ## -## subplot (2, 2, 1); view (-38, 20); +## subplot (2,2,1); view (-38, 20); ## [f, v, cdat] = isosurface (x, y, z, c, iso, y); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... ## "FaceColor", "interp", "EdgeColor", "none"); ## isofinish (p); ## Call user function isofinish ## -## subplot (2, 2, 2); view (-38, 20); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ +## subplot (2,2,2); view (-38, 20); +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... ## "FaceColor", "interp", "EdgeColor", "none"); ## isonormals (x, y, z, c, p); # Directly modify patch ## isofinish (p); ## -## subplot (2, 2, 3); view (-38, 20); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ +## subplot (2,2,3); view (-38, 20); +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... ## "FaceColor", "interp", "EdgeColor", "none"); ## n = isonormals (x, y, z, c, v); # Compute normals of isosurface ## set (p, "VertexNormals", n); # Manually set vertex normals ## isofinish (p); ## -## subplot (2, 2, 4); view (-38, 20); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ +## subplot (2,2,4); view (-38, 20); +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... ## "FaceColor", "interp", "EdgeColor", "none"); ## isonormals (x, y, z, c, v, "negate"); # Use reverse directly ## isofinish (p); @@ -148,16 +148,18 @@ endswitch endfunction + %!test -%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); -%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); -%! [f, v, cdat] = isosurface (x, y, z, c, .4, y); -%! n = isonormals (x, y, z, c, v); -%! assert (size (v), size (n)); +%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); +%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); +%! [f, v, cdat] = isosurface (x, y, z, c, .4, y); +%! n = isonormals (x, y, z, c, v); +%! assert (size (v), size (n)); %!test -%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); -%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); -%! [f, v, cdat] = isosurface (x, y, z, c, .4, y); -%! np = isonormals (x, y, z, c, v); -%! nn = isonormals (x, y, z, c, v, "negate"); -%! assert (all (np == -nn)); +%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); +%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); +%! [f, v, cdat] = isosurface (x, y, z, c, .4, y); +%! np = isonormals (x, y, z, c, v); +%! nn = isonormals (x, y, z, c, v, "negate"); +%! assert (np, -nn); +
--- a/scripts/plot/isosurface.m +++ b/scripts/plot/isosurface.m @@ -80,34 +80,34 @@ ## c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); ## figure (); # Open another figure window ## -## subplot (2, 2, 1); view (-38, 20); +## subplot (2,2,1); view (-38, 20); ## [f, v] = isosurface (x, y, z, c, iso); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); -## set (gca, "PlotBoxAspectRatioMode","manual", ... +## set (gca, "PlotBoxAspectRatioMode", "manual", ... ## "PlotBoxAspectRatio", [1 1 1]); ## # set (p, "FaceColor", "green", "FaceLighting", "phong"); ## # light ("Position", [1 1 5]); # Available with the JHandles package ## -## subplot (2, 2, 2); view (-38, 20); +## subplot (2,2,2); view (-38, 20); ## p = patch ("Faces", f, "Vertices", v, "EdgeColor", "blue"); -## set (gca, "PlotBoxAspectRatioMode","manual", ... +## set (gca, "PlotBoxAspectRatioMode", "manual", ... ## "PlotBoxAspectRatio", [1 1 1]); ## # set (p, "FaceColor", "none", "FaceLighting", "phong"); ## # light ("Position", [1 1 5]); ## -## subplot (2, 2, 3); view (-38, 20); +## subplot (2,2,3); view (-38, 20); ## [f, v, c] = isosurface (x, y, z, c, iso, y); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, \ +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, ... ## "FaceColor", "interp", "EdgeColor", "none"); -## set (gca, "PlotBoxAspectRatioMode","manual", ... +## set (gca, "PlotBoxAspectRatioMode", "manual", ... ## "PlotBoxAspectRatio", [1 1 1]); ## # set (p, "FaceLighting", "phong"); ## # light ("Position", [1 1 5]); ## -## subplot (2, 2, 4); view (-38, 20); -## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, \ +## subplot (2,2,4); view (-38, 20); +## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", c, ... ## "FaceColor", "interp", "EdgeColor", "blue"); -## set (gca, "PlotBoxAspectRatioMode","manual", ... +## set (gca, "PlotBoxAspectRatioMode", "manual", ... ## "PlotBoxAspectRatio", [1 1 1]); ## # set (p, "FaceLighting", "phong"); ## # light ("Position", [1 1 5]); @@ -197,30 +197,30 @@ %! isosurface (x, y, z, v, 1); %!shared x, y, z, val -%! [x, y, z] = meshgrid (0:1, 0:1, 0:1); %% Points for single -%! val = [0, 0; 0, 0]; %% cube and a 3-D -%! val(:,:,2) = [0, 0; 1, 0]; %% array of values +%! [x, y, z] = meshgrid (0:1, 0:1, 0:1); %% Points for single +%! val = [0, 0; 0, 0]; %% cube and a 3-D +%! val(:,:,2) = [0, 0; 1, 0]; %% array of values %!test -%! fv = isosurface (x, y, z, val, 0.3); -%! assert (isfield (fv, "vertices"), true); -%! assert (isfield (fv, "faces"), true); -%! assert (size (fv.vertices), [3 3]); -%! assert (size (fv.faces), [1 3]); +%! fv = isosurface (x, y, z, val, 0.3); +%! assert (isfield (fv, "vertices"), true); +%! assert (isfield (fv, "faces"), true); +%! assert (size (fv.vertices), [3 3]); +%! assert (size (fv.faces), [1 3]); %!test -%! fvc = isosurface (x, y, z, val, .3, y); -%! assert (isfield (fvc, "vertices"), true); -%! assert (isfield (fvc, "faces"), true); -%! assert (isfield (fvc, "facevertexcdata"), true); -%! assert (size (fvc.vertices), [3 3]); -%! assert (size (fvc.faces), [1 3]); -%! assert (size (fvc.facevertexcdata), [3 1]); +%! fvc = isosurface (x, y, z, val, .3, y); +%! assert (isfield (fvc, "vertices"), true); +%! assert (isfield (fvc, "faces"), true); +%! assert (isfield (fvc, "facevertexcdata"), true); +%! assert (size (fvc.vertices), [3 3]); +%! assert (size (fvc.faces), [1 3]); +%! assert (size (fvc.facevertexcdata), [3 1]); %!test -%! [f, v] = isosurface (x, y, z, val, .3); -%! assert (size (f), [1 3]); -%! assert (size (v), [3 3]); +%! [f, v] = isosurface (x, y, z, val, .3); +%! assert (size (f), [1 3]); +%! assert (size (v), [3 3]); %!test -%! [f, v, c] = isosurface (x, y, z, val, .3, y); -%! assert (size (f), [1 3]); -%! assert (size (v), [3 3]); -%! assert (size (c), [3 1]); +%! [f, v, c] = isosurface (x, y, z, val, .3, y); +%! assert (size (f), [1 3]); +%! assert (size (v), [3 3]); +%! assert (size (c), [3 1]);
--- a/scripts/plot/isprop.m +++ b/scripts/plot/isprop.m @@ -47,9 +47,8 @@ endfor endfunction + %!assert (isprop (0, "foobar"), false) - %!assert (isprop (0, "screenpixelsperinch"), true) - %!assert (isprop (zeros (2, 3), "visible"), true (2, 3))
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -1035,9 +1035,9 @@ %! labels = {}; %! colororder = get (gca, 'colororder'); %! for i = 1:5 -%! h = plot (1:100, i + rand(100,1)); hold on; +%! h = plot (1:100, i + rand (100,1)); hold on; %! set (h, 'color', colororder(i,:)); -%! labels = {labels{:}, cstrcat('Signal ', num2str (i))}; +%! labels = {labels{:}, ['Signal ', num2str(i)]}; %! end %! hold off; %! title ('Signals with random offset and uniform noise'); @@ -1047,21 +1047,6 @@ %!demo %! clf; -%! labels = {}; -%! colororder = get (gca, 'colororder'); -%! for i = 1:5 -%! h = plot (1:100, i + rand (100,1)); hold on; -%! set (h, 'color', colororder(i,:)); -%! labels = {labels{:}, cstrcat('Signal ', num2str (i))}; -%! end -%! hold off; -%! title ('Signals with random offset and uniform noise'); -%! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]'); -%! legend (labels{:}, 'location', 'southoutside'); -%! legend ('boxon'); - -%!demo -%! clf; %! x = linspace (0, 10); %! plot (x, x); %! hold on; @@ -1101,24 +1086,24 @@ %! x = 0:0.1:7; %! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10)); %! title ('Only the sin() objects have keylabels'); -%! legend (h([1, 3]), {'sin(x)', 'sin(x^2/10)'}, 'location', 'southwest'); +%! legend (h([1, 3]), {'sin (x)', 'sin (x^2/10)'}, 'location', 'southwest'); %!demo %! clf; %! x = 0:0.1:10; -%! plot (x, sin(x), ';sin(x);'); +%! plot (x, sin (x), ';sin (x);'); %! hold all; -%! plot (x, cos(x), ';cos(x);'); +%! plot (x, cos (x), ';cos (x);'); %! hold off; %!demo %! clf; %! x = 0:0.1:10; -%! plot (x, sin(x), ';sin(x);'); +%! plot (x, sin (x), ';sin (x);'); %! hold all; -%! plot (x, cos(x), ';cos(x);'); +%! plot (x, cos (x), ';cos (x);'); %! hold off; -%! legend ({'sin(x)', 'cos(x)'}, 'location', 'northeastoutside'); +%! legend ({'sin (x)', 'cos (x)'}, 'location', 'northeastoutside'); %!demo %! clf; @@ -1134,19 +1119,19 @@ %!demo %! clf; %! x = (1:5)'; -%! subplot (2, 2, 1); +%! subplot (2,2,1); %! plot (x, rand (numel (x))); %! legend (cellstr (num2str (x)), 'location', 'northwestoutside'); %! legend boxon; -%! subplot (2, 2, 2); +%! subplot (2,2,2); %! plot (x, rand (numel (x))); %! legend (cellstr (num2str (x)), 'location', 'northeastoutside'); %! legend boxon; -%! subplot (2, 2, 3); +%! subplot (2,2,3); %! plot (x, rand (numel (x))); %! legend (cellstr (num2str (x)), 'location', 'southwestoutside'); %! legend boxon; -%! subplot (2, 2, 4); +%! subplot (2,2,4); %! plot (x, rand (numel (x))); %! legend (cellstr (num2str (x)), 'location', 'southeastoutside'); %! legend boxon;
--- a/scripts/plot/line.m +++ b/scripts/plot/line.m @@ -57,3 +57,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/linkprop.m +++ b/scripts/plot/linkprop.m @@ -28,9 +28,9 @@ ## @example ## @group ## x = 0:0.1:10; -## subplot (1, 2, 1); +## subplot (1,2,1); ## h1 = plot (x, sin (x)); -## subplot (1, 2, 2); +## subplot (1,2,2); ## h2 = plot (x, cos (x)); ## hlink = linkprop ([h1, h2], @{"color","linestyle"@}); ## set (h1, "color", "green");
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -67,7 +67,7 @@ %! clf; %! t = 1:0.01:10; %! x = sort ((t .* (1 + rand (size (t)))) .^ 2); -%! y = ((t .* (1 + rand (size (t)))) .^ 2); +%! y = (t .* (1 + rand (size (t)))) .^ 2; %! loglog (x, y); %!demo
--- a/scripts/plot/loglogerr.m +++ b/scripts/plot/loglogerr.m @@ -63,7 +63,7 @@ %!demo %! clf; -%! x = exp (log(0.01):0.2:log(10)); +%! x = exp (log (0.01):0.2:log (10)); %! y = wblpdf (x, 3, 2); %! eyu = 2*rand (size (y)) .* y; %! eyl = 0.5*rand (size (y)) .* y;
--- a/scripts/plot/meshgrid.m +++ b/scripts/plot/meshgrid.m @@ -71,6 +71,7 @@ endfunction + %!test %! x = 1:2; %! y = 1:3; @@ -100,4 +101,5 @@ %! assert (ndims (XX1), 2); %! assert (size (XX1), [3, 3]); %! assert (XX1, XX2); -%! assert (YY1, YY2); \ No newline at end of file +%! assert (YY1, YY2); +
--- a/scripts/plot/module.mk +++ b/scripts/plot/module.mk @@ -166,7 +166,6 @@ plot/sombrero.m \ plot/specular.m \ plot/sphere.m \ - plot/spinmap.m \ plot/stairs.m \ plot/stem.m \ plot/stem3.m \
--- a/scripts/plot/ndgrid.m +++ b/scripts/plot/ndgrid.m @@ -20,13 +20,13 @@ ## @deftypefn {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x1}, @var{x2}, @dots{}, @var{x}n) ## @deftypefnx {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x}) ## Given n vectors @var{x1}, @dots{} @var{x}n, @code{ndgrid} returns -## n arrays of dimension n. The elements of the i-th output argument +## n arrays of dimension n. The elements of the i-th output argument ## contains the elements of the vector @var{x}i repeated over all ## dimensions different from the i-th dimension. Calling ndgrid with ## only one input argument @var{x} is equivalent of calling ndgrid with ## all n input arguments equal to @var{x}: ## -## [@var{y1}, @var{y2}, @dots{}, @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x}) +## [@var{y1}, @var{y2}, @dots{}, @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x}) ## @seealso{meshgrid} ## @end deftypefn @@ -70,6 +70,7 @@ endfunction + %!test %! x = 1:2; %! y = 1:3; @@ -95,3 +96,4 @@ %! assert (XX2(end) * YY2(end), x(end) * y(end)); %! assert (XX1, XX2.'); %! assert (YY1, YY2.'); +
--- a/scripts/plot/newplot.m +++ b/scripts/plot/newplot.m @@ -65,6 +65,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -74,3 +75,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/orient.m +++ b/scripts/plot/orient.m @@ -70,40 +70,42 @@ endfunction + %!shared papersize, paperposition, tallpaperposition, hfig -%! papersize = [8.5, 11]; -%! paperposition = [0.25, 2.5, 8, 6]; -%! tallpaperposition = [0.25, 0.25, (papersize-0.5)]; -%! hfig = figure (); -%! set (hfig, "visible", "off") -%! set (hfig, "paperorientation", "portrait") -%! set (hfig, "papersize", papersize) -%! set (hfig, "paperposition", paperposition) +%! papersize = [8.5, 11]; +%! paperposition = [0.25, 2.5, 8, 6]; +%! tallpaperposition = [0.25, 0.25, (papersize-0.5)]; +%! hfig = figure (); +%! set (hfig, "visible", "off"); +%! set (hfig, "paperorientation", "portrait"); +%! set (hfig, "papersize", papersize); +%! set (hfig, "paperposition", paperposition); %!test -%! orient portrait -%! assert (orient, "portrait") # default -%! assert (get (hfig, "papersize"), papersize) -%! assert (get (hfig, "paperposition"), paperposition) +%! orient portrait; +%! assert (orient, "portrait") # default +%! assert (get (hfig, "papersize"), papersize); +%! assert (get (hfig, "paperposition"), paperposition); %!test -%! orient landscape -%! assert (orient,"landscape") # change to landscape -%! assert (get (hfig, "papersize"), papersize([2, 1])) -%! assert (get (hfig, "paperposition"), paperposition([2, 1, 4, 3])) +%! orient landscape; +%! assert (orient,"landscape") # change to landscape +%! assert (get (hfig, "papersize"), papersize([2, 1])); +%! assert (get (hfig, "paperposition"), paperposition([2, 1, 4, 3])); %!test -%! orient portrait # change back to portrait -%! assert (orient, "portrait") -%! assert (get (hfig, "papersize"), papersize) -%! assert (get (hfig, "paperposition"), paperposition) +%! orient portrait # change back to portrait +%! assert (orient, "portrait"); +%! assert (get (hfig, "papersize"), papersize); +%! assert (get (hfig, "paperposition"), paperposition); %!test -%! orient landscape -%! orient tall -%! assert (orient, "portrait") -%! assert (get (hfig, "papersize"), papersize) -%! assert (get (hfig, "paperposition"), tallpaperposition) +%! orient landscape; +%! orient tall; +%! assert (orient, "portrait"); +%! assert (get (hfig, "papersize"), papersize); +%! assert (get (hfig, "paperposition"), tallpaperposition); %!fail ("orient ('nobody')", "unknown ORIENTATION") %!test -%! orient portrait # errors don't change the state -%! assert (orient, "portrait") -%! assert (get (hfig, "papersize"), papersize) -%! assert (get (hfig, "paperposition"), tallpaperposition) -%! close (hfig) +%! orient portrait # errors don't change the state +%! assert (orient, "portrait"); +%! assert (get (hfig, "papersize"), papersize); +%! assert (get (hfig, "paperposition"), tallpaperposition); +%! close (hfig); +
--- a/scripts/plot/patch.m +++ b/scripts/plot/patch.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{z}, @var{c}) ## @deftypefnx {Function File} {} patch (@var{fv}) -## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{}) +## @deftypefnx {Function File} {} patch ("Faces", @var{f}, "Vertices", @var{v}, @dots{}) ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val}) ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} patch (@dots{}) @@ -106,7 +106,7 @@ %! y2 = cos (t2); %! vert = [x1, y1; x2, y2]; %! fac = [1:8,NaN(1,8);9:24]; -%! patch ('Faces',fac, 'Vertices',vert, 'FaceVertexCData', [0, 1, 0; 0, 0, 1]); +%! patch ('Faces',fac, 'Vertices',vert, 'FaceVertexCData',[0, 1, 0; 0, 0, 1]); %!demo %! %% Property change on multiple patches @@ -117,7 +117,7 @@ %! y1 = cos (t1); %! x2 = sin (t2) + 0.8; %! y2 = cos (t2); -%! h = patch ([x1,x2], [y1,y2], cat (3,[0,0],[1,0],[0,1])); +%! h = patch ([x1,x2], [y1,y2], cat (3, [0,0],[1,0],[0,1])); %! pause (1); %! set (h, 'FaceColor', 'r'); @@ -156,12 +156,12 @@ %! colormap (jet (64)); %! x = [0 1 1 0]; %! y = [0 0 1 1]; -%! subplot (2, 1, 1); +%! subplot (2,1,1); %! title ('Blue, Light-Green, and Red Horizontal Bars'); %! patch (x, y + 0, 1); %! patch (x, y + 1, 2); %! patch (x, y + 2, 3); -%! subplot (2, 1, 2); +%! subplot (2,1,2); %! title ('Blue, Light-Green, and Red Vertical Bars'); %! patch (x + 0, y, 1 * ones (size (x))); %! patch (x + 1, y, 2 * ones (size (x))); @@ -172,12 +172,12 @@ %! colormap (jet (64)); %! x = [0 1 1 0]; %! y = [0 0 1 1]; -%! subplot (2, 1, 1); +%! subplot (2,1,1); %! title ('Blue horizontal bars: Dark to Light'); %! patch (x, y + 0, 1, 'cdatamapping', 'direct'); %! patch (x, y + 1, 9, 'cdatamapping', 'direct'); %! patch (x, y + 2, 17, 'cdatamapping', 'direct'); -%! subplot (2, 1, 2); +%! subplot (2,1,2); %! title ('Blue vertical bars: Dark to Light'); %! patch (x + 0, y, 1 * ones (size (x)), 'cdatamapping', 'direct'); %! patch (x + 1, y, 9 * ones (size (x)), 'cdatamapping', 'direct');
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -29,7 +29,7 @@ ## size of the values of @var{x}. ## ## The variable @var{explode} is a vector of the same length as @var{x} that -## if non zero 'explodes' the slice from the pie chart. +## if non zero "explodes" the slice from the pie chart. ## ## If given @var{labels} is a cell array of strings of the same length as ## @var{x}, giving the labels of each of the slices of the pie chart.
--- a/scripts/plot/pie3.m +++ b/scripts/plot/pie3.m @@ -30,7 +30,7 @@ ## size of the values of @var{x}. ## ## The variable @var{explode} is a vector of the same length as @var{x} that -## if non zero 'explodes' the slice from the pie chart. +## if non zero "explodes" the slice from the pie chart. ## ## If given @var{labels} is a cell array of strings of the same length as ## @var{x}, giving the labels of each of the slices of the pie chart.
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -74,9 +74,9 @@ ## ## @example ## @group -## z = [0:0.05:5]; -## plot3 (cos(2*pi*z), sin(2*pi*z), z, ";helix;"); -## plot3 (z, exp(2i*pi*z), ";complex sinusoid;"); +## z = [0:0.05:5]; +## plot3 (cos (2*pi*z), sin (2*pi*z), z, ";helix;"); +## plot3 (z, exp (2i*pi*z), ";complex sinusoid;"); ## @end group ## @end example ## @seealso{plot, xlabel, ylabel, zlabel, title, print} @@ -342,6 +342,6 @@ %!demo %! clf; %! z = [0:0.05:5]; -%! plot3 (cos(2*pi*z), sin(2*pi*z), z, ';helix;'); -%! plot3 (z, exp(2i*pi*z), ';complex sinusoid;'); +%! plot3 (cos (2*pi*z), sin (2*pi*z), z, ';helix;'); +%! plot3 (z, exp (2i*pi*z), ';complex sinusoid;');
--- a/scripts/plot/plotmatrix.m +++ b/scripts/plot/plotmatrix.m @@ -54,9 +54,7 @@ ## the histogram and @var{pax} the corresponding axes objects. ## ## @example -## @group -## plotmatrix (randn (100, 3), 'g+') -## @end group +## plotmatrix (randn (100, 3), "g+") ## @end example ## ## @end deftypefn
--- a/scripts/plot/plotyy.m +++ b/scripts/plot/plotyy.m @@ -260,7 +260,7 @@ %!demo %! clf; %! x = linspace (-1, 1, 201); -%! hax = plotyy (x, sin(pi*x), x, cos(pi*x)); +%! hax = plotyy (x, sin (pi*x), x, cos (pi*x)); %! ylabel ('Blue on the Left'); %! ylabel (hax(2), 'Green on the Right'); %! xlabel ('xlabel');
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -64,6 +64,7 @@ ## ## @item -d@var{device} ## Output device, where @var{device} is one of: +## ## @table @code ## @item ps ## @itemx ps2 @@ -234,9 +235,9 @@ ## ## @example ## @group -## figure (1) -## clf () -## surf (peaks) +## figure (1); +## clf (); +## surf (peaks); ## print -dsvg figure1.svg ## @end group ## @end example @@ -245,9 +246,9 @@ ## ## @example ## @group -## figure (1) -## clf () -## surf (peaks) +## figure (1); +## clf (); +## surf (peaks); ## print -dcdj550 ## @end group ## @end example @@ -283,21 +284,29 @@ ## Modify properties as specified by options props = []; + drawnow (); + + ## print() requires figure units to be "pixels" + props(1).h = opts.figure; + props(1).name = "units"; + props(1).value = {get(opts.figure, "units")}; + set (opts.figure, "units", "pixels"); + ## graphics toolkit tranlates figure position to eps bbox in points fpos = get (opts.figure, "position"); - props(1).h = opts.figure; - props(1).name = "position"; - props(1).value = {fpos}; + props(2).h = opts.figure; + props(2).name = "position"; + props(2).value = {fpos}; fpos(3:4) = opts.canvas_size; set (opts.figure, "position", fpos); ## Set figure background to none. This is done both for ## consistency with Matlab and to elliminate the visible ## box along the figure's perimeter. - props(2).h = opts.figure; - props(2).name = "color"; - props(2).value{1} = get (props(2).h, props(2).name); - set (props(2).h, props(2).name, "none"); + props(3).h = opts.figure; + props(3).name = "color"; + props(3).value{1} = get (props(3).h, props(3).name); + set (props(3).h, "color", "none"); if (opts.force_solid != 0) h = findall (opts.figure, "-property", "linestyle"); @@ -389,7 +398,7 @@ unwind_protect_cleanup ## restore modified properties if (isstruct (props)) - for n = 1:numel(props) + for n = numel(props):-1:1 if (ishandle (props(n).h)) set (props(n).h, props(n).name, props(n).value{1}); endif
--- a/scripts/plot/private/__marching_cube__.m +++ b/scripts/plot/private/__marching_cube__.m @@ -49,7 +49,7 @@ ## @example ## @group ## N = 20; -## lin = linspace(0, 2, N); +## lin = linspace (0, 2, N); ## [x, y, z] = meshgrid (lin, lin, lin); ## ## c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2; @@ -70,11 +70,11 @@ ## "FaceColor", "interp", "EdgeColor", "none"); ## ## ## Revert normals -## set (pa, "VertexNormals", -get(pa, "VertexNormals")); +## set (pa, "VertexNormals", -get (pa, "VertexNormals")); ## ## ## Set lightning (available with the JHandles package) ## # set (pa, "FaceLighting", "gouraud"); -## # light( "Position", [1 1 5]); +## # light ( "Position", [1 1 5]); ## @end group ## @end example ##
--- a/scripts/plot/private/__print_parse_opts__.m +++ b/scripts/plot/private/__print_parse_opts__.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{args} =} __print_parse_opts__ (@var{propname}, @var{propvalue}) +## @deftypefn {Function File} {@var{args} =} __print_parse_opts__ (@var{propname}, @var{propvalue}) ## @deftypefnx {Function File} {@var{args} =} __print_parse_opts__ (@var{struct}) ## Undocumented internal function. ## @end deftypefn @@ -371,7 +371,7 @@ %! assert (opts.use_color, 1); %! assert (opts.send_to_printer, true); %! assert (opts.canvas_size, [576, 432]); -%! assert (opts.ghostscript.device, "pswrite") +%! assert (opts.ghostscript.device, "pswrite"); #%!test %! opts = __print_parse_opts__ ("test.pdf", "-S640,480"); @@ -383,7 +383,7 @@ %! assert (opts.send_to_printer, true); %! assert (opts.use_color, 1); %! assert (opts.append_to_file, false); -%! assert (opts.ghostscript.device, "pswrite") +%! assert (opts.ghostscript.device, "pswrite"); %! assert (opts.ghostscript.epscrop, false); #%!test @@ -391,13 +391,13 @@ %! assert (opts.tight_flag, true); %! assert (opts.send_to_printer, true); %! assert (opts.use_color, -1); -%! assert (opts.ghostscript.device, "") +%! assert (opts.ghostscript.device, ""); #%!test %! opts = __print_parse_opts__ ("-djpg", "foobar", "-mono", "-loose"); -%! assert (opts.devopt, "jpeg") -%! assert (opts.name, "foobar.jpg") -%! assert (opts.ghostscript.device, "jpeg") +%! assert (opts.devopt, "jpeg"); +%! assert (opts.name, "foobar.jpg"); +%! assert (opts.ghostscript.device, "jpeg"); %! assert (opts.ghostscript.epscrop, true); %! assert (opts.ghostscript.papersize, ""); %! assert (opts.ghostscript.pageoffset, [0, 0]); @@ -407,20 +407,20 @@ #%!test %! opts = __print_parse_opts__ ("-ddeskjet", "foobar", "-mono", "-Pmyprinter"); -%! assert (opts.ghostscript.output, "foobar.deskjet") -%! assert (opts.ghostscript.device, "deskjet") -%! assert (opts.devopt, "deskjet") +%! assert (opts.ghostscript.output, "foobar.deskjet"); +%! assert (opts.ghostscript.device, "deskjet"); +%! assert (opts.devopt, "deskjet"); %! assert (opts.send_to_printer, true); %! assert (opts.printer, "-Pmyprinter"); %! assert (opts.use_color, -1); #%!test %! opts = __print_parse_opts__ ("-f5", "-dljet3"); -%! assert (opts.ghostscript.device, "ljet3") -%! assert (strfind (opts.ghostscript.output, ".ljet3")) -%! assert (opts.devopt, "ljet3") +%! assert (opts.ghostscript.device, "ljet3"); +%! assert (strfind (opts.ghostscript.output, ".ljet3")); +%! assert (opts.devopt, "ljet3"); %! assert (opts.send_to_printer, true); -%! assert (opts.figure, 5) +%! assert (opts.figure, 5); function cmd = __quote_path__ (cmd) if (any (cmd == " ") && ! (cmd(1) == """" && cmd(end) == """"))
--- a/scripts/plot/quiver.m +++ b/scripts/plot/quiver.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} quiver (@var{x}, @var{y}, @var{u}, @var{v}) ## @deftypefnx {Function File} {} quiver (@dots{}, @var{s}) ## @deftypefnx {Function File} {} quiver (@dots{}, @var{style}) -## @deftypefnx {Function File} {} quiver (@dots{}, 'filled') +## @deftypefnx {Function File} {} quiver (@dots{}, "filled") ## @deftypefnx {Function File} {} quiver (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} quiver (@dots{}) ## @@ -40,7 +40,7 @@ ## The style to use for the plot can be defined with a line style @var{style} ## in a similar manner to the line styles used with the @code{plot} command. ## If a marker is specified then markers at the grid points of the vectors are -## printed rather than arrows. If the argument 'filled' is given then the +## printed rather than arrows. If the argument "filled" is given then the ## markers as filled. ## ## The optional return value @var{h} is a graphics handle to a quiver object.
--- a/scripts/plot/quiver3.m +++ b/scripts/plot/quiver3.m @@ -21,7 +21,7 @@ ## @deftypefnx {Function File} {} quiver3 (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w}) ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{s}) ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{style}) -## @deftypefnx {Function File} {} quiver3 (@dots{}, 'filled') +## @deftypefnx {Function File} {} quiver3 (@dots{}, "filled") ## @deftypefnx {Function File} {} quiver3 (@var{h}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} quiver3 (@dots{}) ## @@ -40,7 +40,7 @@ ## The style to use for the plot can be defined with a line style @var{style} ## in a similar manner to the line styles used with the @code{plot} command. ## If a marker is specified then markers at the grid points of the vectors are -## printed rather than arrows. If the argument 'filled' is given then the +## printed rather than arrows. If the argument "filled" is given then the ## markers as filled. ## ## The optional return value @var{h} is a graphics handle to a quiver object. @@ -93,7 +93,7 @@ %! theta = 2*pi * sqrt (x.^2 + y.^2) + pi/2; %! quiver3 (x, y, z, sin (theta), cos (theta), ones (size (z))); %! hold on; -%! mesh (x,y,z); +%! mesh (x, y, z); %! hold off; %!demo
--- a/scripts/plot/refreshdata.m +++ b/scripts/plot/refreshdata.m @@ -42,8 +42,8 @@ ## y = sin (x); ## plot (x, y, "ydatasource", "y"); ## for i = 1 : 100 -## pause (0.1) -## y = sin (x + 0.1 * i); +## pause (0.1); +## y = sin (x + 0.1*i); ## refreshdata (); ## endfor ## @end group @@ -115,6 +115,6 @@ %! for i = 1 : 100 %! pause (0.1); %! y = sin (x + 0.1 * i); -%! refreshdata (gcf (), 'caller'); +%! refreshdata (gcf, 'caller'); %! end
--- a/scripts/plot/ribbon.m +++ b/scripts/plot/ribbon.m @@ -93,3 +93,4 @@ %! ribbon (y, z); %!FIXME: Could have some input validation tests here +
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -39,7 +39,7 @@ ## ## @example ## @group -## [r, t] = rose ([2*randn(1e5,1), pi + 2 * randn(1e5,1)]); +## [r, t] = rose ([2*randn(1e5,1), pi + 2*randn(1e5,1)]); ## polar (r, t); ## @end group ## @end example
--- a/scripts/plot/saveas.m +++ b/scripts/plot/saveas.m @@ -50,10 +50,9 @@ ## ## @example ## @group -## figure (1); ## clf (); ## surf (peaks); -## saveas(1, "figure1.png"); +## saveas (1, "figure1.png"); ## @end group ## @end example ##
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -18,7 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} scatter3 (@var{x}, @var{y}, @var{z}, @var{s}, @var{c}) -## @deftypefnx {Function File} {} scatter3 (@dots{}, 'filled') +## @deftypefnx {Function File} {} scatter3 (@dots{}, "filled") ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{style}) ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{prop}, @var{val}) ## @deftypefnx {Function File} {} scatter3 (@var{h}, @dots{}) @@ -38,7 +38,7 @@ ## ## The marker to use can be changed with the @var{style} argument, that is a ## string defining a marker in the same manner as the @code{plot} command. -## If the argument 'filled' is given then the markers as filled. All +## If the argument "filled" is given then the markers as filled. All ## additional arguments are passed to the underlying patch command. ## ## The optional return value @var{h} is a graphics handle to the hggroup
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -102,7 +102,7 @@ %! unwind_protect %! a = logspace (-5, 1, 10); %! b = logspace (-5, 1, 10); -%! semilogx (a, b) +%! semilogx (a, b); %! assert (get (gca, "xscale"), "log"); %! assert (get (gca, "yscale"), "linear"); %! unwind_protect_cleanup @@ -112,11 +112,11 @@ %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! a = logspace (-5, 1, 10); -%! b =-logspace (-5, 1, 10); +%! a =-logspace (-5, 1, 10); +%! b = logspace (-5, 1, 10); %! semilogx (a, b); %! axis tight; -%! assert (all (get (gca, "ytick") < 0)); +%! assert (all (get (gca, "xtick") < 0)); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -63,7 +63,7 @@ %!demo %! clf; -%! x = exp (log(0.01):0.2:log(10)); +%! x = exp (log (0.01):0.2:log (10)); %! y = wblpdf (x, 2, 2); %! ey = 0.5*rand (size (y)) .* y; %! semilogxerr (x, y, ey, '#~x-');
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -75,11 +75,11 @@ %! x = logspace (-5, 1, 10); %! y = logspace (-5, 1, 10); %! -%! subplot (2, 1, 1); +%! subplot (2,1,1); %! semilogy (x, y); %! ylabel ('semilogy (x, y)'); %! -%! subplot (2, 1, 2); +%! subplot (2,1,2); %! semilogy (x, -y); %! ylabel ('semilogy (x, -y)'); @@ -88,12 +88,12 @@ %! x = logspace (-5, 1, 10); %! y = logspace (-5, 1, 10); %! -%! subplot (2, 1, 1); +%! subplot (2,1,1); %! semilogy (x, y); %! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition'); %! ylabel ({'semilogy (x, y)', 'ydir = reversed'}); %! -%! subplot (2, 1, 2); +%! subplot (2,1,2); %! semilogy (x, -y); %! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition'); %! ylabel ({'semilogy (x, -y)', 'ydir = reversed'});
--- a/scripts/plot/stem.m +++ b/scripts/plot/stem.m @@ -39,7 +39,7 @@ ## @example ## @group ## x = 1:10; -## y = ones (1, length (x))*2.*x; +## y = 2*x; ## stem (x, y, "r"); ## @end group ## @end example @@ -55,7 +55,7 @@ ## ## @example ## @group -## x = [0 : 10]'; +## x = [0:10]'; ## y = [sin(x), cos(x)] ## h = stem (x, y); ## set (h(2), "color", "g"); @@ -64,7 +64,7 @@ ## @end example ## ## @noindent -## changes the color of the second "stem series" and moves the base line +## changes the color of the second "stem series" and moves the base line ## of the first. ## @seealso{bar, barh, plot} ## @end deftypefn @@ -128,5 +128,5 @@ %! y = [sin(x), cos(x)]; %! h = stem (x, y); %! set (h(2), 'color', 'g'); -%! set (h(1), 'basevalue', -1) +%! set (h(1), 'basevalue', -1);
--- a/scripts/plot/stem3.m +++ b/scripts/plot/stem3.m @@ -56,5 +56,5 @@ %!demo %! clf; %! theta = 0:0.2:6; -%! stem3 (cos(theta), sin(theta), theta); +%! stem3 (cos (theta), sin (theta), theta);
--- a/scripts/plot/subplot.m +++ b/scripts/plot/subplot.m @@ -56,7 +56,7 @@ ## the grid locations specified. The first demo illustrates an example: ## ## @example -## @code{demo ("subplot", 1)} +## demo ("subplot", 1) ## @end example ## ## @end ifnottex @@ -327,6 +327,7 @@ endfunction + %!demo %! clf; %! r = 3; @@ -351,13 +352,13 @@ %! clf; %! x = 0:1; %! for n = 1:4 -%! subplot (2, 2, n, 'align'); +%! subplot (2,2,n, 'align'); %! plot (x, x); %! xlabel (sprintf ('xlabel (2,2,%d)', n)); %! ylabel (sprintf ('ylabel (2,2,%d)', n)); %! title (sprintf ('title (2,2,%d)', n)); %! end -%! subplot (1, 2, 1, 'align'); +%! subplot (1,2,1, 'align'); %! plot (x, x); %! xlabel ('xlabel (1,2,1)'); %! ylabel ('ylabel (1,2,1)');
--- a/scripts/plot/surfl.m +++ b/scripts/plot/surfl.m @@ -57,7 +57,7 @@ ## ## @example ## @group -## colormap (bone); +## colormap (bone (64)); ## surfl (peaks); ## shading interp; ## @end group
--- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -27,8 +27,8 @@ ## ## @example ## @group -## [@var{x}, @var{y}] = meshgrid (1:size(@var{z}, 1), -## 1:size(@var{z}, 2)); +## [@var{x}, @var{y}] = meshgrid (1:size (@var{z}, 1), +## 1:size (@var{z}, 2)); ## @end group ## @end example ##
--- a/scripts/plot/title.m +++ b/scripts/plot/title.m @@ -48,22 +48,22 @@ %!demo %! clf; %! ax = axes (); -%! xl = get (ax,'title'); +%! xl = get (ax, 'title'); %! title ('Testing title'); %! assert (get (xl, 'string'), 'Testing title'); %!demo %! clf; %! plot3 ([0,1], [0,1], [0,1]); -%! xl = get (gca (), 'title'); +%! xl = get (gca, 'title'); %! title ('Testing title'); %! assert (get (xl, 'string'), 'Testing title'); %!test %! hf = figure ("visible", "off"); %! unwind_protect -%! ax = axes(); -%! xl = get (ax,"title"); +%! ax = axes (); +%! xl = get (ax, "title"); %! title ("Testing title"); %! assert (get (xl, "string"), "Testing title"); %! unwind_protect_cleanup @@ -74,7 +74,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! plot3 ([0,1], [0,1], [0,1]); -%! xl = get (gca (), "title"); +%! xl = get (gca, "title"); %! title ("Testing title"); %! assert (get (xl, "string"), "Testing title"); %! unwind_protect_cleanup
--- a/scripts/plot/uicontextmenu.m +++ b/scripts/plot/uicontextmenu.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uicontextmenu ('Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uicontextmenu ("Name", value, @dots{}) ## @end deftypefn ## Author: goffioul
--- a/scripts/plot/uicontrol.m +++ b/scripts/plot/uicontrol.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uicontrol ('Name', value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uicontrol (@var{parent}, 'Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uicontrol ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{handle} =} uicontrol (@var{parent}, "Name", value, @dots{}) ## @deftypefnx {Function File} {} uicontrol (@var{handle}) ## @end deftypefn
--- a/scripts/plot/uigetfile.m +++ b/scripts/plot/uigetfile.m @@ -191,5 +191,5 @@ %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'}); ## Remove from test statistics. No real tests possible. -%!assert (1); +%!assert (1)
--- a/scripts/plot/uimenu.m +++ b/scripts/plot/uimenu.m @@ -64,12 +64,12 @@ ## ## @example ## @group -## f = uimenu("label", "&File", "accelerator", "f"); -## e = uimenu("label", "&Edit", "accelerator", "e"); -## uimenu(f, "label", "Close", "accelerator", "q", ... -## "callback", "close (gcf)"); -## uimenu(e, "label", "Toggle &Grid", "accelerator", "g", ... -## "callback", "grid (gca)"); +## f = uimenu ("label", "&File", "accelerator", "f"); +## e = uimenu ("label", "&Edit", "accelerator", "e"); +## uimenu (f, "label", "Close", "accelerator", "q", ... +## "callback", "close (gcf)"); +## uimenu (e, "label", "Toggle &Grid", "accelerator", "g", ... +## "callback", "grid (gca)"); ## @end group ## @end example ## @seealso{figure}
--- a/scripts/plot/uipanel.m +++ b/scripts/plot/uipanel.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uipanel ('Name', value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uipanel (@var{parent}, 'Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uipanel ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{handle} =} uipanel (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul
--- a/scripts/plot/uipushtool.m +++ b/scripts/plot/uipushtool.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uipushtool ('Name', value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uipushtool (@var{parent}, 'Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uipushtool ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{handle} =} uipushtool (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul
--- a/scripts/plot/uitoggletool.m +++ b/scripts/plot/uitoggletool.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uitoggletool ('Name', value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uitoggletool (@var{parent}, 'Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uitoggletool ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{handle} =} uitoggletool (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul
--- a/scripts/plot/uitoolbar.m +++ b/scripts/plot/uitoolbar.m @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uitoolbar ('Name', value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uitoolbar (@var{parent}, 'Name', value, @dots{}) +## @deftypefn {Function File} {@var{handle} =} uitoolbar ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{handle} =} uitoolbar (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul
--- a/scripts/plot/uiwait.m +++ b/scripts/plot/uiwait.m @@ -29,9 +29,9 @@ ## ## When specified, @var{timeout} defines the number of seconds to wait ## for the figure deletion or the @code{uiresume} call. The timeout value -## must be at least 1. If a smaller value is specified, a warning is issued +## must be at least 1. If a smaller value is specified, a warning is issued ## and a timeout value of 1 is used instead. If a non-integer value is -## specified, it is truncated towards 0. If @var{timeout} is not specified, +## specified, it is truncated towards 0. If @var{timeout} is not specified, ## the program execution is suspended indefinitely. ## @seealso{uiresume, waitfor} ## @end deftypefn
--- a/scripts/plot/view.m +++ b/scripts/plot/view.m @@ -94,6 +94,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -122,3 +123,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/whitebg.m +++ b/scripts/plot/whitebg.m @@ -144,6 +144,7 @@ endif endfunction + %!test %! dac = get (0, "defaultaxescolor"); %! dfc = get (0, "defaultfigurecolor"); @@ -162,3 +163,4 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect +
--- a/scripts/plot/xlim.m +++ b/scripts/plot/xlim.m @@ -23,7 +23,7 @@ ## ## @deftypefn {Function File} {@var{xl} =} xlim () ## @deftypefnx {Function File} {} xlim (@var{xl}) -## @deftypefnx {Function File} {@var{m} =} xlim ('mode') +## @deftypefnx {Function File} {@var{m} =} xlim ("mode") ## @deftypefnx {Function File} {} xlim (@var{m}) ## @deftypefnx {Function File} {} xlim (@var{h}, @dots{}) ## Get or set the limits of the x-axis of the current plot. Called without @@ -32,8 +32,8 @@ ## to this value. ## ## The current mode for calculation of the x-axis can be returned with a -## call @code{xlim ('mode')}, and can be either 'auto' or 'manual'. The -## current plotting mode can be set by passing either 'auto' or 'manual' +## call @code{xlim ("mode")}, and can be either "auto" or "manual". The +## current plotting mode can be set by passing either "auto" or "manual" ## as the argument. ## ## If passed a handle as the first argument, then operate on this handle
--- a/scripts/plot/ylim.m +++ b/scripts/plot/ylim.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{yl} =} ylim () ## @deftypefnx {Function File} {} ylim (@var{yl}) -## @deftypefnx {Function File} {@var{m} =} ylim ('mode') +## @deftypefnx {Function File} {@var{m} =} ylim ("mode") ## @deftypefnx {Function File} {} ylim (@var{m}) ## @deftypefnx {Function File} {} ylim (@var{h}, @dots{}) ## Get or set the limits of the y-axis of the current plot. Called without @@ -28,8 +28,8 @@ ## to this value. ## ## The current mode for calculation of the y-axis can be returned with a -## call @code{ylim ('mode')}, and can be either 'auto' or 'manual'. The -## current plotting mode can be set by passing either 'auto' or 'manual' +## call @code{ylim ("mode")}, and can be either "auto" or "manual". The +## current plotting mode can be set by passing either "auto" or "manual" ## as the argument. ## ## If passed a handle as the first argument, then operate on this handle
--- a/scripts/plot/zlim.m +++ b/scripts/plot/zlim.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{zl} =} zlim () ## @deftypefnx {Function File} {} zlim (@var{zl}) -## @deftypefnx {Function File} {@var{m} =} zlim ('mode') +## @deftypefnx {Function File} {@var{m} =} zlim ("mode") ## @deftypefnx {Function File} {} zlim (@var{m}) ## @deftypefnx {Function File} {} zlim (@var{h}, @dots{}) ## Get or set the limits of the z-axis of the current plot. Called without @@ -28,8 +28,8 @@ ## to this value. ## ## The current mode for calculation of the z-axis can be returned with a -## call @code{zlim ('mode')}, and can be either 'auto' or 'manual'. The -## current plotting mode can be set by passing either 'auto' or 'manual' +## call @code{zlim ("mode")}, and can be either "auto" or "manual". The +## current plotting mode can be set by passing either "auto" or "manual" ## as the argument. ## ## If passed a handle as the first argument, then operate on this handle
--- a/scripts/polynomial/compan.m +++ b/scripts/polynomial/compan.m @@ -79,15 +79,12 @@ endfunction -%!assert(all (all (compan ([1, 2, 3]) == [-2, -3; 1, 0]))); - -%!assert(all (all (compan ([1; 2; 3]) == [-2, -3; 1, 0]))); - -%!assert(isempty (compan (4))); -%!assert(all (all (compan ([3, 2, 1]) == [-2/3, -1/3; 1, 0]))); +%!assert (compan ([1, 2, 3]), [-2, -3; 1, 0]) +%!assert (compan ([1; 2; 3]), [-2, -3; 1, 0]) +%!assert (isempty (compan (4))) +%!assert (compan ([3, 2, 1]), [-2/3, -1/3; 1, 0]) -%!error compan ([1,2;3,4]); +%!error compan ([1,2;3,4]) +%!error compan ([]) -%!error compan ([]); -
--- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -51,12 +51,12 @@ if (! (isvector (a) && isvector (b))) error ("conv: both arguments A and B must be vectors"); - elseif (nargin == 3 && ! any (strcmpi (shape, {"full", "same"}))) - error ('conv: SHAPE argument must be "full" or "same"'); + elseif (nargin == 3 && ! any (strcmpi (shape, {"full", "same", "valid"}))) + error ('conv: SHAPE argument must be "full", "same", or "valid"'); endif - la = length (a); - lb = length (b); + la = la_orig = length (a); + lb = lb_orig = length (b); ly = la + lb - 1; @@ -79,63 +79,68 @@ y = filter (a, 1, x); - if (strcmp (shape, "same")) + if (strcmpi (shape, "same")) idx = ceil ((ly - la) / 2); y = y(idx+1:idx+la); + elseif (strcmpi (shape, "valid")) + len = la_orig - lb_orig; + y = y(lb_orig:lb_orig+len); endif endfunction %!test -%! x = ones(3,1); -%! y = ones(1,3); -%! b = 2; -%! c = 3; -%! assert (conv (x, x), [1; 2; 3; 2; 1]); -%! assert (conv (y, y), [1, 2, 3, 2, 1]); -%! assert (conv (x, y), [1, 2, 3, 2, 1]); -%! assert (conv (y, x), [1; 2; 3; 2; 1]); -%! assert (conv (c, x), [3; 3; 3]); -%! assert (conv (c, y), [3, 3, 3]); -%! assert (conv (x, c), [3; 3; 3]); -%! assert (conv (y, c), [3, 3, 3]); -%! assert (conv (b, c), 6); +%! x = ones (3,1); +%! y = ones (1,3); +%! b = 2; +%! c = 3; +%! assert (conv (x, x), [1; 2; 3; 2; 1]); +%! assert (conv (y, y), [1, 2, 3, 2, 1]); +%! assert (conv (x, y), [1, 2, 3, 2, 1]); +%! assert (conv (y, x), [1; 2; 3; 2; 1]); +%! assert (conv (c, x), [3; 3; 3]); +%! assert (conv (c, y), [3, 3, 3]); +%! assert (conv (x, c), [3; 3; 3]); +%! assert (conv (y, c), [3, 3, 3]); +%! assert (conv (b, c), 6); +%!shared a,b %!test -%! a = 1:10; -%! b = 1:3; -%! assert (size (conv(a,b)), [1, numel(a)+numel(b)-1]); -%! assert (size (conv(b,a)), [1, numel(a)+numel(b)-1]); +%! a = 1:10; +%! b = 1:3; +%!assert (size (conv (a,b)), [1, numel(a)+numel(b)-1]) +%!assert (size (conv (b,a)), [1, numel(a)+numel(b)-1]) %!test -%! a = (1:10).'; -%! b = 1:3; -%! assert (size (conv(a,b)), [numel(a)+numel(b)-1, 1]); -%! assert (size (conv(b,a)), [numel(a)+numel(b)-1, 1]); +%! a = (1:10).'; +%!assert (size (conv (a,b)), [numel(a)+numel(b)-1, 1]) +%!assert (size (conv (b,a)), [numel(a)+numel(b)-1, 1]) + +%!test +%! a = 1:10; +%! b = (1:3).'; +%!assert (size (conv (a,b)), [1, numel(a)+numel(b)-1]) +%!assert (size (conv (b,a)), [1, numel(a)+numel(b)-1]) %!test -%! a = 1:10; -%! b = (1:3).'; -%! assert (size (conv(a,b)), [1, numel(a)+numel(b)-1]); -%! assert (size (conv(b,a)), [1, numel(a)+numel(b)-1]); +%! a = 1:10; +%! b = 1:3; + +%!assert (conv (a,b,"full"), conv (a,b)) +%!assert (conv (b,a,"full"), conv (b,a)) -%!test -%! a = 1:10; -%! b = 1:3; -%! assert (conv (a,b,"full"), conv (a,b)); -%! assert (conv (b,a,"full"), conv (b,a)); +%!assert (conv (a,b,"same"), [4, 10, 16, 22, 28, 34, 40, 46, 52, 47]) +%!assert (conv (b,a,"same"), [28, 34, 40]) -%!test -%! a = 1:10; -%! b = 1:3; -%! assert (conv (a,b,"same"), [4, 10, 16, 22, 28, 34, 40, 46, 52, 47]); -%! assert (conv (b,a,"same"), [28, 34, 40]); +%!assert (conv (a,b,"valid"), [10, 16, 22, 28, 34, 40, 46, 52]) +%!assert (conv (b,a,"valid"), zeros (1,0)) + %% Test input validation %!error conv (1) %!error conv (1,2,3,4) -%!error conv ([1, 2; 3, 4], 3) -%!error conv (3, [1, 2; 3, 4]) -%!error conv (2, 3, "XXXX") +%!error <A and B must be vectors> conv ([1, 2; 3, 4], 3) +%!error <A and B must be vectors> conv (3, [1, 2; 3, 4]) +%!error <SHAPE argument must be> conv (2, 3, "INVALID_SHAPE")
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -81,30 +81,34 @@ endfunction + %!test %! [b, r] = deconv ([3, 6, 9, 9], [1, 2, 3]); -%! assert(all (all (b == [3, 0])) && all (all (r == [0, 0, 0, 9]))); +%! assert (b, [3, 0]); +%! assert (r, [0, 0, 0, 9]); %!test %! [b, r] = deconv ([3, 6], [1, 2, 3]); -%! assert(b == 0 && all (all (r == [3, 6]))); +%! assert (b, 0); +%! assert (r, [3, 6]); %!test %! [b, r] = deconv ([3, 6], [1; 2; 3]); -%! assert(b == 0 && all (all (r == [3, 6]))); +%! assert (b, 0); +%! assert (r, [3, 6]); %!test %! [b,r] = deconv ([3; 6], [1; 2; 3]); -%! assert (b == 0 && all (all (r == [3; 6]))) +%! assert (b, 0); +%! assert (r, [3; 6]); %!test %! [b, r] = deconv ([3; 6], [1, 2, 3]); -%! assert (b == 0 && all (all (r == [3; 6]))) - -%!test -%! assert (deconv ((1:3)',[1, 1]), [1; 1]) +%! assert (b, 0); +%! assert (r, [3; 6]); -%!error [b, r] = deconv ([3, 6], [1, 2; 3, 4]); +%!assert (deconv ((1:3)',[1, 1]), [1; 1]) -%!error [b, r] = deconv ([3, 6; 1, 2], [1, 2, 3]); +%!error [b, r] = deconv ([3, 6], [1, 2; 3, 4]) +%!error [b, r] = deconv ([3, 6; 1, 2], [1, 2, 3])
--- a/scripts/polynomial/mkpp.m +++ b/scripts/polynomial/mkpp.m @@ -88,27 +88,27 @@ %! pp = mkpp (x, [m(:),b(:)]); %! xi = linspace (0,pi,50); %! plot (x,t,"x", xi,ppval (pp,xi)); -%! legend ("control","interp"); +%! legend ("control", "interp"); %!shared b,c,pp %! b = 1:3; c = 1:24; pp = mkpp (b,c); -%!assert (pp.pieces, 2); -%!assert (pp.order, 12); -%!assert (pp.dim, 1); -%!assert (size (pp.coefs), [2,12]); +%!assert (pp.pieces, 2) +%!assert (pp.order, 12) +%!assert (pp.dim, 1) +%!assert (size (pp.coefs), [2,12]) %! pp = mkpp(b,c,2); -%!assert (pp.pieces, 2); -%!assert (pp.order, 6); -%!assert (pp.dim, 2); -%!assert (size (pp.coefs), [4,6]); +%!assert (pp.pieces, 2) +%!assert (pp.order, 6) +%!assert (pp.dim, 2) +%!assert (size (pp.coefs), [4,6]) %! pp = mkpp(b,c,3); -%!assert (pp.pieces, 2); -%!assert (pp.order, 4); -%!assert (pp.dim, 3); -%!assert (size (pp.coefs), [6,4]); +%!assert (pp.pieces, 2) +%!assert (pp.order, 4) +%!assert (pp.dim, 3) +%!assert (size (pp.coefs), [6,4]) %! pp = mkpp(b,c,[2,3]); -%!assert (pp.pieces, 2); -%!assert (pp.order, 2); -%!assert (pp.dim, [2,3]); -%!assert (size (pp.coefs), [12,2]); +%!assert (pp.pieces, 2) +%!assert (pp.order, 2) +%!assert (pp.dim, [2,3]) +%!assert (size (pp.coefs), [12,2])
--- a/scripts/polynomial/mpoles.m +++ b/scripts/polynomial/mpoles.m @@ -38,10 +38,10 @@ ## @example ## @group ## p = [2 3 1 1 2]; -## [m, n] = mpoles(p); -## @result{} m = [1; 1; 2; 1; 2] -## @result{} n = [2; 5; 1; 4; 3] -## @result{} p(n) = [3, 2, 2, 1, 1] +## [m, n] = mpoles (p) +## @result{} m = [1; 1; 2; 1; 2] +## @result{} n = [2; 5; 1; 4; 3] +## @result{} p(n) = [3, 2, 2, 1, 1] ## @end group ## @end example ## @@ -116,7 +116,8 @@ endfunction + %!test %! [mp, n] = mpoles ([0 0], 0.01); -%! assert (mp, [1; 2]) +%! assert (mp, [1; 2]);
--- a/scripts/polynomial/pchip.m +++ b/scripts/polynomial/pchip.m @@ -138,7 +138,7 @@ %! %------------------------------------------------------------------- %! % confirm that pchip agreed better to discontinuous data than spline -%!shared x,y,y2,pp,yi1,yi2,yi3 +%!shared x, y, y2, pp, yi1, yi2, yi3 %! x = 0:8; %! y = [1, 1, 1, 1, 0.5, 0, 0, 0, 0]; %!assert (pchip (x,y,x), y) @@ -152,7 +152,7 @@ %!assert (pchip (x',[y;y],x), [pchip(x,y,x);pchip(x,y,x)]) %!assert (pchip (x',[y;y],x'), [pchip(x,y,x);pchip(x,y,x)]) %!test -%! x = (0:8)*pi/4; y = [sin(x);cos(x)]; +%! x = (0:8)*pi/4; y = [sin(x); cos(x)]; %! y2(:,:,1) = y; y2(:,:,2) = y+1; y2(:,:,3) = y-1; %! pp = pchip (x, shiftdim (y2,2)); %! yi1 = ppval (pp, (1:4)*pi/4); @@ -163,7 +163,7 @@ %!assert (pp.order, 4) %!assert (pp.dim, [3,2]) %!assert (ppval (pp,pi), [0,-1;1,0;-1,-2], 1e-14) -%!assert (yi3(:,:,2), ppval(pp,pi), 1e-14) +%!assert (yi3(:,:,2), ppval (pp,pi), 1e-14) %!assert (yi3(:,:,1), [1,0;2,1;0,-1], 1e-14) %!assert (squeeze (yi1(1,2,:)), [1/sqrt(2); 0; -1/sqrt(2);-1], 1e-14) %!assert (size (yi2), [3,2,5,4])
--- a/scripts/polynomial/poly.m +++ b/scripts/polynomial/poly.m @@ -27,10 +27,10 @@ ## ## @example ## @group -## roots(poly(eye(3))) -## @result{} 1.00001 + 0.00001i -## @result{} 1.00001 - 0.00001i -## @result{} 0.99999 + 0.00000i +## roots (poly (eye (3))) +## @result{} 1.00001 + 0.00001i +## 1.00001 - 0.00001i +## 0.99999 + 0.00000i ## @end group ## @end example ## @@ -81,11 +81,10 @@ endfunction -%!assert(all (all (poly ([1, 2, 3]) == [1, -6, 11, -6]))); - -%!assert(all (all (abs (poly ([1, 2; 3, 4]) - [1, -5, -2]) < sqrt (eps)))); -%!error poly ([1, 2, 3; 4, 5, 6]); +%!assert (poly ([]), 1) +%!assert (poly ([1, 2, 3]), [1, -6, 11, -6]) +%!assert (poly ([1, 2; 3, 4]), [1, -5, -2], sqrt (eps)) -%!assert(poly ([]),1); +%!error poly ([1, 2, 3; 4, 5, 6])
--- a/scripts/polynomial/polyaffine.m +++ b/scripts/polynomial/polyaffine.m @@ -24,13 +24,12 @@ ## representing: ## ## @example -## g(x) = f((x-@var{mu}(1))/@var{mu}(2)). +## g(x) = f( (x - @var{mu}(1)) / @var{mu}(2) ) ## @end example ## ## @seealso{polyval, polyfit} ## @end deftypefn - function g = polyaffine (f, mu) if (nargin != 2)
--- a/scripts/polynomial/polyder.m +++ b/scripts/polynomial/polyder.m @@ -91,9 +91,10 @@ endfunction -%!assert(all (all (polyder ([1, 2, 3]) == [2, 2]))); -%!assert(polyder (13) == 0); +%!assert (polyder ([1, 2, 3], [2, 2])) +%!assert (polyder (13), 0) -%!error polyder ([]); -%!error polyder ([1, 2; 3, 4]); +%!error polyder ([]) +%!error polyder (1,2,3) +%!error <argument must be a vector> polyder ([1, 2; 3, 4])
--- a/scripts/polynomial/polyfit.m +++ b/scripts/polynomial/polyfit.m @@ -22,7 +22,9 @@ ## @deftypefnx {Function File} {[@var{p}, @var{s}, @var{mu}] =} polyfit (@var{x}, @var{y}, @var{n}) ## Return the coefficients of a polynomial @var{p}(@var{x}) of degree ## @var{n} that minimizes the least-squares-error of the fit to the points -## @code{[@var{x}, @var{y}]}. +## @code{[@var{x}, @var{y}]}. If @var{n} is a logical vector, it is used +## as a mask to selectivelly force the corresponding polynomial +## coefficients to be used or ignored. ## ## The polynomial coefficients are returned in a row vector. ## @@ -35,6 +37,11 @@ ## @item X ## The Vandermonde matrix used to compute the polynomial coefficients. ## +## @item C +## The unscaled covariance matrix, formally equal to the inverse of +## @var{x'}*@var{x}, but computed in a way minimizing roundoff error +## propagation. +## ## @item df ## The degrees of freedom. ## @@ -46,7 +53,9 @@ ## @end table ## ## The second output may be used by @code{polyval} to calculate the -## statistical error limits of the predicted values. +## statistical error limits of the predicted values. In particular, the +## standard deviation of @var{p} coefficients is given by @* +## @code{sqrt (diag (s.C)/s.df)*s.normr}. ## ## When the third output, @var{mu}, is present the ## coefficients, @var{p}, are associated with a polynomial in @@ -60,6 +69,8 @@ ## Author: KH <Kurt.Hornik@wu-wien.ac.at> ## Created: 13 December 1994 ## Adapted-By: jwe +## Modified on 20120204 by P. Dupuis; added the ability to specify a +## polynomial mask instead of a polynomial degree. function [p, s, mu] = polyfit (x, y, n) @@ -77,8 +88,16 @@ error ("polyfit: X and Y must be vectors of the same size"); endif - if (! (isscalar (n) && n >= 0 && ! isinf (n) && n == fix (n))) - error ("polyfit: N must be a non-negative integer"); + if (islogical (n)) + polymask = n; + ## n is the polynomial degree as given the polymask size; m is the + ## effective number of used coefficients. + n = length (polymask) - 1; m = sum (polymask) - 1; + else + if (! (isscalar (n) && n >= 0 && ! isinf (n) && n == fix (n))) + error ("polyfit: N must be a non-negative integer"); + endif + polymask = logical (ones (1, n+1)); m = n; endif y_is_row_vector = (rows (y) == 1); @@ -92,10 +111,15 @@ v = vander (x, n+1); ## Solve by QR decomposition. - [q, r, k] = qr (v, 0); + [q, r, k] = qr (v(:, polymask), 0); p = r \ (q' * y); p(k) = p; - + + if (n ~= m) + q = p; p = zeros (n+1, 1); + p(polymask) = q; + endif + if (nargout > 1) yf = v*p; @@ -104,10 +128,28 @@ else s.yf = yf; endif + s.X = v; - s.R = r; - s.X = v; - s.df = l - n - 1; + ## r.'*r is positive definite if X(:, polymask) is of full rank. + ## Invert it by cholinv to avoid taking the square root of squared + ## quantities. If cholinv fails, then X(:, polymask) is rank + ## deficient and not invertible. + try + C = cholinv (r.'*r)(k, k); + catch + C = NaN * ones (m+1, m+1); + end_try_catch + + if (n ~= m) + ## fill matrices if required + s.X(:, ~polymask) = 0; + s.R = zeros (n+1, n+1); s.R(polymask, polymask) = r; + s.C = zeros (n+1, n+1); s.C(polymask, polymask) = C; + else + s.R = r; + s.C = C; + endif + s.df = l - m - 1; s.normr = norm (yf - y); endif @@ -116,23 +158,13 @@ endfunction -%!test -%! x = [-2, -1, 0, 1, 2]; -%! assert(all (all (abs (polyfit (x, x.^2+x+1, 2) - [1, 1, 1]) < sqrt (eps)))); -%!error(polyfit ([1, 2; 3, 4], [1, 2, 3, 4], 2)) - -%!test +%!shared x %! x = [-2, -1, 0, 1, 2]; -%! assert(all (all (abs (polyfit (x, x.^2+x+1, 3) - [0, 1, 1, 1]) < sqrt (eps)))); - -%!test -%! x = [-2, -1, 0, 1, 2]; -%! fail("polyfit (x, x.^2+x+1)"); - -%!test -%! x = [-2, -1, 0, 1, 2]; -%! fail("polyfit (x, x.^2+x+1, [])"); +%!assert (polyfit (x, x.^2+x+1, 2), [1, 1, 1], sqrt (eps)) +%!assert (polyfit (x, x.^2+x+1, 3), [0, 1, 1, 1], sqrt (eps)) +%!fail ("polyfit (x, x.^2+x+1)") +%!fail ("polyfit (x, x.^2+x+1, [])") ## Test difficult case where scaling is really needed. This example ## demonstrates the rather poor result which occurs when the dependent @@ -146,32 +178,33 @@ %! 315600.7143, 315602.9508, 315605.1765 ]; %! [p1, s1] = polyfit (x, y, 10); %! [p2, s2, mu] = polyfit (x, y, 10); -%! assert (s2.normr < s1.normr) +%! assert (s2.normr < s1.normr); %!test %! x = 1:4; %! p0 = [1i, 0, 2i, 4]; %! y0 = polyval (p0, x); -%! p = polyfit (x, y0, numel(p0)-1); -%! assert (p, p0, 1000*eps) +%! p = polyfit (x, y0, numel (p0) - 1); +%! assert (p, p0, 1000*eps); %!test %! x = 1000 + (-5:5); %! xn = (x - mean (x)) / std (x); %! pn = ones (1,5); %! y = polyval (pn, xn); -%! [p, s, mu] = polyfit (x, y, numel(pn)-1); -%! [p2, s2] = polyfit (x, y, numel(pn)-1); -%! assert (p, pn, s.normr) -%! assert (s.yf, y, s.normr) -%! assert (mu, [mean(x), std(x)]) -%! assert (s.normr/s2.normr < sqrt(eps)) +%! [p, s, mu] = polyfit (x, y, numel (pn) - 1); +%! [p2, s2] = polyfit (x, y, numel (pn) - 1); +%! assert (p, pn, s.normr); +%! assert (s.yf, y, s.normr); +%! assert (mu, [mean(x), std(x)]); +%! assert (s.normr/s2.normr < sqrt (eps)); %!test %! x = [1, 2, 3; 4, 5, 6]; %! y = [0, 0, 1; 1, 0, 0]; %! p = polyfit (x, y, 5); -%! expected = [0, 1, -14, 65, -112, 60]/12; -%! assert (p, expected, sqrt(eps)) +%! expected = [0, 1, -14, 65, -112, 60] / 12; +%! assert (p, expected, sqrt (eps)); +%!error <vectors of the same size> polyfit ([1, 2; 3, 4], [1, 2, 3, 4], 2)
--- a/scripts/polynomial/polygcd.m +++ b/scripts/polynomial/polygcd.m @@ -25,16 +25,16 @@ ## Together with deconv, you can reduce a ratio of two polynomials. ## The tolerance @var{tol} defaults to @code{sqrt(eps)}. ## -## @strong{Caution:} This is a numerically unstable algorithm and should not be used on large polynomials. +## @strong{Caution:} This is a numerically unstable algorithm and should not +## be used on large polynomials. ## ## Example code: ## ## @example ## @group -## polygcd (poly(1:8), poly(3:12)) - poly(3:8) +## polygcd (poly (1:8), poly (3:12)) - poly (3:8) ## @result{} [ 0, 0, 0, 0, 0, 0, 0 ] -## deconv (poly(1:8), polygcd (poly(1:8), poly(3:12))) ... -## - poly(1:2) +## deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))) - poly(1:2) ## @result{} [ 0, 0, 0 ] ## @end group ## @end example @@ -82,21 +82,19 @@ %!test -%! poly1 = [1 6 11 6]; % (x+1)(x+2)(x+3) -%! poly2 = [1 3 2]; % (x+1)(x+2) +%! poly1 = [1 6 11 6]; # (x+1)(x+2)(x+3); +%! poly2 = [1 3 2]; # (x+1)(x+2); %! poly3 = polygcd (poly1, poly2); -%! assert (poly3, poly2, sqrt (eps)) +%! assert (poly3, poly2, sqrt (eps)); -%!test -%! assert (polygcd (poly(1:8), poly(3:12)), poly(3:8), sqrt (eps)) - -%!test -%! assert (deconv (poly(1:8), polygcd (poly(1:8), poly(3:12))), poly(1:2), sqrt (eps)) +%!assert (polygcd (poly (1:8), poly (3:12)), poly (3:8), sqrt (eps)) +%!assert (deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))), poly (1:2), sqrt (eps)) %!test %! for ii=1:10 %! p = (unique (randn (10, 1)) * 10).'; %! p1 = p(3:end); %! p2 = p(1:end-2); -%! assert (polygcd (poly (-p1), poly (-p2)), poly (- intersect (p1, p2)), sqrt (eps)) +%! assert (polygcd (poly (-p1), poly (-p2)), poly (- intersect (p1, p2)), sqrt (eps)); %! endfor +
--- a/scripts/polynomial/polyint.m +++ b/scripts/polynomial/polyint.m @@ -61,17 +61,19 @@ endfunction + %!test %! A = [3, 2, 1]; -%! assert (polyint(A),polyint(A,0)); -%! assert (polyint(A),polyint(A')); -%! assert (polyint(A),[1, 1, 1, 0]); -%! assert (polyint(A,1),ones(1,4)); +%! assert (polyint (A), polyint (A,0)); +%! assert (polyint (A), polyint (A')); +%! assert (polyint (A), [1, 1, 1, 0]); +%! assert (polyint (A,1), ones (1,4)); %!test -%! A = ones(1,8); +%! A = ones (1,8); %! B = [length(A):-1:1]; -%! assert (polyint(A),[1./B, 0]); +%! assert (polyint (A), [1./B, 0]); -%!error polyint() -%!error polyint(ones(2,2)) +%!error polyint () +%!error polyint (ones (2,2)) +
--- a/scripts/polynomial/polyout.m +++ b/scripts/polynomial/polyout.m @@ -27,7 +27,7 @@ ## @ifnottex ## ## @example -## c(x) = c(1) * x^n + @dots{} + c(n) x + c(n+1) +## c(x) = c(1) * x^n + @dots{} + c(n) x + c(n+1) ## @end example ## ## @end ifnottex @@ -96,8 +96,11 @@ endif endfunction -%!assert (polyout ([3 2 1]), '3*s^2 + 2*s^1 + 1') -%!assert (polyout ([3 2 1], 'x'), '3*x^2 + 2*x^1 + 1') -%!assert (polyout ([3 2 1], 'wxyz'), '3*wxyz^2 + 2*wxyz^1 + 1') -%!assert (polyout ([5 4 3 2 1], '1'),'5*1^4 + 4*1^3 + 3*1^2 + 2*1^1 + 1') + +%!assert (polyout ([3 2 1]), "3*s^2 + 2*s^1 + 1") +%!assert (polyout ([3 2 1], "x"), "3*x^2 + 2*x^1 + 1") +%!assert (polyout ([3 2 1], "wxyz"), "3*wxyz^2 + 2*wxyz^1 + 1") +%!assert (polyout ([5 4 3 2 1], "1"),"5*1^4 + 4*1^3 + 3*1^2 + 2*1^1 + 1") + %!error polyout ([]) +
--- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -93,20 +93,20 @@ endfunction -%!test -%! fail("polyval([1,0;0,1],0:10)"); + +%!fail ("polyval ([1,0;0,1],0:10)") %!test %! r = 0:10:50; %! p = poly (r); -%! p = p / max(abs(p)); -%! x = linspace(0,50,11); -%! y = polyval(p,x) + 0.25*sin(100*x); -%! [pf, s] = polyfit (x, y, numel(r)); +%! p = p / max (abs (p)); +%! x = linspace (0,50,11); +%! y = polyval (p,x) + 0.25*sin (100*x); +%! [pf, s] = polyfit (x, y, numel (r)); %! [y1, delta] = polyval (pf, x, s); %! expected = [0.37235, 0.35854, 0.32231, 0.32448, 0.31328, ... %! 0.32036, 0.31328, 0.32448, 0.32231, 0.35854, 0.37235]; -%! assert (delta, expected, 0.00001) +%! assert (delta, expected, 0.00001); %!test %! x = 10 + (-2:2); @@ -115,38 +115,39 @@ %! [pn, s, mu] = polyfit (x, y, numel (x) - 1); %! y1 = polyval (p, x); %! yn = polyval (pn, x, [], mu); -%! assert (y1, y, sqrt(eps)) -%! assert (yn, y, sqrt(eps)) +%! assert (y1, y, sqrt (eps)); +%! assert (yn, y, sqrt (eps)); %!test %! p = [0, 1, 0]; %! x = 1:10; -%! assert (x, polyval(p,x), eps) +%! assert (x, polyval (p,x), eps); %! x = x(:); -%! assert (x, polyval(p,x), eps) +%! assert (x, polyval (p,x), eps); %! x = reshape(x, [2, 5]); -%! assert (x, polyval(p,x), eps) +%! assert (x, polyval (p,x), eps); %! x = reshape(x, [5, 2]); -%! assert (x, polyval(p,x), eps) -%! x = reshape(x, [1, 1, 5, 2]); -%! assert (x, polyval(p,x), eps) +%! assert (x, polyval (p,x), eps); +%! x = reshape (x, [1, 1, 5, 2]); +%! assert (x, polyval (p,x), eps); %!test %! p = [1]; %! x = 1:10; -%! y = ones(size(x)); -%! assert (y, polyval(p,x), eps) +%! y = ones (size (x)); +%! assert (y, polyval (p,x), eps); %! x = x(:); -%! y = ones(size(x)); -%! assert (y, polyval(p,x), eps) -%! x = reshape(x, [2, 5]); -%! y = ones(size(x)); -%! assert (y, polyval(p,x), eps) -%! x = reshape(x, [5, 2]); -%! y = ones(size(x)); -%! assert (y, polyval(p,x), eps) -%! x = reshape(x, [1, 1, 5, 2]); +%! y = ones (size (x)); +%! assert (y, polyval (p,x), eps); +%! x = reshape (x, [2, 5]); +%! y = ones (size (x)); +%! assert (y, polyval (p,x), eps); +%! x = reshape (x, [5, 2]); +%! y = ones (size (x)); +%! assert (y, polyval (p,x), eps); +%! x = reshape (x, [1, 1, 5, 2]); %!assert (zeros (1, 10), polyval ([], 1:10)) %!assert ([], polyval (1, [])) %!assert ([], polyval ([], [])) +
--- a/scripts/polynomial/polyvalm.m +++ b/scripts/polynomial/polyvalm.m @@ -61,8 +61,8 @@ endfunction -%!assert(! any (polyvalm ([], [1, 2; 3, 4]))(:)); -%!assert(polyvalm ([1, 2, 3, 4], [3, -4, 1; -2, 0, 2; -1, 4, -3]), [117, -124, 11; -70, 36, 38; -43, 92, -45]) +%!assert (! any (polyvalm ([], [1, 2; 3, 4]))(:)); +%!assert (polyvalm ([1, 2, 3, 4], [3, -4, 1; -2, 0, 2; -1, 4, -3]), [117, -124, 11; -70, 36, 38; -43, 92, -45]) -%!error polyvalm ([1, 1, 1], [1, 2; 3, 4; 5, 6]); +%!error <must be a square matrix> polyvalm ([1, 1, 1], [1, 2; 3, 4; 5, 6])
--- a/scripts/polynomial/ppder.m +++ b/scripts/polynomial/ppder.m @@ -51,20 +51,24 @@ ppd = mkpp (x, pd, d); endfunction + %!shared x,y,pp,ppd -%! x=0:8;y=[x.^2;x.^3+1];pp=spline(x,y); -%! ppd=ppder(pp); -%!assert(ppval(ppd,x),[2*x;3*x.^2],1e-14) -%!assert(ppd.order,3) -%! ppd=ppder(pp,2); -%!assert(ppval(ppd,x),[2*ones(size(x));6*x],1e-14) -%!assert(ppd.order,2) -%! ppd=ppder(pp,3); -%!assert(ppd.order,1) -%!assert(ppd.pieces,8) -%!assert(size(ppd.coefs),[16,1]) -%! ppd=ppder(pp,4); -%!assert(ppd.order,1) -%!assert(ppd.pieces,1) -%!assert(size(ppd.coefs),[2,1]) -%!assert(ppval(ppd,x),zeros(size(y)),1e-14) +%! x = 0:8; +%! y = [x.^2; x.^3+1]; +%! pp = spline (x, y); +%! ppd = ppder (pp); +%!assert (ppval (ppd, x), [2*x; 3*x.^2], 1e-14) +%!assert (ppd.order, 3) +%! ppd = ppder (pp, 2); +%!assert (ppval (ppd, x), [2*ones(size (x)); 6*x], 1e-14) +%!assert (ppd.order, 2) +%! ppd = ppder (pp, 3); +%!assert (ppd.order, 1) +%!assert (ppd.pieces, 8) +%!assert (size (ppd.coefs), [16, 1]) +%! ppd = ppder (pp, 4); +%!assert (ppd.order, 1) +%!assert (ppd.pieces, 1) +%!assert (size (ppd.coefs), [2, 1]) +%!assert (ppval (ppd,x), zeros (size (y)), 1e-14) +
--- a/scripts/polynomial/ppint.m +++ b/scripts/polynomial/ppint.m @@ -51,8 +51,12 @@ endfunction + %!shared x,y,pp,ppi -%! x=0:8;y=[ones(size(x));x+1];pp=spline(x,y); -%! ppi=ppint(pp); -%!assert(ppval(ppi,x),[x;0.5*x.^2+x],1e-14) -%!assert(ppi.order,5) +%! x = 0:8; +%! y = [ ones(size(x)); x+1 ]; +%! pp = spline (x, y); +%! ppi = ppint (pp); +%!assert (ppval (ppi, x), [x; 0.5*x.^2 + x], 1e-14) +%!assert (ppi.order, 5) +
--- a/scripts/polynomial/ppjumps.m +++ b/scripts/polynomial/ppjumps.m @@ -64,21 +64,20 @@ %! y = polyval (p, x); %! pp = spline (x, y); %! jj = ppjumps (pp); -%! assert (jj, [0 0], eps) +%! assert (jj, [0 0], eps); %!test -%! %! breaks = [0 1 2]; %! pp1 = poly (-[1 2 3]); %! pp2 = poly (-([1 2 3]+1)); %! pp = mkpp (breaks, [pp1;pp2]); -%! assert (ppjumps (pp), 0, eps) +%! assert (ppjumps (pp), 0, eps); %!test -%! %! breaks = [0 1 2]; %! pp1 = poly (-[1 2 3]); %! pp2 = poly (([1 2 3]+1)); %! pp = mkpp (breaks, [pp1;pp2]); %! j = - 2 * polyval (pp1, 1); -%! assert (ppjumps (pp), j, eps) +%! assert (ppjumps (pp), j, eps); +
--- a/scripts/polynomial/ppval.m +++ b/scripts/polynomial/ppval.m @@ -102,15 +102,21 @@ endfunction -%!shared b,c,pp,pp2,xi,abserr -%! b = 1:3; c = ones(2); pp=mkpp(b,c);abserr = 1e-14;pp2=mkpp(b,[c;c],2); + +%!shared b, c, pp, pp2, xi, abserr +%! b = 1:3; +%! c = ones (2); +%! pp = mkpp (b, c); +%! abserr = 1e-14; +%! pp2 = mkpp (b, [c;c], 2); %! xi = [1.1 1.3 1.9 2.1]; -%!assert (ppval(pp,1.1), 1.1, abserr); -%!assert (ppval(pp,2.1), 1.1, abserr); -%!assert (ppval(pp,xi), [1.1 1.3 1.9 1.1], abserr); -%!assert (ppval(pp,xi.'), [1.1 1.3 1.9 1.1].', abserr); -%!assert (ppval(pp2,1.1), [1.1;1.1], abserr); -%!assert (ppval(pp2,2.1), [1.1;1.1], abserr); -%!assert (ppval(pp2,xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr); -%!assert (ppval(pp2,xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr); -%!assert (size(ppval(pp2,[xi;xi])), [2 2 4]); +%!assert (ppval (pp, 1.1), 1.1, abserr) +%!assert (ppval (pp, 2.1), 1.1, abserr) +%!assert (ppval (pp, xi), [1.1 1.3 1.9 1.1], abserr) +%!assert (ppval (pp, xi.'), [1.1 1.3 1.9 1.1].', abserr) +%!assert (ppval (pp2, 1.1), [1.1;1.1], abserr) +%!assert (ppval (pp2, 2.1), [1.1;1.1], abserr) +%!assert (ppval (pp2, xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr) +%!assert (ppval (pp2, xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr) +%!assert (size (ppval (pp2, [xi;xi])), [2 2 4]) +
--- a/scripts/polynomial/residue.m +++ b/scripts/polynomial/residue.m @@ -33,9 +33,9 @@ ## ## @example ## @group -## B(s) M r(m) N -## ---- = SUM ------------- + SUM k(i)*s^(N-i) -## A(s) m=1 (s-p(m))^e(m) i=1 +## B(s) M r(m) N +## ---- = SUM ------------- + SUM k(i)*s^(N-i) +## A(s) m=1 (s-p(m))^e(m) i=1 ## @end group ## @end example ## @@ -52,11 +52,11 @@ ## @group ## b = [1, 1, 1]; ## a = [1, -5, 8, -4]; -## [r, p, k, e] = residue (b, a); -## @result{} r = [-2; 7; 3] -## @result{} p = [2; 2; 1] -## @result{} k = [](0x0) -## @result{} e = [1; 2; 1] +## [r, p, k, e] = residue (b, a) +## @result{} r = [-2; 7; 3] +## @result{} p = [2; 2; 1] +## @result{} k = [](0x0) +## @result{} e = [1; 2; 1] ## @end group ## @end example ## @@ -95,12 +95,11 @@ ## r = [-2; 7; 3]; ## p = [2; 2; 1]; ## k = [1, 0]; -## [b, a] = residue (r, p, k); -## @result{} b = [1, -5, 9, -3, 1] -## @result{} a = [1, -5, 8, -4] +## [b, a] = residue (r, p, k) +## @result{} b = [1, -5, 9, -3, 1] +## @result{} a = [1, -5, 8, -4] ## ## where mpoles is used to determine e = [1; 2; 1] -## ## @end group ## @end example ## @@ -112,9 +111,9 @@ ## p = [2; 1; 2]; ## k = [1, 0]; ## e = [2; 1; 1]; -## [b, a] = residue (r, p, k, e); -## @result{} b = [1, -5, 9, -3, 1] -## @result{} a = [1, -5, 8, -4] +## [b, a] = residue (r, p, k, e) +## @result{} b = [1, -5, 9, -3, 1] +## @result{} a = [1, -5, 8, -4] ## @end group ## @end example ## @@ -129,9 +128,9 @@ ## ## @example ## @group -## -2 7 3 s^4 - 5s^3 + 9s^2 - 3s + 1 -## ----- + ------- + ----- + s = -------------------------- -## (s-2) (s-2)^2 (s-1) s^3 - 5s^2 + 8s - 4 +## -2 7 3 s^4 - 5s^3 + 9s^2 - 3s + 1 +## ----- + ------- + ----- + s = -------------------------- +## (s-2) (s-2)^2 (s-1) s^3 - 5s^2 + 8s - 4 ## @end group ## @end example ## @@ -352,23 +351,24 @@ endfunction + %!test %! b = [1, 1, 1]; %! a = [1, -5, 8, -4]; %! [r, p, k, e] = residue (b, a); -%! assert (abs (r - [-2; 7; 3]) < 1e-12 -%! && abs (p - [2; 2; 1]) < 1e-12 -%! && isempty (k) -%! && e == [1; 2; 1]); +%! assert (r, [-2; 7; 3], 1e-12); +%! assert (p, [2; 2; 1], 1e-12); +%! assert (isempty (k)); +%! assert (e, [1; 2; 1]); %! k = [1 0]; %! b = conv (k, a) + prepad (b, numel (k) + numel (a) - 1, 0); %! a = a; %! [br, ar] = residue (r, p, k); -%! assert ((abs (br - b) < 1e-12 -%! && abs (ar - a) < 1e-12)); +%! assert (br, b, 1e-12); +%! assert (ar, a, 1e-12); %! [br, ar] = residue (r, p, k, e); -%! assert ((abs (br - b) < 1e-12 -%! && abs (ar - a) < 1e-12)); +%! assert (br, b, 1e-12); +%! assert (ar, a, 1e-12); %!test %! b = [1, 0, 1]; @@ -376,12 +376,13 @@ %! [r, p, k, e] = residue (b, a); %! r1 = [-5i; 12; +5i; 12]/54; %! p1 = [+3i; +3i; -3i; -3i]; -%! assert (abs (r - r1) < 1e-12 && abs (p - p1) < 1e-12 -%! && isempty (k) -%! && e == [1; 2; 1; 2]); +%! assert (r, r1, 1e-12); +%! assert (p, p1, 1e-12); +%! assert (isempty (k)); +%! assert (e, [1; 2; 1; 2]); %! [br, ar] = residue (r, p, k); -%! assert ((abs (br - b) < 1e-12 -%! && abs (ar - a) < 1e-12)); +%! assert (br, b, 1e-12); +%! assert (ar, a, 1e-12); %!test %! r = [7; 3; -2]; @@ -389,14 +390,14 @@ %! k = [1 0]; %! e = [2; 1; 1]; %! [b, a] = residue (r, p, k, e); -%! assert ((abs (b - [1, -5, 9, -3, 1]) < 1e-12 -%! && abs (a - [1, -5, 8, -4]) < 1e-12)); +%! assert (b, [1, -5, 9, -3, 1], 1e-12); +%! assert (a, [1, -5, 8, -4], 1e-12); %! [rr, pr, kr, er] = residue (b, a); -%! [jnk, n] = mpoles(p); -%! assert ((abs (rr - r(n)) < 1e-12 -%! && abs (pr - p(n)) < 1e-12 -%! && abs (kr - k) < 1e-12 -%! && abs (er - e(n)) < 1e-12)); +%! [jnk, n] = mpoles (p); +%! assert (rr, r(n), 1e-12); +%! assert (pr, p(n), 1e-12); +%! assert (kr, k, 1e-12); +%! assert (er, e(n), 1e-12); %!test %! b = [1]; @@ -404,12 +405,13 @@ %! [r, p, k, e] = residue (b, a); %! r1 = [0; 1]; %! p1 = [-5; -5]; -%! assert (abs (r - r1) < 1e-12 && abs (p - p1) < 1e-12 -%! && isempty (k) -%! && e == [1; 2]); +%! assert (r, r1, 1e-12); +%! assert (p, p1, 1e-12); +%! assert (isempty (k)); +%! assert (e, [1; 2]); %! [br, ar] = residue (r, p, k); -%! assert ((abs (br - b) < 1e-12 -%! && abs (ar - a) < 1e-12)); +%! assert (br, b, 1e-12); +%! assert (ar, a, 1e-12); ## The following test is due to Bernard Grung (bug #34266) %!xtest @@ -429,3 +431,4 @@ %! [br, ar] = residue (r, p, k, e); %! assert (br, b, 1e-8); %! assert (ar, a, 1e-8); +
--- a/scripts/polynomial/roots.m +++ b/scripts/polynomial/roots.m @@ -118,24 +118,22 @@ endfunction + %!test %! p = [poly([3 3 3 3]), 0 0 0 0]; %! r = sort (roots (p)); -%! assert (r, [0; 0; 0; 0; 3; 3; 3; 3], 0.001) - -%!assert(all (all (abs (roots ([1, -6, 11, -6]) - [3; 2; 1]) < sqrt (eps)))); - -%!assert(isempty (roots ([]))); - -%!error roots ([1, 2; 3, 4]); +%! assert (r, [0; 0; 0; 0; 3; 3; 3; 3], 0.001); -%!assert(isempty (roots (1))); - -%!error roots ([1, 2; 3, 4]); - -%!error roots ([1 Inf 1]); - -%!error roots ([1 NaN 1]); +%!assert (isempty (roots ([]))) +%!assert (isempty (roots (1))) +%!assert (roots ([1, -6, 11, -6]), [3; 2; 1], sqrt (eps)) %!assert(roots ([1e-200, -1e200, 1]), 1e-200) %!assert(roots ([1e-200, -1e200 * 1i, 1]), -1e-200 * 1i) + +%!error roots () +%!error roots (1,2) +%!error roots ([1, 2; 3, 4]) +%!error <inputs must not contain Inf or NaN> roots ([1 Inf 1]) +%!error <inputs must not contain Inf or NaN> roots ([1 NaN 1]) +
--- a/scripts/polynomial/spline.m +++ b/scripts/polynomial/spline.m @@ -247,8 +247,8 @@ %!demo %! x = 0:10; y = sin (x); -%! xspline = 0:0.1:10; yspline = spline (x,y,xspline); -%! title ("spline fit to points from sin(x)"); +%! xspline = 0:0.1:10; yspline = spline (x,y,xspline); +%! title ("spline fit to points from sin (x)"); %! plot (xspline,sin(xspline),"r", xspline,yspline,"g-", x,y,"b+"); %! legend ("original", "interpolation", "interpolation points"); %! %-------------------------------------------------------- @@ -266,7 +266,7 @@ %!assert (spline (x,[y;y],x'), [spline(x,y,x);spline(x,y,x)], abserr) %!assert (spline (x',[y;y],x), [spline(x,y,x);spline(x,y,x)], abserr) %!assert (spline (x',[y;y],x'), [spline(x,y,x);spline(x,y,x)], abserr) -%! y = cos(x) + i*sin(x); +%! y = cos (x) + i*sin (x); %!assert (spline (x,y,x), y, abserr) %!assert (real (spline (x,y,x)), real (y), abserr) %!assert (real (spline (x,y,x.')), real (y).', abserr)
--- a/scripts/set/intersect.m +++ b/scripts/set/intersect.m @@ -87,29 +87,30 @@ %!test %! a = [3 2 4 5 7 6 5 1 0 13 13]; %! b = [3 5 12 1 1 7]; -%! [c,ia,ib] = intersect(a,b); -%! assert(c,[1 3 5 7]); -%! assert(ia,[8 1 7 5]); -%! assert(ib,[5 1 2 6]); -%! assert(a(ia),c); -%! assert(b(ib),c); +%! [c,ia,ib] = intersect (a, b); +%! assert (c, [1 3 5 7]); +%! assert (ia, [8 1 7 5]); +%! assert (ib, [5 1 2 6]); +%! assert (a(ia), c); +%! assert (b(ib), c); %!test %! a = [1,1,2;1,4,5;2,1,7]; %! b = [1,4,5;2,3,4;1,1,2;9,8,7]; -%! [c,ia,ib] = intersect(a,b,'rows'); -%! assert(c,[1,1,2;1,4,5]); -%! assert(ia,[1;2]); -%! assert(ib,[3;1]); -%! assert(a(ia,:),c); -%! assert(b(ib,:),c); +%! [c,ia,ib] = intersect (a, b, "rows"); +%! assert (c, [1,1,2;1,4,5]); +%! assert (ia, [1;2]); +%! assert (ib, [3;1]); +%! assert (a(ia,:), c); +%! assert (b(ib,:), c); %!test %! a = [1 1 1 2 2 2]; %! b = [1 2 3 4 5 6]; -%! c = intersect(a,b); +%! c = intersect (a, b); %! assert(c, [1,2]); %!test %! a = [1 2 3 4; 5 6 7 8; 9 10 11 12]; -%! [b, ia, ib] = intersect(a, a, "rows"); -%! assert(b, a); -%! assert(ia, [1:3]'); -%! assert(ib, [1:3]'); +%! [b, ia, ib] = intersect (a, a, "rows"); +%! assert (b, a); +%! assert (ia, [1:3]'); +%! assert (ib, [1:3]'); +
--- a/scripts/set/ismember.m +++ b/scripts/set/ismember.m @@ -30,7 +30,7 @@ ## @group ## a = [3, 10, 1]; ## s = [0:9]; -## [tf, s_idx] = ismember (a, s); +## [tf, s_idx] = ismember (a, s) ## @result{} tf = [1, 0, 1] ## @result{} s_idx = [4, 0, 2] ## @end group @@ -40,9 +40,9 @@ ## ## @example ## @group -## a = @{'abc'@}; -## s = @{'abc', 'def'@}; -## [tf, s_idx] = ismember (a, s); +## a = @{"abc"@}; +## s = @{"abc", "def"@}; +## [tf, s_idx] = ismember (a, s) ## @result{} tf = [1, 0] ## @result{} s_idx = [1, 0] ## @end group @@ -56,7 +56,7 @@ ## @group ## a = [1:3; 5:7; 4:6]; ## s = [0:2; 1:3; 2:4; 3:5; 4:6]; -## [tf, s_idx] = ismember(a, s, 'rows'); +## [tf, s_idx] = ismember(a, s, "rows") ## @result{} tf = logical ([1; 0; 1]) ## @result{} s_idx = [2; 0; 5]; ## @end group @@ -133,29 +133,30 @@ endfunction -%!assert (ismember ({''}, {'abc', 'def'}), false); -%!assert (ismember ('abc', {'abc', 'def'}), true); -%!assert (isempty (ismember ([], [1, 2])), true); -%!assert (isempty (ismember ({}, {'a', 'b'})), true); -%!assert (ismember ('', {'abc', 'def'}), false); -%!fail ('ismember ([], {1, 2})'); -%!fail ('ismember ({[]}, {1, 2})'); -%!fail ('ismember ({}, {1, 2})'); -%!fail ('ismember ({1}, {''1'', ''2''})'); -%!fail ('ismember (1, ''abc'')'); -%!fail ('ismember ({''1''}, {''1'', ''2''},''rows'')'); -%!fail ('ismember ([1 2 3], [5 4 3 1], ''rows'')'); -%!assert (ismember ({'foo', 'bar'}, {'foobar'}), logical ([0, 0])); -%!assert (ismember ({'foo'}, {'foobar'}), false); -%!assert (ismember ({'bar'}, {'foobar'}), false); -%!assert (ismember ({'bar'}, {'foobar', 'bar'}), true); -%!assert (ismember ({'foo', 'bar'}, {'foobar', 'bar'}), logical ([0, 1])); -%!assert (ismember ({'xfb', 'f', 'b'}, {'fb', 'b'}), logical ([0, 0, 1])); -%!assert (ismember ("1", "0123456789."), true); + +%!assert (ismember ({""}, {"abc", "def"}), false) +%!assert (ismember ("abc", {"abc", "def"}), true) +%!assert (isempty (ismember ([], [1, 2])), true) +%!assert (isempty (ismember ({}, {'a', 'b'})), true) +%!assert (ismember ("", {"abc", "def"}), false) +%!fail ("ismember ([], {1, 2})") +%!fail ("ismember ({[]}, {1, 2})") +%!fail ("ismember ({}, {1, 2})") +%!fail ("ismember ({1}, {'1', '2'})") +%!fail ("ismember (1, 'abc')") +%!fail ("ismember ({'1'}, {'1' '2'},'rows')") +%!fail ("ismember ([1 2 3], [5 4 3 1], 'rows')") +%!assert (ismember ({"foo", "bar"}, {"foobar"}), [false false]) +%!assert (ismember ({"foo"}, {"foobar"}), false) +%!assert (ismember ({"bar"}, {"foobar"}), false) +%!assert (ismember ({"bar"}, {"foobar", "bar"}), true) +%!assert (ismember ({"foo", "bar"}, {"foobar", "bar"}), [false true]) +%!assert (ismember ({"xfb", "f", "b"}, {"fb", "b"}), [false false true]) +%!assert (ismember ("1", "0123456789."), true) %!test %! [result, a_idx] = ismember ([1, 2], []); -%! assert (result, logical ([0, 0])) +%! assert (result, [false false]) %! assert (a_idx, [0, 0]); %!test @@ -164,46 +165,52 @@ %! assert (a_idx, []); %!test -%! [result, a_idx] = ismember ({'a', 'b'}, ''); -%! assert (result, logical ([0, 0])) +%! [result, a_idx] = ismember ({"a", "b"}, ""); +%! assert (result, [false false]) %! assert (a_idx, [0, 0]); %!test -%! [result, a_idx] = ismember ({'a', 'b'}, {}); -%! assert (result, logical ([0, 0])) +%! [result, a_idx] = ismember ({"a", "b"}, {}); +%! assert (result, [false false]) %! assert (a_idx, [0, 0]); %!test -%! [result, a_idx] = ismember ('', {'a', 'b'}); +%! [result, a_idx] = ismember ("", {"a", "b"}); %! assert (result, false) %! assert (a_idx, 0); %!test -%! [result, a_idx] = ismember ({}, {'a', 'b'}); +%! [result, a_idx] = ismember ({}, {"a", "b"}); %! assert (result, logical ([])) %! assert (a_idx, []); %!test %! [result, a_idx] = ismember([1 2 3 4 5], [3]); -%! assert (all (result == logical ([0 0 1 0 0])) && all (a_idx == [0 0 1 0 0])); +%! assert (result, logical ([0 0 1 0 0])) +%! assert (a_idx , [0 0 1 0 0]); %!test %! [result, a_idx] = ismember([1 6], [1 2 3 4 5 1 6 1]); -%! assert (all (result == logical ([1 1])) && a_idx(2) == 7); +%! assert (result, [true true]); +%! assert (a_idx(2), 7); %!test %! [result, a_idx] = ismember ([3,10,1], [0,1,2,3,4,5,6,7,8,9]); -%! assert (all (result == logical ([1, 0, 1])) && all (a_idx == [4, 0, 2])); +%! assert (result, [true false true]); +%! assert (a_idx, [4, 0, 2]); %!test %! [result, a_idx] = ismember ("1.1", "0123456789.1"); -%! assert (all (result == logical ([1, 1, 1])) && all (a_idx == [12, 11, 12])); +%! assert (result, [true true true]); +%! assert (a_idx, [12, 11, 12]); %!test -%! [result, a_idx] = ismember([1:3; 5:7; 4:6], [0:2; 1:3; 2:4; 3:5; 4:6], 'rows'); -%! assert (all (result == logical ([1; 0; 1])) && all (a_idx == [2; 0; 5])); +%! [result, a_idx] = ismember ([1:3; 5:7; 4:6], [0:2; 1:3; 2:4; 3:5; 4:6], "rows"); +%! assert (result, [true; false; true]); +%! assert (a_idx, [2; 0; 5]); %!test -%! [result, a_idx] = ismember([1.1,1.2,1.3; 2.1,2.2,2.3; 10,11,12], [1.1,1.2,1.3; 10,11,12; 2.12,2.22,2.32], 'rows'); -%! assert (all (result == logical ([1; 0; 1])) && all (a_idx == [1; 0; 2])); +%! [result, a_idx] = ismember ([1.1,1.2,1.3; 2.1,2.2,2.3; 10,11,12], [1.1,1.2,1.3; 10,11,12; 2.12,2.22,2.32], "rows"); +%! assert (result, [true; false; true]); +%! assert (a_idx, [1; 0; 2]);
--- a/scripts/set/powerset.m +++ b/scripts/set/powerset.m @@ -81,3 +81,4 @@ %! c = sort (cellstr ({ [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]})); %! p = sort (cellstr (powerset ([1, 2, 3]))); %! assert (p, c); +
--- a/scripts/set/setdiff.m +++ b/scripts/set/setdiff.m @@ -90,16 +90,18 @@ endfunction -%!assert(setdiff(["bb";"zz";"bb";"zz"],["bb";"cc";"bb"],"rows"), "zz") -%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"],"rows"), "z") -%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"]), "z") -%!assert(setdiff([1, 1; 2, 2; 3, 3; 4, 4], [1, 1; 2, 2; 4, 4], "rows"), [3 3]) -%!assert(setdiff([1; 2; 3; 4], [1; 2; 4], "rows"), 3) -%!assert(setdiff([1, 2; 3, 4], [1, 2; 3, 6], "rows"), [3, 4]) -%!assert(setdiff({"one","two";"three","four"},{"one","two";"three","six"}), {"four"}) + +%!assert (setdiff (["bb";"zz";"bb";"zz"], ["bb";"cc";"bb"], "rows"), "zz") +%!assert (setdiff (["b";"z";"b";"z"], ["b";"c";"b"], "rows"), "z") +%!assert (setdiff (["b";"z";"b";"z"], ["b";"c";"b"]), "z") +%!assert (setdiff ([1, 1; 2, 2; 3, 3; 4, 4], [1, 1; 2, 2; 4, 4], "rows"), [3 3]) +%!assert (setdiff ([1; 2; 3; 4], [1; 2; 4], "rows"), 3) +%!assert (setdiff ([1, 2; 3, 4], [1, 2; 3, 6], "rows"), [3, 4]) +%!assert (setdiff ({"one","two";"three","four"}, {"one","two";"three","six"}), {"four"}) %!test -%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; +%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; %! [y, i] = setdiff (a, b.'); -%! assert(y, [5]); -%! assert(y, a(i)); +%! assert (y, [5]); +%! assert (y, a(i)); +
--- a/scripts/set/setxor.m +++ b/scripts/set/setxor.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} setxor (@var{a}, @var{b}) -## @deftypefnx {Function File} {} setxor (@var{a}, @var{b}, 'rows') +## @deftypefnx {Function File} {} setxor (@var{a}, @var{b}, "rows") ## @deftypefnx {Function File} {[@var{c}, @var{ia}, @var{ib}] =} setxor (@var{a}, @var{b}) ## ## Return the elements exclusive to @var{a} or @var{b}, sorted in ascending @@ -91,11 +91,12 @@ endfunction -%!assert(setxor([1,2,3],[2,3,4]),[1,4]) -%!assert(setxor({'a'}, {'a', 'b'}), {'b'}); + +%!assert (setxor ([1,2,3],[2,3,4]),[1,4]) +%!assert (setxor ({'a'}, {'a', 'b'}), {'b'}) %!test -%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; +%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; %! [y, ia, ib] = setxor (a, b.'); -%! assert(y, [2, 5]); -%! assert(y, sort([a(ia), b(ib)])); +%! assert (y, [2, 5]); +%! assert (y, sort([a(ia), b(ib)]));
--- a/scripts/set/union.m +++ b/scripts/set/union.m @@ -27,7 +27,7 @@ ## @example ## @group ## union ([1, 2, 4], [2, 3, 5]) -## @result{} [1, 2, 3, 4, 5] +## @result{} [1, 2, 3, 4, 5] ## @end group ## @end example ## @@ -37,18 +37,17 @@ ## ## @example ## @group -## union([1, 2; 2, 3], [1, 2; 3, 4], "rows") -## @result{} 1 2 -## 2 3 -## 3 4 +## union ([1, 2; 2, 3], [1, 2; 3, 4], "rows") +## @result{} 1 2 +## 2 3 +## 3 4 ## @end group ## @end example ## ## @deftypefnx {Function File} {[@var{c}, @var{ia}, @var{ib}] =} union (@var{a}, @var{b}) ## ## Return index vectors @var{ia} and @var{ib} such that @code{a(ia)} and -## @code{b(ib)} are -## disjoint sets whose union is @var{c}. +## @code{b(ib)} are disjoint sets whose union is @var{c}. ## ## @seealso{intersect, setdiff, unique} ## @end deftypefn @@ -84,18 +83,17 @@ endfunction -%!assert(all (all (union ([1, 2, 4], [2, 3, 5]) == [1, 2, 3, 4, 5]))); -%!assert(all (all (union ([1; 2; 4], [2, 3, 5]) == [1, 2, 3, 4, 5]))); - -%!assert(all (all (union ([1, 2, 3], [5; 7; 9]) == [1, 2, 3, 5, 7, 9]))); - -%!error union (1); - -%!error union (1, 2, 3); +%!assert (union ([1, 2, 4], [2, 3, 5]), [1, 2, 3, 4, 5]); +%!assert (union ([1; 2; 4], [2, 3, 5]), [1, 2, 3, 4, 5]); +%!assert (union ([1, 2, 3], [5; 7; 9]), [1, 2, 3, 5, 7, 9]); %!test -%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; +%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; %! [y, ia, ib] = union (a, b.'); -%! assert(y, [1, 2, 3, 4, 5]); -%! assert(y, sort([a(ia), b(ib)])); +%! assert (y, [1, 2, 3, 4, 5]); +%! assert (y, sort ([a(ia), b(ib)])); + +%!error union (1) +%!error union (1, 2, 3) +
--- a/scripts/set/unique.m +++ b/scripts/set/unique.m @@ -163,52 +163,54 @@ endfunction -%!assert(unique([1 1 2; 1 2 1; 1 1 2]),[1;2]) -%!assert(unique([1 1 2; 1 0 1; 1 1 2],'rows'),[1 0 1; 1 1 2]) -%!assert(unique([]),[]) -%!assert(unique([1]),[1]) -%!assert(unique([1 2]),[1 2]) -%!assert(unique([1;2]),[1;2]) -%!assert(unique([1,NaN,Inf,NaN,Inf]),[1,Inf,NaN,NaN]) -%!assert(unique({'Foo','Bar','Foo'}),{'Bar','Foo'}) -%!assert(unique({'Foo','Bar','FooBar'}'),{'Bar','Foo','FooBar'}') -%!assert(unique(zeros(1,0)), zeros(0,1)) -%!assert(unique(zeros(1,0), 'rows'), zeros(1,0)) -%!assert(unique(cell(1,0)), cell(0,1)) -%!assert(unique({}), {}) -%!assert(unique([1,2,2,3,2,4], 'rows'), [1,2,2,3,2,4]) -%!assert(unique([1,2,2,3,2,4]), [1,2,3,4]) -%!assert(unique([1,2,2,3,2,4]', 'rows'), [1,2,3,4]') -%!assert(unique(sparse([2,0;2,0])), [0,2]') -%!assert(unique(sparse([1,2;2,3])), [1,2,3]') -%!assert(unique([1,2,2,3,2,4]', 'rows'), [1,2,3,4]') -%!assert(unique(single([1,2,2,3,2,4]), 'rows'), single([1,2,2,3,2,4])) -%!assert(unique(single([1,2,2,3,2,4])), single([1,2,3,4])) -%!assert(unique(single([1,2,2,3,2,4]'), 'rows'), single([1,2,3,4]')) -%!assert(unique(uint8([1,2,2,3,2,4]), 'rows'), uint8([1,2,2,3,2,4])) -%!assert(unique(uint8([1,2,2,3,2,4])), uint8([1,2,3,4])) -%!assert(unique(uint8([1,2,2,3,2,4]'), 'rows'), uint8([1,2,3,4]')) + +%!assert (unique ([1 1 2; 1 2 1; 1 1 2]),[1;2]) +%!assert (unique ([1 1 2; 1 0 1; 1 1 2],"rows"),[1 0 1; 1 1 2]) +%!assert (unique ([]),[]) +%!assert (unique ([1]),[1]) +%!assert (unique ([1 2]),[1 2]) +%!assert (unique ([1;2]),[1;2]) +%!assert (unique ([1,NaN,Inf,NaN,Inf]),[1,Inf,NaN,NaN]) +%!assert (unique ({"Foo","Bar","Foo"}),{"Bar","Foo"}) +%!assert (unique ({"Foo","Bar","FooBar"}'),{"Bar","Foo","FooBar"}') +%!assert (unique (zeros (1,0)), zeros (0,1)) +%!assert (unique (zeros (1,0), "rows"), zeros (1,0)) +%!assert (unique (cell (1,0)), cell (0,1)) +%!assert (unique ({}), {}) +%!assert (unique ([1,2,2,3,2,4], "rows"), [1,2,2,3,2,4]) +%!assert (unique ([1,2,2,3,2,4]), [1,2,3,4]) +%!assert (unique ([1,2,2,3,2,4]', "rows"), [1,2,3,4]') +%!assert (unique (sparse ([2,0;2,0])), [0,2]') +%!assert (unique (sparse ([1,2;2,3])), [1,2,3]') +%!assert (unique ([1,2,2,3,2,4]', "rows"), [1,2,3,4]') +%!assert (unique (single ([1,2,2,3,2,4]), "rows"), single ([1,2,2,3,2,4])) +%!assert (unique (single ([1,2,2,3,2,4])), single ([1,2,3,4])) +%!assert (unique (single ([1,2,2,3,2,4]'), "rows"), single ([1,2,3,4]')) +%!assert (unique (uint8 ([1,2,2,3,2,4]), "rows"), uint8 ([1,2,2,3,2,4])) +%!assert (unique (uint8 ([1,2,2,3,2,4])), uint8 ([1,2,3,4])) +%!assert (unique (uint8 ([1,2,2,3,2,4]'), "rows"), uint8 ([1,2,3,4]')) %!test -%! [a,i,j] = unique([1,1,2,3,3,3,4]); -%! assert(a,[1,2,3,4]) -%! assert(i,[2,3,6,7]) -%! assert(j,[1,1,2,3,3,3,4]) +%! [a,i,j] = unique ([1,1,2,3,3,3,4]); +%! assert (a, [1,2,3,4]); +%! assert (i, [2,3,6,7]); +%! assert (j, [1,1,2,3,3,3,4]); %! %!test -%! [a,i,j] = unique([1,1,2,3,3,3,4]','first'); -%! assert(a,[1,2,3,4]') -%! assert(i,[1,3,4,7]') -%! assert(j,[1,1,2,3,3,3,4]') +%! [a,i,j] = unique ([1,1,2,3,3,3,4]', "first"); +%! assert (a, [1,2,3,4]'); +%! assert (i, [1,3,4,7]'); +%! assert (j, [1,1,2,3,3,3,4]'); %! %!test -%! [a,i,j] = unique({'z'; 'z'; 'z'}); -%! assert(a,{'z'}) -%! assert(i,[3]') -%! assert(j,[1,1,1]') +%! [a,i,j] = unique ({"z"; "z"; "z"}); +%! assert (a, {"z"}); +%! assert (i, [3]'); +%! assert (j, [1;1;1]); %! %!test -%! A=[1,2,3;1,2,3]; -%! [a,i,j] = unique(A,'rows'); -%! assert(a,[1,2,3]) -%! assert(A(i,:),a) -%! assert(a(j,:),A) +%! A = [1,2,3;1,2,3]; +%! [a,i,j] = unique (A, "rows"); +%! assert (a, [1,2,3]); +%! assert (A(i,:), a); +%! assert (a(j,:), A); +
--- a/scripts/signal/autoreg_matrix.m +++ b/scripts/signal/autoreg_matrix.m @@ -50,13 +50,14 @@ %!test -%! K=4; +%! K = 4; %! A = zeros(1,K+1); %! A(1) = 1; %! B = eye(K+1); %! B(:,1) = 1; -%! assert (autoreg_matrix(A,K),B); +%! assert (autoreg_matrix (A,K), B); -%!error autoreg_matrix() -%!error autoreg_matrix(1) -%!error autoreg_matrix(ones(4,1),5) +%!error autoreg_matrix () +%!error autoreg_matrix (1) +%!error autoreg_matrix (ones (4,1), 5) +
--- a/scripts/signal/bartlett.m +++ b/scripts/signal/bartlett.m @@ -48,16 +48,18 @@ endfunction -%!assert (bartlett (1), 1); -%!assert (bartlett (2), zeros (2,1)); -%!assert (bartlett (16), fliplr (bartlett (16))); -%!assert (bartlett (15), fliplr (bartlett (15))); + +%!assert (bartlett (1), 1) +%!assert (bartlett (2), zeros (2,1)) +%!assert (bartlett (16), fliplr (bartlett (16))) +%!assert (bartlett (15), fliplr (bartlett (15))) %!test %! N = 9; %! A = bartlett (N); -%! assert (A (ceil (N/2)), 1); +%! assert (A(ceil (N/2)), 1); -%!error bartlett (); -%!error bartlett (0.5); -%!error bartlett (-1); -%!error bartlett (ones(1,4)); +%!error bartlett () +%!error bartlett (0.5) +%!error bartlett (-1) +%!error bartlett (ones (1,4)) +
--- a/scripts/signal/blackman.m +++ b/scripts/signal/blackman.m @@ -47,17 +47,19 @@ endfunction -%!assert (blackman (1), 1); -%!assert (blackman (2), zeros(2,1), 1e-6); -%!assert (blackman (16), fliplr (blackman (16))); -%!assert (blackman (15), fliplr (blackman (15))); + +%!assert (blackman (1), 1) +%!assert (blackman (2), zeros (2,1), 1e-6) +%!assert (blackman (16), fliplr (blackman (16))) +%!assert (blackman (15), fliplr (blackman (15))) %!test %! N = 9; %! A = blackman (N); %! assert (A (ceil (N/2)), 1, 1e-6); %! assert ([A(1), A(length (A))], zeros (1, 2), 1e-6); -%!error blackman (); -%!error blackman (0.5); -%!error blackman (-1); -%!error blackman (ones(1,4)); +%!error blackman () +%!error blackman (0.5) +%!error blackman (-1) +%!error blackman (ones (1,4)) +
--- a/scripts/signal/detrend.m +++ b/scripts/signal/detrend.m @@ -67,23 +67,24 @@ endfunction -%!test -%! N=32; -%! x = (0:1:N-1)/N + 2; -%! y = detrend(x); -%! assert(all (all (abs (y) < 20*eps))); %!test -%! N=32; +%! N = 32; +%! x = (0:1:N-1)/N + 2; +%! y = detrend (x); +%! assert (abs (y(:)) < 20*eps); + +%!test +%! N = 32; %! t = (0:1:N-1)/N; %! x = t .* t + 2; -%! y = detrend(x,2); -%! assert(all (all (abs (y) < 30*eps))); +%! y = detrend (x,2); +%! assert (abs (y(:)) < 30*eps); %!test -%! N=32; +%! N = 32; %! t = (0:1:N-1)/N; %! x = [t;4*t-3]'; -%! y = detrend(x); -%! assert(all (all (abs (y) < 20*eps))); +%! y = detrend (x); +%! assert (abs (y(:)) < 20*eps);
--- a/scripts/signal/fftconv.m +++ b/scripts/signal/fftconv.m @@ -84,23 +84,24 @@ %!test %! a = 1:10; %! b = 1:3; -%! assert (size(conv(a,b)), [1, numel(a)+numel(b)-1]) -%! assert (size(conv(b,a)), [1, numel(a)+numel(b)-1]) +%! assert (size (conv (a,b)), [1, numel(a)+numel(b)-1]) +%! assert (size (conv (b,a)), [1, numel(a)+numel(b)-1]) %! a = (1:10).'; %! b = 1:3; -%! assert (size(conv(a,b)), [numel(a)+numel(b)-1, 1]) -%! assert (size(conv(b,a)), [numel(a)+numel(b)-1, 1]) +%! assert (size (conv (a,b)), [numel(a)+numel(b)-1, 1]) +%! assert (size (conv (b,a)), [numel(a)+numel(b)-1, 1]) %!test %! a = 1:10; %! b = (1:3).'; -%! assert (size(conv(a,b)), [1, numel(a)+numel(b)-1]) -%! assert (size(conv(b,a)), [1, numel(a)+numel(b)-1]) +%! assert (size (conv (a,b)), [1, numel(a)+numel(b)-1]) +%! assert (size (conv (b,a)), [1, numel(a)+numel(b)-1]) %% Test input validation -%!error fftconv (1); -%!error fftconv (1,2,3,4); -%!error fftconv ([1, 2; 3, 4], 3); -%!error fftconv (2, []); -%!error fftconv ([1,1], [2,2] , [3, 4]); +%!error fftconv (1) +%!error fftconv (1,2,3,4) +%!error fftconv ([1, 2; 3, 4], 3) +%!error fftconv (2, []) +%!error fftconv ([1,1], [2,2] , [3, 4]) +
--- a/scripts/signal/fftfilt.m +++ b/scripts/signal/fftfilt.m @@ -114,33 +114,33 @@ %!shared b, x, r %!test -%! b = [1 1]; -%! x = [1, zeros(1,9)]; -%! assert(fftfilt(b, x ), [1 1 0 0 0 0 0 0 0 0] , eps); -%! assert(fftfilt(b, x.'), [1 1 0 0 0 0 0 0 0 0].', eps); -%! assert(fftfilt(b.',x ), [1 1 0 0 0 0 0 0 0 0] , eps); -%! assert(fftfilt(b.',x.'), [1 1 0 0 0 0 0 0 0 0].', eps); +%! b = [1 1]; +%! x = [1, zeros(1,9)]; +%! assert (fftfilt (b, x ), [1 1 0 0 0 0 0 0 0 0] , eps); +%! assert (fftfilt (b, x.'), [1 1 0 0 0 0 0 0 0 0].', eps); +%! assert (fftfilt (b.',x ), [1 1 0 0 0 0 0 0 0 0] , eps); +%! assert (fftfilt (b.',x.'), [1 1 0 0 0 0 0 0 0 0].', eps); %!test -%! r = sqrt(1/2) * (1+i); -%! b = b*r; -%! assert(fftfilt(b, x ), r*[1 1 0 0 0 0 0 0 0 0] , eps); -%! assert(fftfilt(b, r*x), r*r*[1 1 0 0 0 0 0 0 0 0], eps); -%! assert(fftfilt(b, x.'), r*[1 1 0 0 0 0 0 0 0 0].', eps); +%! r = sqrt (1/2) * (1+i); +%! b = b*r; +%! assert (fftfilt (b, x ), r*[1 1 0 0 0 0 0 0 0 0] , eps); +%! assert (fftfilt (b, r*x), r*r*[1 1 0 0 0 0 0 0 0 0], eps); +%! assert (fftfilt (b, x.'), r*[1 1 0 0 0 0 0 0 0 0].', eps); %!test -%! b = [1 1]; -%! x = zeros (10,3); x(1,1)=-1; x(1,2)=1; -%! y0 = zeros (10,3); y0(1:2,1)=-1; y0(1:2,2)=1; -%! y = fftfilt (b, x); -%! assert (y,y0); +%! b = [1 1]; +%! x = zeros (10,3); x(1,1)=-1; x(1,2)=1; +%! y0 = zeros (10,3); y0(1:2,1)=-1; y0(1:2,2)=1; +%! y = fftfilt (b, x); +%! assert (y,y0); %!test -%! b = rand (10, 1); -%! x = rand (10, 1); -%! y0 = filter (b, 1, x); -%! y = filter (b, 1, x); -%! assert (y, y0); +%! b = rand (10, 1); +%! x = rand (10, 1); +%! y0 = filter (b, 1, x); +%! y = filter (b, 1, x); +%! assert (y, y0); %% Test input validation %!error fftfilt (1)
--- a/scripts/signal/fftshift.m +++ b/scripts/signal/fftshift.m @@ -87,45 +87,45 @@ %!test %! x = [0:7]; %! y = fftshift (x); -%! assert(y, [4 5 6 7 0 1 2 3]); -%! assert(fftshift (y), x); +%! assert (y, [4 5 6 7 0 1 2 3]); +%! assert (fftshift (y), x); %!test %! x = [0:6]; %! y = fftshift (x); -%! assert(y, [4 5 6 0 1 2 3]); -%! assert(fftshift (y), [1 2 3 4 5 6 0]); +%! assert (y, [4 5 6 0 1 2 3]); +%! assert (fftshift (y), [1 2 3 4 5 6 0]); %!test %! x = [0:7]'; %! y = fftshift (x); -%! assert(y, [4;5;6;7;0;1;2;3]); -%! assert(fftshift (y), x); +%! assert (y, [4;5;6;7;0;1;2;3]); +%! assert (fftshift (y), x); %!test %! x = [0:6]'; %! y = fftshift (x); -%! assert(y, [4;5;6;0;1;2;3]); -%! assert(fftshift (y), [1;2;3;4;5;6;0]); +%! assert (y, [4;5;6;0;1;2;3]); +%! assert (fftshift (y), [1;2;3;4;5;6;0]); %!test %! x = [0:3]; %! x = [x;2*x;3*x+1;4*x+1]; %! y = fftshift (x); -%! assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); -%! assert(fftshift (y), x); +%! assert (y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); +%! assert (fftshift (y), x); %!test %! x = [0:3]; %! x = [x;2*x;3*x+1;4*x+1]; %! y = fftshift (x,1); -%! assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); -%! assert(fftshift (y,1), x); +%! assert (y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); +%! assert (fftshift (y,1), x); %!test %! x = [0:3]; %! x = [x;2*x;3*x+1;4*x+1]; %! y = fftshift (x,2); -%! assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); -%! assert(fftshift (y,2), x); +%! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); +%! assert (fftshift (y,2), x);
--- a/scripts/signal/filter2.m +++ b/scripts/signal/filter2.m @@ -24,13 +24,13 @@ ## Possible values are: ## ## @table @asis -## @item 'full' +## @item "full" ## pad @var{x} with zeros on all sides before filtering. ## -## @item 'same' +## @item "same" ## unpadded @var{x} (default) ## -## @item 'valid' +## @item "valid" ## trim @var{x} after filtering so edge effects are no included. ## @end table ##
--- a/scripts/signal/freqz.m +++ b/scripts/signal/freqz.m @@ -169,29 +169,30 @@ endfunction + %!test # correct values and fft-polyval consistency %! # butterworth filter, order 2, cutoff pi/2 radians %! b = [0.292893218813452 0.585786437626905 0.292893218813452]; %! a = [1 0 0.171572875253810]; -%! [h,w] = freqz(b,a,32); -%! assert(h(1),1,10*eps); -%! assert(abs(h(17)).^2,0.5,10*eps); -%! assert(h,freqz(b,a,w),10*eps); # fft should be consistent with polyval +%! [h,w] = freqz (b,a,32); +%! assert (h(1),1,10*eps); +%! assert (abs (h(17)).^2,0.5,10*eps); +%! assert (h,freqz (b,a,w),10*eps); # fft should be consistent with polyval %!test # whole-half consistency %! b = [1 1 1]/3; # 3-sample average -%! [h,w] = freqz(b,1,32,'whole'); -%! assert(h(2:16),conj(h(32:-1:18)),20*eps); -%! [h2,w2] = freqz(b,1,16,'half'); -%! assert(h(1:16),h2,20*eps); -%! assert(w(1:16),w2,20*eps); +%! [h,w] = freqz (b,1,32,"whole"); +%! assert (h(2:16),conj (h(32:-1:18)),20*eps); +%! [h2,w2] = freqz (b,1,16,"half"); +%! assert (h(1:16),h2,20*eps); +%! assert (w(1:16),w2,20*eps); %!test # Sampling frequency properly interpreted %! b = [1 1 1]/3; a = [1 0.2]; -%! [h,f] = freqz(b,a,16,320); -%! assert(f,[0:15]'*10,10*eps); -%! [h2,f2] = freqz(b,a,[0:15]*10,320); -%! assert(f2,[0:15]*10,10*eps); -%! assert(h,h2.',20*eps); -%! [h3,f3] = freqz(b,a,32,'whole',320); -%! assert(f3,[0:31]'*10,10*eps); +%! [h,f] = freqz (b,a,16,320); +%! assert (f,[0:15]'*10,10*eps); +%! [h2,f2] = freqz (b,a,[0:15]*10,320); +%! assert (f2,[0:15]*10,10*eps); +%! assert (h,h2.',20*eps); +%! [h3,f3] = freqz (b,a,32,"whole",320); +%! assert (f3,[0:31]'*10,10*eps);
--- a/scripts/signal/hamming.m +++ b/scripts/signal/hamming.m @@ -46,16 +46,18 @@ endfunction -%!assert (hamming (1), 1); -%!assert (hamming (2), (0.54 - 0.46)*ones(2,1)); -%!assert (hamming (16), fliplr (hamming (16))); -%!assert (hamming (15), fliplr (hamming (15))); + +%!assert (hamming (1), 1) +%!assert (hamming (2), (0.54 - 0.46)*ones (2,1)) +%!assert (hamming (16), fliplr (hamming (16))) +%!assert (hamming (15), fliplr (hamming (15))) %!test %! N = 15; %! A = hamming (N); %! assert (A (ceil (N/2)), 1); -%!error hamming (); -%!error hamming (0.5); -%!error hamming (-1); -%!error hamming (ones(1,4)); +%!error hamming () +%!error hamming (0.5) +%!error hamming (-1) +%!error hamming (ones (1,4)) +
--- a/scripts/signal/hanning.m +++ b/scripts/signal/hanning.m @@ -46,16 +46,18 @@ endfunction + %!assert (hanning (1), 1); -%!assert (hanning (2), zeros(2,1)); +%!assert (hanning (2), zeros (2,1)); %!assert (hanning (16), fliplr (hanning (16))); %!assert (hanning (15), fliplr (hanning (15))); %!test %! N = 15; %! A = hanning (N); -%! assert (A (ceil (N/2)), 1); +%! assert (A(ceil (N/2)), 1); -%!error hanning (); -%!error hanning (0.5); -%!error hanning (-1); -%!error hanning (ones(1,4)); +%!error hanning () +%!error hanning (0.5) +%!error hanning (-1) +%!error hanning (ones(1,4)) +
--- a/scripts/signal/ifftshift.m +++ b/scripts/signal/ifftshift.m @@ -69,48 +69,49 @@ endfunction + %!test -%! x = [0:7]; -%! y = ifftshift (x); -%! assert(y, [4 5 6 7 0 1 2 3]); -%! assert(ifftshift (y), x); +%! x = [0:7]; +%! y = ifftshift (x); +%! assert (y, [4 5 6 7 0 1 2 3]); +%! assert (ifftshift (y), x); %!test -%! x = [0:6]; -%! y = ifftshift (x); -%! assert(y, [3 4 5 6 0 1 2]); -%! assert(ifftshift (y), [6 0 1 2 3 4 5]); +%! x = [0:6]; +%! y = ifftshift (x); +%! assert (y, [3 4 5 6 0 1 2]); +%! assert (ifftshift (y), [6 0 1 2 3 4 5]); %!test -%! x = [0:7]'; -%! y = ifftshift (x); -%! assert(y, [4;5;6;7;0;1;2;3]); -%! assert(ifftshift (y), x); +%! x = [0:7]'; +%! y = ifftshift (x); +%! assert (y, [4;5;6;7;0;1;2;3]); +%! assert (ifftshift (y), x); %!test -%! x = [0:6]'; -%! y = ifftshift (x); -%! assert(y, [3;4;5;6;0;1;2]); -%! assert(ifftshift (y), [6;0;1;2;3;4;5]); +%! x = [0:6]'; +%! y = ifftshift (x); +%! assert (y, [3;4;5;6;0;1;2]); +%! assert (ifftshift (y), [6;0;1;2;3;4;5]); %!test -%! x = [0:3]; -%! x = [x;2*x;3*x+1;4*x+1]; -%! y = ifftshift (x); -%! assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); -%! assert(ifftshift (y), x); +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x); +%! assert (y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); +%! assert (ifftshift (y), x); %!test -%! x = [0:3]; -%! x = [x;2*x;3*x+1;4*x+1]; -%! y = ifftshift (x,1); -%! assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); -%! assert(ifftshift (y,1), x); +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x,1); +%! assert (y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); +%! assert (ifftshift (y,1), x); %!test -%! x = [0:3]; -%! x = [x;2*x;3*x+1;4*x+1]; -%! y = ifftshift (x,2); -%! assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); -%! assert(ifftshift (y,2), x); +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x,2); +%! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); +%! assert (ifftshift (y,2), x);
--- a/scripts/signal/sinc.m +++ b/scripts/signal/sinc.m @@ -47,8 +47,9 @@ endfunction -%!assert (sinc (0), 1); -%!assert (sinc (1), 0,1e-6); +%!assert (sinc (0), 1) +%!assert (sinc (1), 0,1e-6) %!assert (sinc (1/2), 2/pi, 1e-6) %!error sinc() +
--- a/scripts/signal/sinetone.m +++ b/scripts/signal/sinetone.m @@ -64,4 +64,5 @@ endfunction -%!assert (size (sinetone (18e6, 150e6, 19550/150e6, 1)), [19550, 1]); +%!assert (size (sinetone (18e6, 150e6, 19550/150e6, 1)), [19550, 1]) +
--- a/scripts/signal/sinewave.m +++ b/scripts/signal/sinewave.m @@ -44,12 +44,14 @@ endfunction -%!assert (sinewave (1), 0); -%!assert (sinewave (1, 4, 1), 1); -%!assert (sinewave (1, 12, 1), 1/2, 1e-6); -%!assert (sinewave (1, 12, 2), sqrt (3)/2, 1e-6); -%!assert (sinewave (1, 20, 1), (sqrt (5)-1)/4, 1e-6); -%!assert (sinewave (1), sinewave (1, 1,0)); -%!assert (sinewave (3, 4), sinewave(3, 4, 0)); -%!error sinewave (); +%!assert (sinewave (1), 0) +%!assert (sinewave (1, 4, 1), 1) +%!assert (sinewave (1, 12, 1), 1/2, 1e-6) +%!assert (sinewave (1, 12, 2), sqrt (3)/2, 1e-6) +%!assert (sinewave (1, 20, 1), (sqrt (5)-1)/4, 1e-6) +%!assert (sinewave (1), sinewave (1, 1,0)) +%!assert (sinewave (3, 4), sinewave (3, 4, 0)) + +%!error sinewave () +
--- a/scripts/signal/unwrap.m +++ b/scripts/signal/unwrap.m @@ -89,16 +89,17 @@ endfunction + %!function t = __xassert(a,b,tol) %! if (nargin == 1) -%! t = all(a(:)); +%! t = all (a(:)); %! else %! if (nargin == 2) %! tol = 0; %! endif -%! if (any (size(a) != size(b))) +%! if (any (size (a) != size (b))) %! t = 0; -%! elseif (any (abs(a(:) - b(:)) > tol)) +%! elseif (any (abs (a(:) - b(:)) > tol)) %! t = 0; %! else %! t = 1; @@ -112,29 +113,29 @@ %! t = []; %! %! r = [0:100]; # original vector -%! w = r - 2*pi*floor((r+pi)/(2*pi)); # wrapped into [-pi,pi] +%! w = r - 2*pi*floor ((r+pi)/(2*pi)); # wrapped into [-pi,pi] %! tol = 1e3*eps; # maximum expected deviation %! -%! t(++i) = __xassert(r, unwrap(w), tol); #unwrap single row -%! t(++i) = __xassert(r', unwrap(w'), tol); #unwrap single column -%! t(++i) = __xassert([r',r'], unwrap([w',w']), tol); #unwrap 2 columns -%! t(++i) = __xassert([r;r], unwrap([w;w],[],2), tol); #check that dim works -%! t(++i) = __xassert(r+10, unwrap(10+w), tol); #check r(1)>pi works +%! t(++i) = __xassert (r, unwrap (w), tol); #unwrap single row +%! t(++i) = __xassert (r', unwrap (w'), tol); #unwrap single column +%! t(++i) = __xassert ([r',r'], unwrap ([w',w']), tol); #unwrap 2 columns +%! t(++i) = __xassert ([r;r], unwrap ([w;w],[],2), tol); #check that dim works +%! t(++i) = __xassert (r+10, unwrap (10+w), tol); #check r(1)>pi works %! -%! t(++i) = __xassert(w', unwrap(w',[],2)); #unwrap col by rows should not change it -%! t(++i) = __xassert(w, unwrap(w,[],1)); #unwrap row by cols should not change it -%! t(++i) = __xassert([w;w], unwrap([w;w])); #unwrap 2 rows by cols should not change them +%! t(++i) = __xassert (w', unwrap (w',[],2)); #unwrap col by rows should not change it +%! t(++i) = __xassert (w, unwrap (w,[],1)); #unwrap row by cols should not change it +%! t(++i) = __xassert ([w;w], unwrap ([w;w])); #unwrap 2 rows by cols should not change them %! %! ## verify that setting tolerance too low will cause bad results. -%! t(++i) = __xassert(any(abs(r - unwrap(w,0.8)) > 100)); +%! t(++i) = __xassert (any (abs (r - unwrap (w,0.8)) > 100)); %! -%! assert(all(t)); +%! assert (all (t)); %! %!test %! A = [pi*(-4), pi*(-2+1/6), pi/4, pi*(2+1/3), pi*(4+1/2), pi*(8+2/3), pi*(16+1), pi*(32+3/2), pi*64]; -%! assert (unwrap(A), unwrap(A, pi)); -%! assert (unwrap(A, pi), unwrap(A, pi, 2)); -%! assert (unwrap(A', pi), unwrap(A', pi, 1)); +%! assert (unwrap (A), unwrap (A, pi)); +%! assert (unwrap (A, pi), unwrap (A, pi, 2)); +%! assert (unwrap (A', pi), unwrap (A', pi, 1)); %! %!test %! A = [pi*(-4); pi*(2+1/3); pi*(16+1)]; @@ -145,12 +146,13 @@ %! E(:, :, 2) = [A+B, B+C, C+D, D+A]; %! F(:, :, 1) = [unwrap(A), unwrap(B), unwrap(C), unwrap(D)]; %! F(:, :, 2) = [unwrap(A+B), unwrap(B+C), unwrap(C+D), unwrap(D+A)]; -%! assert (unwrap(E), F); +%! assert (unwrap (E), F); %! %!test %! A = [0, 2*pi, 4*pi, 8*pi, 16*pi, 65536*pi]; %! B = [pi*(-2+1/6), pi/4, pi*(2+1/3), pi*(4+1/2), pi*(8+2/3), pi*(16+1), pi*(32+3/2), pi*64]; -%! assert (unwrap(A), zeros(1, length(A))); -%! assert (diff(unwrap(B), 1)<2*pi, true(1, length(B)-1)); -%! +%! assert (unwrap (A), zeros (1, length (A))); +%! assert (diff (unwrap (B), 1) < 2*pi, true (1, length (B)-1)); + %!error unwrap() +
--- a/scripts/sparse/bicg.m +++ b/scripts/sparse/bicg.m @@ -40,8 +40,8 @@ ## The preconditioner @var{P} is given as @code{P = M1 * M2}. ## Both @var{M1} and @var{M2} can be passed as a matrix or as ## a function handle or inline function @code{g} such that -## @code{g(x, 'notransp') = M1 \ x} or @code{g(x, 'notransp') = M2 \ x} and -## @code{g(x, 'transp') = M1' \ x} or @code{g(x, 'transp') = M2' \ x}. +## @code{g(x, "notransp") = M1 \ x} or @code{g(x, "notransp") = M2 \ x} and +## @code{g(x, "transp") = M1' \ x} or @code{g(x, "transp") = M2' \ x}. ## ## If called with more than one output parameter ## @@ -228,7 +228,6 @@ %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n); %! [x, flag, relres, iter, resvec] = bicg (A, b, tol, maxit, M1, M2); %! assert (x, ones (size (b)), 1e-7); -%! %!function y = afun (x, t, a) %! switch t @@ -260,3 +259,4 @@ %! b = sum (A, 2); %! [x, flag, relres, iter, resvec] = bicg (A, b, tol, [], diag (diag (A))); %! assert (x, ones (size (b)), 1e-7); +
--- a/scripts/sparse/bicgstab.m +++ b/scripts/sparse/bicgstab.m @@ -246,3 +246,4 @@ %! b = sum (A, 2); %! [x, flag, relres, iter, resvec] = bicgstab (A, b, tol, [], diag (diag (A))); %! assert (x, ones (size (b)), 1e-7); +
--- a/scripts/sparse/gmres.m +++ b/scripts/sparse/gmres.m @@ -49,6 +49,7 @@ ## ## @itemize @minus ## @item @var{flag} indicates the exit status: +## ## @table @asis ## @item 0 : iteration converged to within the specified tolerance ## @@ -197,22 +198,23 @@ %! dim = 100; %!test %! A = spdiags ([-ones(dim,1) 2*ones(dim,1) ones(dim,1)], [-1:1], dim, dim); -%! b = ones(dim, 1); -%! x = gmres (A, b, 10, 1e-10, dim, @(x) x./diag(A), [], b); -%! assert(x, A\b, 1e-9*norm(x,inf)); +%! b = ones (dim, 1); +%! x = gmres (A, b, 10, 1e-10, dim, @(x) x ./ diag (A), [], b); +%! assert (x, A\b, 1e-9*norm (x, Inf)); %! %!test -%! x = gmres (A, b, dim, 1e-10, 1e4, @(x) diag(diag(A))\x, [], b); -%! assert(x, A\b, 1e-7*norm(x,inf)); +%! x = gmres (A, b, dim, 1e-10, 1e4, @(x) diag (diag (A)) \ x, [], b); +%! assert(x, A\b, 1e-7*norm (x, Inf)); %! %!test %! A = spdiags ([[1./(2:2:2*(dim-1)) 0]; 1./(1:2:2*dim-1); [0 1./(2:2:2*(dim-1))]]', -1:1, dim, dim); %! A = A'*A; %! b = rand (dim, 1); -%! [x, resids] = gmres (@(x) A*x, b, dim, 1e-10, dim, @(x) x./diag(A), [], []); -%! assert(x, A\b, 1e-9*norm(x,inf)) -%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) diag(diag(A))\x, [], []); -%! assert(x, A\b, 1e-9*norm(x,inf)); +%! [x, resids] = gmres (@(x) A*x, b, dim, 1e-10, dim, @(x) x./diag (A), [], []); +%! assert (x, A\b, 1e-9*norm (x, Inf)); +%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) diag (diag (A)) \ x, [], []); +%! assert (x, A\b, 1e-9*norm (x, Inf)); %!test -%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x./diag(A), [], []); -%! assert(x, A\b, 1e-7*norm(x,inf)); +%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x./diag(A), [], []); +%! assert (x, A\b, 1e-7*norm (x, Inf)); +
--- a/scripts/sparse/gplot.m +++ b/scripts/sparse/gplot.m @@ -80,5 +80,5 @@ %! title ("gplot() of Binary Tree Adjacency matrix"); %% Mark graphical function as tested by demo block -%!assert (1); +%!assert (1)
--- a/scripts/sparse/nonzeros.m +++ b/scripts/sparse/nonzeros.m @@ -34,7 +34,8 @@ endfunction -%!assert(nonzeros([1,2;3,0]),[1;3;2]) -%!assert(nonzeros([1,2,3,0]),[1;2;3]) -%!assert(nonzeros(sparse([1,2;3,0])),[1;3;2]) -%!assert(nonzeros(sparse([1,2,3,0])),[1;2;3]) +%!assert (nonzeros ([1,2;3,0]), [1;3;2]) +%!assert (nonzeros ([1,2,3,0]), [1;2;3]) +%!assert (nonzeros (sparse ([1,2;3,0])), [1;3;2]) +%!assert (nonzeros (sparse ([1,2,3,0])), [1;2;3]) +
--- a/scripts/sparse/pcg.m +++ b/scripts/sparse/pcg.m @@ -124,17 +124,17 @@ ## ## @example ## @group -## n = 10; -## A = diag (sparse (1:n)); -## b = rand (n, 1); -## [l, u, p, q] = luinc (A, 1.e-3); +## n = 10; +## A = diag (sparse (1:n)); +## b = rand (n, 1); +## [l, u, p, q] = luinc (A, 1.e-3); ## @end group ## @end example ## ## @sc{Example 1:} Simplest use of @code{pcg} ## ## @example -## x = pcg(A,b) +## x = pcg (A,b) ## @end example ## ## @sc{Example 2:} @code{pcg} with a function which computes @@ -142,18 +142,18 @@ ## ## @example ## @group -## function y = apply_a (x) -## y = [1:N]'.*x; -## endfunction +## function y = apply_a (x) +## y = [1:N]' .* x; +## endfunction ## -## x = pcg ("apply_a", b) +## x = pcg ("apply_a", b) ## @end group ## @end example ## ## @sc{Example 3:} @code{pcg} with a preconditioner: @var{l} * @var{u} ## ## @example -## x = pcg (A, b, 1.e-6, 500, l*u); +## x = pcg (A, b, 1.e-6, 500, l*u) ## @end example ## ## @sc{Example 4:} @code{pcg} with a preconditioner: @var{l} * @var{u}. @@ -161,7 +161,7 @@ ## are easier to invert ## ## @example -## x = pcg (A, b, 1.e-6, 500, l, u); +## x = pcg (A, b, 1.e-6, 500, l, u) ## @end example ## ## @sc{Example 5:} Preconditioned iteration, with full diagnostics. The @@ -170,15 +170,15 @@ ## ## @example ## @group -## function y = apply_m (x) -## k = floor (length (x) - 2); -## y = x; -## y(1:k) = x(1:k)./[1:k]'; -## endfunction +## function y = apply_m (x) +## k = floor (length (x) - 2); +## y = x; +## y(1:k) = x(1:k) ./ [1:k]'; +## endfunction ## -## [x, flag, relres, iter, resvec, eigest] = ... -## pcg (A, b, [], [], "apply_m"); -## semilogy (1:iter+1, resvec); +## [x, flag, relres, iter, resvec, eigest] = ... +## pcg (A, b, [], [], "apply_m"); +## semilogy (1:iter+1, resvec); ## @end group ## @end example ## @@ -187,14 +187,14 @@ ## ## @example ## @group -## function y = apply_M (x, varargin) +## function y = apply_M (x, varargin) ## K = varargin@{1@}; ## y = x; -## y(1:K) = x(1:K)./[1:K]'; -## endfunction +## y(1:K) = x(1:K) ./ [1:K]'; +## endfunction ## -## [x, flag, relres, iter, resvec, eigest] = ... -## pcg (A, b, [], [], "apply_m", [], [], 3) +## [x, flag, relres, iter, resvec, eigest] = ... +## pcg (A, b, [], [], "apply_m", [], [], 3) ## @end group ## @end example ## @@ -216,8 +216,7 @@ ## Author: Piotr Krzyzanowski <piotr.krzyzanowski@mimuw.edu.pl> ## Modified by: Vittoria Rezzonico <vittoria.rezzonico@epfl.ch> -## - Add the ability to provide the pre-conditioner as two separate -## matrices +## - Add the ability to provide the pre-conditioner as two separate matrices function [x, flag, relres, iter, resvec, eigest] = pcg (A, b, tol, maxit, m1, m2, x0, varargin) @@ -434,7 +433,6 @@ %! legend ("absolute residual", "absolute preconditioned residual"); %!demo -%! %! # Full output from pcg, including the eigenvalue estimates %! # We use the 1-D Laplacian matrix for A, and cond(A) = O(N^2) %! # and that's the reason we need some preconditioner; here we take
--- a/scripts/sparse/pcr.m +++ b/scripts/sparse/pcr.m @@ -101,16 +101,16 @@ ## ## @example ## @group -## n = 10; -## A = sparse (diag (1:n)); -## b = rand (N, 1); +## n = 10; +## A = sparse (diag (1:n)); +## b = rand (N, 1); ## @end group ## @end example ## ## @sc{Example 1:} Simplest use of @code{pcr} ## ## @example -## x = pcr (A, b) +## x = pcr (A, b) ## @end example ## ## @sc{Example 2:} @code{pcr} with a function which computes @@ -118,11 +118,11 @@ ## ## @example ## @group -## function y = apply_a (x) -## y = [1:10]'.*x; -## endfunction +## function y = apply_a (x) +## y = [1:10]' .* x; +## endfunction ## -## x = pcr ("apply_a", b) +## x = pcr ("apply_a", b) ## @end group ## @end example ## @@ -132,15 +132,15 @@ ## ## @example ## @group -## function y = apply_m (x) -## k = floor (length(x)-2); -## y = x; -## y(1:k) = x(1:k)./[1:k]'; -## endfunction +## function y = apply_m (x) +## k = floor (length (x) - 2); +## y = x; +## y(1:k) = x(1:k) ./ [1:k]'; +## endfunction ## -## [x, flag, relres, iter, resvec] = ... -## pcr (A, b, [], [], "apply_m") -## semilogy([1:iter+1], resvec); +## [x, flag, relres, iter, resvec] = ... +## pcr (A, b, [], [], "apply_m") +## semilogy ([1:iter+1], resvec); ## @end group ## @end example ## @@ -149,13 +149,14 @@ ## ## @example ## @group -## function y = apply_m (x, varargin) -## k = varargin@{1@}; -## y = x; y(1:k) = x(1:k)./[1:k]'; -## endfunction +## function y = apply_m (x, varargin) +## k = varargin@{1@}; +## y = x; +## y(1:k) = x(1:k) ./ [1:k]'; +## endfunction ## -## [x, flag, relres, iter, resvec] = ... -## pcr (A, b, [], [], "apply_m"', [], 3) +## [x, flag, relres, iter, resvec] = ... +## pcr (A, b, [], [], "apply_m"', [], 3) ## @end group ## @end example ## @@ -302,100 +303,100 @@ %!demo -%! # Simplest usage of PCR (see also 'help pcr') +%! # Simplest usage of PCR (see also 'help pcr') %! -%! N = 20; -%! A = diag (linspace (-3.1,3,N)); b = rand (N,1); -%! y = A \ b; # y is the true solution -%! x = pcr (A,b); -%! printf ("The solution relative error is %g\n", norm (x-y) / norm (y)); +%! N = 20; +%! A = diag (linspace (-3.1,3,N)); b = rand (N,1); +%! y = A \ b; # y is the true solution +%! x = pcr (A,b); +%! printf ("The solution relative error is %g\n", norm (x-y) / norm (y)); %! -%! # You shouldn't be afraid if PCR issues some warning messages in this -%! # example: watch out in the second example, why it takes N iterations -%! # of PCR to converge to (a very accurate, by the way) solution +%! # You shouldn't be afraid if PCR issues some warning messages in this +%! # example: watch out in the second example, why it takes N iterations +%! # of PCR to converge to (a very accurate, by the way) solution %!demo -%! # Full output from PCR -%! # We use this output to plot the convergence history +%! # Full output from PCR +%! # We use this output to plot the convergence history %! -%! N = 20; -%! A = diag (linspace(-3.1,30,N)); b = rand (N,1); -%! X = A \ b; # X is the true solution -%! [x, flag, relres, iter, resvec] = pcr (A,b); -%! printf ("The solution relative error is %g\n", norm (x-X) / norm (X)); -%! clf; -%! title ("Convergence history"); -%! xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)"); -%! semilogy ([0:iter], resvec/resvec(1), "o-g;relative residual;"); +%! N = 20; +%! A = diag (linspace (-3.1,30,N)); b = rand (N,1); +%! X = A \ b; # X is the true solution +%! [x, flag, relres, iter, resvec] = pcr (A,b); +%! printf ("The solution relative error is %g\n", norm (x-X) / norm (X)); +%! clf; +%! title ("Convergence history"); +%! xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)"); +%! semilogy ([0:iter], resvec/resvec(1), "o-g;relative residual;"); %!demo -%! # Full output from PCR -%! # We use indefinite matrix based on the Hilbert matrix, with one -%! # strongly negative eigenvalue -%! # Hilbert matrix is extremely ill conditioned, so is ours, -%! # and that's why PCR WILL have problems +%! # Full output from PCR +%! # We use indefinite matrix based on the Hilbert matrix, with one +%! # strongly negative eigenvalue +%! # Hilbert matrix is extremely ill conditioned, so is ours, +%! # and that's why PCR WILL have problems %! -%! N = 10; -%! A = hilb (N); A(1,1) = -A(1,1); b = rand (N,1); -%! X = A \ b; # X is the true solution -%! printf ("Condition number of A is %g\n", cond (A)); -%! [x, flag, relres, iter, resvec] = pcr (A,b,[],200); -%! if (flag == 3) -%! printf ("PCR breakdown. System matrix is [close to] singular\n"); -%! end -%! clf; -%! title ("Convergence history"); -%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); -%! semilogy ([0:iter], resvec, "o-g;absolute residual;"); +%! N = 10; +%! A = hilb (N); A(1,1) = -A(1,1); b = rand (N,1); +%! X = A \ b; # X is the true solution +%! printf ("Condition number of A is %g\n", cond (A)); +%! [x, flag, relres, iter, resvec] = pcr (A,b,[],200); +%! if (flag == 3) +%! printf ("PCR breakdown. System matrix is [close to] singular\n"); +%! end +%! clf; +%! title ("Convergence history"); +%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); +%! semilogy ([0:iter], resvec, "o-g;absolute residual;"); %!demo -%! # Full output from PCR -%! # We use an indefinite matrix based on the 1-D Laplacian matrix for A, -%! # and here we have cond(A) = O(N^2) -%! # That's the reason we need some preconditioner; here we take -%! # a very simple and not powerful Jacobi preconditioner, -%! # which is the diagonal of A +%! # Full output from PCR +%! # We use an indefinite matrix based on the 1-D Laplacian matrix for A, +%! # and here we have cond(A) = O(N^2) +%! # That's the reason we need some preconditioner; here we take +%! # a very simple and not powerful Jacobi preconditioner, +%! # which is the diagonal of A %! -%! # Note that we use here indefinite preconditioners! +%! # Note that we use here indefinite preconditioners! %! -%! N = 100; -%! A = zeros (N,N); -%! for i=1:N-1 # form 1-D Laplacian matrix -%! A(i:i+1,i:i+1) = [2 -1; -1 2]; -%! endfor -%! A = [A, zeros(size(A)); zeros(size(A)), -A]; -%! b = rand (2*N,1); -%! X = A \ b; # X is the true solution -%! maxit = 80; -%! printf ("System condition number is %g\n", cond (A)); -%! # No preconditioner: the convergence is very slow! +%! N = 100; +%! A = zeros (N,N); +%! for i=1:N-1 # form 1-D Laplacian matrix +%! A(i:i+1,i:i+1) = [2 -1; -1 2]; +%! endfor +%! A = [A, zeros(size(A)); zeros(size(A)), -A]; +%! b = rand (2*N,1); +%! X = A \ b; # X is the true solution +%! maxit = 80; +%! printf ("System condition number is %g\n", cond (A)); +%! # No preconditioner: the convergence is very slow! %! -%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit); -%! clf; -%! title ("Convergence history"); -%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); -%! semilogy ([0:iter], resvec, "o-g;NO preconditioning: absolute residual;"); +%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit); +%! clf; +%! title ("Convergence history"); +%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)"); +%! semilogy ([0:iter], resvec, "o-g;NO preconditioning: absolute residual;"); %! -%! pause (1); -%! # Test Jacobi preconditioner: it will not help much!!! +%! pause (1); +%! # Test Jacobi preconditioner: it will not help much!!! %! -%! M = diag (diag (A)); # Jacobi preconditioner -%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M); -%! hold on; -%! semilogy ([0:iter],resvec,"o-r;JACOBI preconditioner: absolute residual;"); +%! M = diag (diag (A)); # Jacobi preconditioner +%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M); +%! hold on; +%! semilogy ([0:iter],resvec,"o-r;JACOBI preconditioner: absolute residual;"); %! -%! pause (1); -%! # Test nonoverlapping block Jacobi preconditioner: this one should give -%! # some convergence speedup! +%! pause (1); +%! # Test nonoverlapping block Jacobi preconditioner: this one should give +%! # some convergence speedup! %! -%! M = zeros (N,N); k = 4; -%! for i=1:k:N # get k x k diagonal blocks of A -%! M(i:i+k-1,i:i+k-1) = A(i:i+k-1,i:i+k-1); -%! endfor -%! M = [M, zeros(size (M)); zeros(size(M)), -M]; -%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M); -%! semilogy ([0:iter], resvec, "o-b;BLOCK JACOBI preconditioner: absolute residual;"); -%! hold off; +%! M = zeros (N,N); k = 4; +%! for i=1:k:N # get k x k diagonal blocks of A +%! M(i:i+k-1,i:i+k-1) = A(i:i+k-1,i:i+k-1); +%! endfor +%! M = [M, zeros(size (M)); zeros(size(M)), -M]; +%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M); +%! semilogy ([0:iter], resvec, "o-b;BLOCK JACOBI preconditioner: absolute residual;"); +%! hold off; %!test %! # solve small indefinite diagonal system
--- a/scripts/sparse/spaugment.m +++ b/scripts/sparse/spaugment.m @@ -22,19 +22,18 @@ ## ## @example ## @group -## [@var{c} * eye(@var{m}, @var{m}),@var{A}; @var{A}', zeros(@var{n}, -## @var{n})] +## [@var{c} * eye(@var{m}, @var{m}), @var{A}; +## @var{A}', zeros(@var{n}, @var{n})] ## @end group ## @end example ## ## @noindent ## This is related to the least squares solution of -## @code{@var{A} \\ @var{b}}, by +## @code{@var{A} \ @var{b}}, by ## ## @example ## @group -## @var{s} * [ @var{r} / @var{c}; x] = [@var{b}, zeros(@var{n}, -## columns(@var{b})] +## @var{s} * [ @var{r} / @var{c}; x] = [ @var{b}, zeros(@var{n}, columns(@var{b})) ] ## @end group ## @end example ## @@ -53,7 +52,7 @@ ## ## @example ## @group -## m = 11; n = 10; mn = max(m ,n); +## m = 11; n = 10; mn = max (m, n); ## A = spdiags ([ones(mn,1), 10*ones(mn,1), -ones(mn,1)], ## [-1, 0, 1], m, n); ## x0 = A \ ones (m,1); @@ -91,12 +90,14 @@ s = [ c * speye(m, m), A; A', sparse(n, n)]; endfunction + %!testif HAVE_UMFPACK -%! m = 11; n = 10; mn = max(m ,n); +%! m = 11; n = 10; mn = max (m ,n); %! A = spdiags ([ones(mn,1), 10*ones(mn,1), -ones(mn,1)],[-1,0,1], m, n); %! x0 = A \ ones (m,1); %! s = spaugment (A); %! [L, U, P, Q] = lu (s); %! x1 = Q * (U \ (L \ (P * [ones(m,1); zeros(n,1)]))); %! x1 = x1(end - n + 1 : end); -%! assert (x1, x0, 1e-6) +%! assert (x1, x0, 1e-6); +
--- a/scripts/sparse/spconvert.m +++ b/scripts/sparse/spconvert.m @@ -65,3 +65,4 @@ %!error spconvert ([1 2]) %!error spconvert ([1 2 3i]) %!error spconvert ([1 2 3 4 5]) +
--- a/scripts/sparse/spdiags.m +++ b/scripts/sparse/spdiags.m @@ -42,7 +42,7 @@ ## @example ## @group ## spdiags (reshape (1:12, 4, 3), [-1 0 1], 5, 4) -## @result{} 5 10 0 0 +## @result{} 5 10 0 0 ## 1 6 11 0 ## 0 2 7 12 ## 0 0 3 8 @@ -87,8 +87,7 @@ endfunction -%!test -%assert(spdiags(zeros(1,0),1,1,1),0) -%!test -%assert(spdiags(zeros(0,1),1,1,1),0) +%!assert (spdiags (zeros (1,0),1,1,1), sparse (0)) +%!assert (spdiags (zeros (0,1),1,1,1), sparse (0)) +
--- a/scripts/sparse/speye.m +++ b/scripts/sparse/speye.m @@ -50,8 +50,10 @@ s = sparse (1:lo, 1:lo, 1, m, n); endfunction -%!assert(issparse(speye(4))) -%!assert(speye(4),sparse(1:4,1:4,1)) -%!assert(speye(2,4),sparse(1:2,1:2,1,2,4)) -%!assert(speye(4,2),sparse(1:2,1:2,1,4,2)) -%!assert(speye([4,2]),sparse(1:2,1:2,1,4,2)) + +%!assert (issparse (speye (4))) +%!assert (speye (4), sparse (1:4,1:4,1)) +%!assert (speye (2,4), sparse (1:2,1:2,1,2,4)) +%!assert (speye (4,2), sparse (1:2,1:2,1,4,2)) +%!assert (speye ([4,2]), sparse (1:2,1:2,1,4,2)) +
--- a/scripts/sparse/spfun.m +++ b/scripts/sparse/spfun.m @@ -42,8 +42,9 @@ endfunction -%!assert(spfun('exp',[1,2;3,0]),sparse([exp(1),exp(2);exp(3),0])) -%!assert(spfun('exp',sparse([1,2;3,0])),sparse([exp(1),exp(2);exp(3),0])) -%!assert(spfun(@exp,[1,2;3,0]),sparse([exp(1),exp(2);exp(3),0])) -%!assert(spfun(@exp,sparse([1,2;3,0])),sparse([exp(1),exp(2);exp(3),0])) +%!assert (spfun ("exp", [1,2;3,0]), sparse ([exp(1),exp(2);exp(3),0])) +%!assert (spfun ("exp", sparse ([1,2;3,0])), sparse ([exp(1),exp(2);exp(3),0])) +%!assert (spfun (@exp, [1,2;3,0]), sparse ([exp(1),exp(2);exp(3),0])) +%!assert (spfun (@exp, sparse ([1,2;3,0])), sparse ([exp(1),exp(2);exp(3),0])) +
--- a/scripts/sparse/spones.m +++ b/scripts/sparse/spones.m @@ -35,6 +35,8 @@ endfunction -%!assert(issparse(spones([1,2;3,0]))) -%!assert(spones([1,2;3,0]),sparse([1,1;1,0])) -%!assert(spones(sparse([1,2;3,0])),sparse([1,1;1,0])) + +%!assert (issparse (spones ([1,2;3,0]))) +%!assert (spones ([1,2;3,0]), sparse ([1,1;1,0])) +%!assert (spones (sparse ([1,2;3,0])), sparse ([1,1;1,0])) +
--- a/scripts/sparse/sprand.m +++ b/scripts/sparse/sprand.m @@ -54,6 +54,7 @@ endfunction + %!test %! s = sprand (4, 10, 0.1); %! assert (size (s), [4, 10]); @@ -71,10 +72,10 @@ %!error sprand () %!error sprand (1, 2) %!error sprand (1, 2, 3, 4) -%!error sprand (ones(3), 3, 0.5) +%!error sprand (ones (3), 3, 0.5) %!error sprand (3.5, 3, 0.5) %!error sprand (0, 3, 0.5) -%!error sprand (3, ones(3), 0.5) +%!error sprand (3, ones (3), 0.5) %!error sprand (3, 3.5, 0.5) %!error sprand (3, 0, 0.5) %!error sprand (3, 3, -1)
--- a/scripts/sparse/sprandn.m +++ b/scripts/sparse/sprandn.m @@ -24,7 +24,7 @@ ## @deftypefnx {Function File} {} sprandn (@var{s}) ## Generate a random sparse matrix. The size of the matrix will be ## @var{m} by @var{n}, with a density of values given by @var{d}. -## @var{d} should be between 0 and 1. Values will be normally +## @var{d} should be between 0 and 1. Values will be normally ## distributed with mean of zero and variance 1. ## ## If called with a single matrix argument, a random sparse matrix is
--- a/scripts/sparse/sprandsym.m +++ b/scripts/sparse/sprandsym.m @@ -22,7 +22,7 @@ ## @deftypefnx {Function File} {} sprandsym (@var{s}) ## Generate a symmetric random sparse matrix. The size of the matrix will be ## @var{n} by @var{n}, with a density of values given by @var{d}. -## @var{d} should be between 0 and 1. Values will be normally +## @var{d} should be between 0 and 1. Values will be normally ## distributed with mean of zero and variance 1. ## ## If called with a single matrix argument, a random sparse matrix is @@ -151,6 +151,7 @@ endfunction + %!test %! s = sprandsym (10, 0.1); %! assert (issparse (s)); @@ -168,7 +169,7 @@ %% Test input validation %!error sprandsym () %!error sprandsym (1, 2, 3) -%!error sprandsym (ones(3), 0.5) +%!error sprandsym (ones (3), 0.5) %!error sprandsym (3.5, 0.5) %!error sprandsym (0, 0.5) %!error sprandsym (3, -1)
--- a/scripts/sparse/spstats.m +++ b/scripts/sparse/spstats.m @@ -59,7 +59,8 @@ %!test -%! [n,m,v] = spstats([1 2 1 2 3 4],[2 2 1 1 1 1]); -%! assert(n,sparse([4,2])); -%! assert(m,sparse([10/4,3/2]),10*eps); -%! assert(v,sparse([5/3,1/2]),10*eps); +%! [n,m,v] = spstats ([1 2 1 2 3 4],[2 2 1 1 1 1]); +%! assert (n, sparse ([4,2])); +%! assert (m, sparse ([10/4,3/2]), 10*eps); +%! assert (v, sparse ([5/3,1/2]), 10*eps); +
--- a/scripts/sparse/spy.m +++ b/scripts/sparse/spy.m @@ -72,4 +72,5 @@ %! spy (sprand (10,10, 0.2)); %% Mark graphical function as tested by demo block -%!assert (1); +%!assert (1) +
--- a/scripts/sparse/svds.m +++ b/scripts/sparse/svds.m @@ -29,9 +29,9 @@ ## ## @example ## @group -## [@var{m}, @var{n}] = size(@var{A}) -## @var{s} = eigs([sparse(@var{m}, @var{m}), @var{A}; -## @var{A}', sparse(@var{n}, @var{n})]) +## [@var{m}, @var{n}] = size (@var{A}); +## @var{s} = eigs ([sparse(@var{m}, @var{m}), @var{A}; +## @var{A}', sparse(@var{n}, @var{n})]) ## @end group ## @end example ## @@ -241,6 +241,7 @@ endfunction + %!shared n, k, A, u, s, v, opts, rand_state, randn_state %! n = 100; %! k = 7;
--- a/scripts/sparse/treelayout.m +++ b/scripts/sparse/treelayout.m @@ -202,6 +202,7 @@ endif endfunction + %!test %! % Compute a simple tree layout %! [x, y, h, s] = treelayout ([0, 1, 2, 2]); @@ -225,3 +226,4 @@ %! assert (y, [0, 0, 0, 3]); %! assert (h, 0); %! assert (s, 1); +
--- a/scripts/specfun/bessel.m +++ b/scripts/specfun/bessel.m @@ -91,4 +91,5 @@ error ("bessel: you must use besselj, bessely, besseli, or besselk"); endfunction + %!error bessel ()
--- a/scripts/specfun/beta.m +++ b/scripts/specfun/beta.m @@ -55,28 +55,30 @@ endfunction + %!test -%! a=[1, 1.5, 2, 3]; -%! b=[4, 3, 2, 1]; -%! v1=beta(a,b); -%! v2=beta(b,a); -%! v3=gamma(a).*gamma(b)./gamma(a+b); -%! assert(all(abs(v1-v2)<sqrt(eps)) && all(abs(v2-v3)<sqrt(eps))); +%! a = [1, 1.5, 2, 3]; +%! b = [4, 3, 2, 1]; +%! v1 = beta (a,b); +%! v2 = beta (b,a); +%! v3 = gamma (a).*gamma (b) ./ gamma (a+b); +%! assert (v1, v2, sqrt (eps)); +%! assert (v2, v3, sqrt (eps)); -%!error beta(); - -%!error beta(1); - -%!assert (1, beta (1, 1)) +%!assert (beta (1, 1), 1) %!test %! a = 2:10; %! tol = 10 * max (a) * eps; -%! assert (-a, beta (-1./a, 1), tol) -%! assert (-a, beta (1, -1./a), tol) +%! assert (-a, beta (-1./a, 1), tol); +%! assert (-a, beta (1, -1./a), tol); %!test %! a = 0.25 + (0:5) * 0.5; %! tol = 10 * max (a) * eps; -%! assert (zeros (size (a)), beta (a, -a), tol) -%! assert (zeros (size (a)), beta (-a, a), tol) +%! assert (zeros (size (a)), beta (a, -a), tol); +%! assert (zeros (size (a)), beta (-a, a), tol); + +%!error beta () +%!error beta (1) +
--- a/scripts/specfun/betaln.m +++ b/scripts/specfun/betaln.m @@ -50,7 +50,7 @@ endfunction -%!assert (betaln (3,4), log (beta(3,4)),eps); +%!assert (betaln (3,4), log (beta (3,4)), eps) %% Test input validation %!error (betaln (1))
--- a/scripts/specfun/factor.m +++ b/scripts/specfun/factor.m @@ -82,14 +82,15 @@ endfunction + +%!assert (factor (1), 1) %!test -%! assert(factor(1),1); -%! for i=2:20 -%! p = factor(i); -%! assert(prod(p),i); -%! assert(all(isprime(p))); -%! [p,n] = factor(i); -%! assert(prod(p.^n),i); -%! assert(all([0,p]!=[p,0])); -%! endfor +%! for i = 2:20 +%! p = factor (i); +%! assert (prod (p), i); +%! assert (all (isprime (p))); +%! [p,n] = factor (i); +%! assert (prod (p.^n), i); +%! assert (all ([0,p] != [p,0])); +%! endfor
--- a/scripts/specfun/factorial.m +++ b/scripts/specfun/factorial.m @@ -35,8 +35,11 @@ x = round (gamma (n+1)); endfunction -%!assert (factorial(5), prod(1:5)) -%!assert (factorial([1,2;3,4]), [1,2;6,24]) -%!assert (factorial(70), exp(sum(log(1:70))), -128*eps) -%!fail ('factorial(5.5)', "must all be non-negative integers") -%!fail ('factorial(-3)', "must all be non-negative integers") + +%!assert (factorial (5), prod (1:5)) +%!assert (factorial ([1,2;3,4]), [1,2;6,24]) +%!assert (factorial (70), exp (sum (log (1:70))), -128*eps) + +%!fail ("factorial (5.5)", "must all be non-negative integers") +%!fail ("factorial (-3)", "must all be non-negative integers") +
--- a/scripts/specfun/isprime.m +++ b/scripts/specfun/isprime.m @@ -80,8 +80,10 @@ endfunction -%!assert (isprime (4), logical (0)); -%!assert (isprime (3), logical (1)); -%!assert (isprime (magic (3)), logical ([0, 0, 0; 1, 1, 1; 0, 0, 1])); +%!assert (isprime (3), true) +%!assert (isprime (4), false) +%!assert (isprime (magic (3)), logical ([0, 0, 0; 1, 1, 1; 0, 0, 1])) + %!error isprime () %!error isprime (1, 2) +
--- a/scripts/specfun/lcm.m +++ b/scripts/specfun/lcm.m @@ -51,11 +51,11 @@ endfunction -%!assert(lcm (3, 5, 7, 15) == 105); + +%!assert (lcm (3, 5, 7, 15), 105) %!error lcm (); - %!test %! s.a = 1; -%! fail("lcm (s)"); +%! fail ("lcm (s)");
--- a/scripts/specfun/legendre.m +++ b/scripts/specfun/legendre.m @@ -43,7 +43,7 @@ ## @example ## @group ## m m 2 m/2 d^m -## P(x) = (-1) * (1-x ) * ---- P (x) +## P(x) = (-1) * (1-x ) * ---- P(x) ## n dx^m n ## @end group ## @end example @@ -62,9 +62,9 @@ ## ## @example ## @group -## 1 d^n 2 n -## P (x) = ------ [----(x - 1) ] -## n 2^n n! dx^n +## 1 d^n 2 n +## P(x) = ------ [----(x - 1) ] +## n 2^n n! dx^n ## @end group ## @end example ## @@ -75,7 +75,7 @@ ## ## @example ## @group -## x | -1.0 | -0.9 | -0.8 +## x | -1.0 | -0.9 | -0.8 ## ------------------------------------ ## m=0 | -1.00000 | -0.47250 | -0.08000 ## m=1 | 0.00000 | -1.99420 | -1.98000 @@ -100,9 +100,9 @@ ## ## @example ## @group -## 0 0 -## SP (x) = P (x) -## n n +## 0 0 +## SP(x) = P(x) +## n n ## @end group ## @end example ## @@ -119,9 +119,9 @@ ## ## @example ## @group -## m m m 2(n-m)! 0.5 -## SP (x) = P (x) * (-1) * [-------] -## n n (n+m)! +## m m m 2(n-m)! 0.5 +## SP(x) = P(x) * (-1) * [-------] +## n n (n+m)! ## @end group ## @end example ## @@ -143,9 +143,9 @@ ## ## @example ## @group -## m m m (n+0.5)(n-m)! 0.5 -## NP (x) = P (x) * (-1) * [-------------] -## n n (n+m)! +## m m m (n+0.5)(n-m)! 0.5 +## NP(x) = P(x) * (-1) * [-------------] +## n n (n+m)! ## @end group ## @end example ## @@ -286,7 +286,7 @@ %!test %! result = legendre (0, 0:0.1:1); -%! assert (result, full(ones(1,11))); +%! assert (result, full (ones (1,11))); %!test %! result = legendre (3, [-1,0,1;1,0,-1]); @@ -303,13 +303,14 @@ %! assert (result, expected); %% Check correct invocation -%!error legendre (); -%!error legendre (1); -%!error legendre (1,2,3,4); -%!error legendre ([1, 2], [-1, 0, 1]); -%!error legendre (-1, [-1, 0, 1]); -%!error legendre (1.1, [-1, 0, 1]); -%!error legendre (1, [-1+i, 0, 1]); -%!error legendre (1, [-2, 0, 1]); -%!error legendre (1, [-1, 0, 2]); -%!error legendre (1, [-1, 0, 1], "badnorm"); +%!error legendre () +%!error legendre (1) +%!error legendre (1,2,3,4) +%!error legendre ([1, 2], [-1, 0, 1]) +%!error legendre (-1, [-1, 0, 1]) +%!error legendre (1.1, [-1, 0, 1]) +%!error legendre (1, [-1+i, 0, 1]) +%!error legendre (1, [-2, 0, 1]) +%!error legendre (1, [-1, 0, 2]) +%!error legendre (1, [-1, 0, 1], "badnorm") +
--- a/scripts/specfun/nchoosek.m +++ b/scripts/specfun/nchoosek.m @@ -141,7 +141,7 @@ %!assert (nchoosek (80,10), bincoeff (80,10)) -%!assert (nchoosek(1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5]) +%!assert (nchoosek (1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5]) %% Test input validation %!warning nchoosek (100,45);
--- a/scripts/specfun/nthroot.m +++ b/scripts/specfun/nthroot.m @@ -81,11 +81,12 @@ endfunction -%!assert (nthroot(-32,5), -2); -%!assert (nthroot(81,4), 3); -%!assert (nthroot(Inf,4), Inf); -%!assert (nthroot(-Inf,7), -Inf); -%!assert (nthroot(-Inf,-7), 0); + +%!assert (nthroot (-32,5), -2); +%!assert (nthroot (81,4), 3); +%!assert (nthroot (Inf,4), Inf); +%!assert (nthroot (-Inf,7), -Inf); +%!assert (nthroot (-Inf,-7), 0); %% Test input validation %!error (nthroot ())
--- a/scripts/specfun/perms.m +++ b/scripts/specfun/perms.m @@ -64,10 +64,11 @@ endif endfunction -%!error perms (); -%!error perms (1, 2); -%!assert (perms ([1,2,3]), [1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1]); -%!assert (perms (1:3), perms ([1,2,3])); +%!assert (perms ([1,2,3]), [1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1]) +%!assert (perms (1:3), perms ([1,2,3])) +%!assert (perms (int8 ([1,2,3])), int8 ([1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1])) -%!assert (perms (int8([1,2,3])), int8([1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1])); +%!error perms () +%!error perms (1, 2) +
--- a/scripts/specfun/pow2.m +++ b/scripts/specfun/pow2.m @@ -54,16 +54,17 @@ endfunction + %!test %! x = [3, 0, -3]; %! v = [8, 1, .125]; -%! assert(all (abs (pow2 (x) - v) < sqrt (eps))); +%! assert (pow2 (x), v, sqrt (eps)); %!test %! x = [3, 0, -3, 4, 0, -4, 5, 0, -5]; %! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3]; %! z = x .* (2 .^ y); -%! assert(all (abs (pow2 (x,y) - z) < sqrt (eps))); +%! assert (pow2 (x,y), z, sqrt (eps)); -%!error pow2(); +%!error pow2 ()
--- a/scripts/specfun/primes.m +++ b/scripts/specfun/primes.m @@ -93,10 +93,10 @@ endfunction -%!error primes (); -%!error primes (1, 2); + +%!assert (size (primes (350)), [1, 70]) +%!assert (primes (357)(end), 353) -%!assert (size (primes (350)), [1, 70]); -%!assert (size (primes (350)), [1, 70]); +%!error primes () +%!error primes (1, 2) -%!assert (primes (357)(end), 353);
--- a/scripts/specfun/reallog.m +++ b/scripts/specfun/reallog.m @@ -33,8 +33,11 @@ endif endfunction -%!assert (log(1:5),reallog(1:5)) + +%!assert (log (1:5), reallog (1:5)) %!test %! x = rand (10,10); -%! assert (log(x),reallog(x)) -%!error (reallog(-1)) +%! assert (log (x),reallog (x)); + +%!error <produced complex result> reallog (-1) +
--- a/scripts/specfun/realpow.m +++ b/scripts/specfun/realpow.m @@ -35,11 +35,14 @@ endif endfunction + %!assert (power (1:10, 0.5:0.5:5), realpow (1:10, 0.5:0.5:5)) %!assert ([1:10] .^ [0.5:0.5:5], realpow (1:10, 0.5:0.5:5)) %!test %! x = rand (10,10); %! y = randn (10,10); -%! assert (x.^y,realpow(x,y)) -%!assert (realpow(1i,2),-1) -%!error (realpow(-1, 1/2)) +%! assert (x.^y, realpow (x,y)); +%!assert (realpow (1i,2), -1) + +%!error <produced complex result> realpow (-1, 1/2) +
--- a/scripts/specfun/realsqrt.m +++ b/scripts/specfun/realsqrt.m @@ -33,8 +33,11 @@ endif endfunction -%!assert (sqrt(1:5),realsqrt(1:5)) + +%!assert (sqrt (1:5), realsqrt (1:5)) %!test %! x = rand (10,10); -%! assert (sqrt(x),realsqrt(x)) -%!error (realsqrt(-1)) +%! assert (sqrt (x), realsqrt (x)); + +%!error <produced complex result> realsqrt (-1) +
--- a/scripts/special-matrix/hadamard.m +++ b/scripts/special-matrix/hadamard.m @@ -165,7 +165,7 @@ %!assert (hadamard (2), [1,1;1,-1]) %!test %! for n = [1,2,4,8,12,24,48,20,28,2^9] -%! h = hadamard(n); +%! h = hadamard (n); %! assert (norm (h*h' - n*eye (n)), 0); %! endfor
--- a/scripts/special-matrix/hankel.m +++ b/scripts/special-matrix/hankel.m @@ -29,7 +29,7 @@ ## @var{r}, has the elements ## @tex ## $$ -## H (i, j) = \cases{c_{i+j-1},&$i+j-1\le m$;\cr r_{i+j-m},&otherwise.\cr} +## H(i, j) = \cases{c_{i+j-1},&$i+j-1\le m$;\cr r_{i+j-m},&otherwise.\cr} ## $$ ## @end tex ## @ifnottex @@ -91,8 +91,8 @@ %!assert (hankel (1:3,3:4), [1,2;2,3;3,4]) %!assert (hankel (1:3,4:6), [1,2,3;2,3,5;3,5,6]) -%!error hankel (); -%!error hankel (1, 2, 3); +%!error hankel () +%!error hankel (1, 2, 3) %!error <C must be a vector> hankel ([1, 2; 3, 4]) %!error <C and R must be vectors> hankel (1:4, [1, 2; 3, 4])
--- a/scripts/special-matrix/hilb.m +++ b/scripts/special-matrix/hilb.m @@ -22,13 +22,13 @@ ## of a Hilbert matrix is defined as ## @tex ## $$ -## H (i, j) = {1 \over (i + j - 1)} +## H(i, j) = {1 \over (i + j - 1)} ## $$ ## @end tex ## @ifnottex ## ## @example -## H (i, j) = 1 / (i + j - 1) +## H(i, j) = 1 / (i + j - 1) ## @end example ## ## @end ifnottex @@ -41,9 +41,9 @@ ## @example ## @group ## cond (rand (5)) -## @result{} 14.392 +## @result{} 14.392 ## cond (hilb (5)) -## @result{} 4.7661e+05 +## @result{} 4.7661e+05 ## @end group ## @end example ## @@ -75,5 +75,5 @@ %!error hilb () %!error hilb (1, 2) -%!error <N must be a scalar integer> hilb (ones(2)) +%!error <N must be a scalar integer> hilb (ones (2))
--- a/scripts/special-matrix/invhilb.m +++ b/scripts/special-matrix/invhilb.m @@ -120,7 +120,7 @@ %! 240 , -2700, 6480 , -4200; %! -140, 1680 , -4200, 2800]; %! assert (invhilb (4), result4); -%!assert (abs (invhilb (7) * hilb (7) - eye (7)) < sqrt (eps)) +%!assert (invhilb (7) * hilb (7), eye (7), sqrt (eps)) %!error invhilb () %!error invhilb (1, 2)
--- a/scripts/special-matrix/magic.m +++ b/scripts/special-matrix/magic.m @@ -80,13 +80,13 @@ %!test -%! for i=3:30 +%! for i = 3:30 %! A = magic (i); %! assert (norm(diff([sum(diag(A)),sum(diag(flipud(A))),sum(A),sum(A')])),0); %! endfor %!assert (isempty (magic (0))) -%!assert (magic(1), 1) +%!assert (magic (1), 1) %% Test input validation %!error magic ()
--- a/scripts/special-matrix/rosser.m +++ b/scripts/special-matrix/rosser.m @@ -44,5 +44,9 @@ endfunction -%!assert (size(rosser()), [8,8]) -%!error (rosser(1)) + +%!assert (size (rosser ()), [8,8]) +%!assert (rosser ()([1, end]), [611, 99]) + +%!error (rosser (1)) +
--- a/scripts/special-matrix/vander.m +++ b/scripts/special-matrix/vander.m @@ -79,17 +79,17 @@ %!test %! c = [0,1,2,3]; %! expect = [0,0,0,1; 1,1,1,1; 8,4,2,1; 27,9,3,1]; -%! assert(vander (c), expect); +%! assert (vander (c), expect); %!assert (vander (1), 1) %!assert (vander ([1, 2, 3]), vander ([1; 2; 3])) %!assert (vander ([1, 2, 3]), [1, 1, 1; 4, 2, 1; 9, 3, 1]) %!assert (vander ([1, 2, 3]*i), [-1, i, 1; -4, 2i, 1; -9, 3i, 1]) -%!assert(vander (2, 3), [4, 2, 1]) -%!assert(vander ([2, 3], 3), [4, 2, 1; 9, 3, 1]) +%!assert (vander (2, 3), [4, 2, 1]) +%!assert (vander ([2, 3], 3), [4, 2, 1; 9, 3, 1]) -%!error vander (); -%!error vander (1, 2, 3); -%!error <polynomial C must be a vector> vander ([1, 2; 3, 4]); +%!error vander () +%!error vander (1, 2, 3) +%!error <polynomial C must be a vector> vander ([1, 2; 3, 4])
--- a/scripts/startup/__finish__.m +++ b/scripts/startup/__finish__.m @@ -37,5 +37,6 @@ endfunction + ## No test needed for internal helper function. %!assert (1)
--- a/scripts/statistics/base/center.m +++ b/scripts/statistics/base/center.m @@ -65,19 +65,21 @@ endfunction -%!assert(center ([1,2,3]), [-1,0,1]) -%!assert(center (single([1,2,3])), single([-1,0,1])) -%!assert(center (int8 ([1,2,3])), [-1,0,1]) -%!assert(center (logical ([1, 0, 0, 1])), [0.5, -0.5, -0.5, 0.5]) -%!assert(center (ones (3,2,0,2)), zeros (3,2,0,2)) -%!assert(center (ones (3,2,0,2, 'single')), zeros (3,2,0,2, 'single')) -%!assert(center (magic (3)), [3,-4,1;-2,0,2;-1,4,-3]) -%!assert(center ([1 2 3; 6 5 4], 2), [-1 0 1; 1 0 -1]) + +%!assert (center ([1,2,3]), [-1,0,1]) +%!assert (center (single ([1,2,3])), single ([-1,0,1])) +%!assert (center (int8 ([1,2,3])), [-1,0,1]) +%!assert (center (logical ([1, 0, 0, 1])), [0.5, -0.5, -0.5, 0.5]) +%!assert (center (ones (3,2,0,2)), zeros (3,2,0,2)) +%!assert (center (ones (3,2,0,2, "single")), zeros (3,2,0,2, "single")) +%!assert (center (magic (3)), [3,-4,1;-2,0,2;-1,4,-3]) +%!assert (center ([1 2 3; 6 5 4], 2), [-1 0 1; 1 0 -1]) %% Test input validation %!error center () %!error center (1, 2, 3) -%!error center (1, ones(2,2)) +%!error center (1, ones (2,2)) %!error center (1, 1.5) %!error center (1, 0) %!error center (1, 3) +
--- a/scripts/statistics/base/cloglog.m +++ b/scripts/statistics/base/cloglog.m @@ -27,7 +27,7 @@ ## @ifnottex ## ## @example -## cloglog(x) = - log (- log (@var{x})) +## cloglog (x) = - log (- log (@var{x})) ## @end example ## ## @end ifnottex @@ -46,10 +46,12 @@ endfunction -%!assert(cloglog(0), -Inf) -%!assert(cloglog(1), Inf) -%!assert(cloglog(1/e), 0) + +%!assert (cloglog (0), -Inf) +%!assert (cloglog (1), Inf) +%!assert (cloglog (1/e), 0) %% Test input validation %!error cloglog () %!error cloglog (1, 2) +
--- a/scripts/statistics/base/corr.m +++ b/scripts/statistics/base/corr.m @@ -33,7 +33,7 @@ ## @ifnottex ## ## @example -## corr(x,y) = cov(x,y)/(std(x)*std(y)) +## corr (x,y) = cov (x,y) / (std (x) * std (y)) ## @end example ## ## @end ifnottex @@ -56,7 +56,7 @@ ## Special case, scalar is always 100% correlated with itself if (isscalar (x)) - if (isa (x, 'single')) + if (isa (x, "single")) retval = single (1); else retval = 1; @@ -89,24 +89,24 @@ %!test %! x = [1:3]'; %! y = [3:-1:1]'; -%! assert (corr (x,y), -1, 5*eps) -%! assert (corr (x,flipud (y)), 1, 5*eps) -%! assert (corr ([x, y]), [1 -1; -1 1], 5*eps) +%! assert (corr (x, y), -1, 5*eps); +%! assert (corr (x, flipud (y)), 1, 5*eps); +%! assert (corr ([x, y]), [1 -1; -1 1], 5*eps); %!test %! x = single ([1:3]'); %! y = single ([3:-1:1]'); -%! assert (corr (x,y), single (-1), 5*eps) -%! assert (corr (x,flipud (y)), single (1), 5*eps) -%! assert (corr ([x, y]), single ([1 -1; -1 1]), 5*eps) +%! assert (corr (x, y), single (-1), 5*eps); +%! assert (corr (x, flipud (y)), single (1), 5*eps); +%! assert (corr ([x, y]), single ([1 -1; -1 1]), 5*eps); -%!assert (corr (5), 1); -%!assert (corr (single(5)), single(1)); +%!assert (corr (5), 1) +%!assert (corr (single(5)), single(1)) %% Test input validation -%!error corr (); -%!error corr (1, 2, 3); -%!error corr ([1; 2], ["A", "B"]); -%!error corr (ones (2,2,2)); -%!error corr (ones (2,2), ones (2,2,2)); +%!error corr () +%!error corr (1, 2, 3) +%!error corr ([1; 2], ["A", "B"]) +%!error corr (ones (2,2,2)) +%!error corr (ones (2,2), ones (2,2,2))
--- a/scripts/statistics/base/cov.m +++ b/scripts/statistics/base/cov.m @@ -86,7 +86,7 @@ ## Special case, scalar has zero covariance if (isscalar (x)) - if (isa (x, 'single')) + if (isa (x, "single")) c = single (0); else c = 0; @@ -121,22 +121,22 @@ %! x = rand (10); %! cx1 = cov (x); %! cx2 = cov (x, x); -%! assert(size (cx1) == [10, 10] && size (cx2) == [10, 10]); -%! assert(cx1, cx2, 1e1*eps); +%! assert (size (cx1) == [10, 10] && size (cx2) == [10, 10]); +%! assert (cx1, cx2, 1e1*eps); %!test %! x = [1:3]'; %! y = [3:-1:1]'; -%! assert (cov (x,y), -1, 5*eps) -%! assert (cov (x,flipud (y)), 1, 5*eps) -%! assert (cov ([x, y]), [1 -1; -1 1], 5*eps) +%! assert (cov (x, y), -1, 5*eps); +%! assert (cov (x, flipud (y)), 1, 5*eps); +%! assert (cov ([x, y]), [1 -1; -1 1], 5*eps); %!test %! x = single ([1:3]'); %! y = single ([3:-1:1]'); -%! assert (cov (x,y), single (-1), 5*eps) -%! assert (cov (x,flipud (y)), single (1), 5*eps) -%! assert (cov ([x, y]), single ([1 -1; -1 1]), 5*eps) +%! assert (cov (x, y), single (-1), 5*eps); +%! assert (cov (x, flipud (y)), single (1), 5*eps); +%! assert (cov ([x, y]), single ([1 -1; -1 1]), 5*eps); %!test %! x = [1:5]; @@ -144,8 +144,8 @@ %! assert (isscalar (c)); %! assert (c, 2.5); -%!assert(cov (5), 0); -%!assert(cov (single(5)), single(0)); +%!assert(cov (5), 0) +%!assert(cov (single(5)), single(0)) %!test %! x = [1:5]; @@ -155,11 +155,11 @@ %! assert(c, 2); %% Test input validation -%!error cov (); -%!error cov (1, 2, 3, 4); -%!error cov ([1; 2], ["A", "B"]); -%!error cov (ones (2,2,2)); -%!error cov (ones (2,2), ones (2,2,2)); -%!error cov (1, 3); -%!error cov (ones (2,2), ones (3,2)); +%!error cov () +%!error cov (1, 2, 3, 4) +%!error cov ([1; 2], ["A", "B"]) +%!error cov (ones (2,2,2)) +%!error cov (ones (2,2), ones (2,2,2)) +%!error cov (1, 3) +%!error cov (ones (2,2), ones (3,2))
--- a/scripts/statistics/base/gls.m +++ b/scripts/statistics/base/gls.m @@ -140,6 +140,6 @@ %!error gls (ones (2,2,2), ones (2,2), ones (4,4)) %!error gls (ones (2,2), ones (2,2,2), ones (4,4)) %!error gls (ones (2,2), ones (2,2), ones (4,4,4)) -%!error gls (ones(1,2), ones(2,2), ones (2,2)) -%!error gls (ones(2,2), ones(2,2), ones (2,2)) +%!error gls (ones (1,2), ones (2,2), ones (2,2)) +%!error gls (ones (2,2), ones (2,2), ones (2,2))
--- a/scripts/statistics/base/histc.m +++ b/scripts/statistics/base/histc.m @@ -168,9 +168,10 @@ %! n = histc (x, 0:10, 2); %! assert (n, repmat ([repmat(100, 1, 10), 1], [2, 1, 3])); -%!error histc (); -%!error histc (1); -%!error histc (1, 2, 3, 4); -%!error histc ([1:10 1+i], 2); -%!error histc (1:10, []); -%!error histc (1, 1, 3); +%!error histc () +%!error histc (1) +%!error histc (1, 2, 3, 4) +%!error histc ([1:10 1+i], 2) +%!error histc (1:10, []) +%!error histc (1, 1, 3) +
--- a/scripts/statistics/base/iqr.m +++ b/scripts/statistics/base/iqr.m @@ -60,8 +60,8 @@ ## can take a matrix, rather than just a vector argument. n = sz(dim); sz(dim) = 1; - if (isa (x, 'single')) - y = zeros (sz, 'single'); + if (isa (x, "single")) + y = zeros (sz, "single"); else y = zeros (sz); endif @@ -82,17 +82,17 @@ endfunction -%!assert (iqr (1:101), 50); -%!assert (iqr (single(1:101)), single(50)); +%!assert (iqr (1:101), 50) +%!assert (iqr (single (1:101)), single (50)) %%!test %%! x = [1:100]; %%! n = iqr (x, 0:10); %%! assert (n, [repmat(100, 1, 10), 1]); -%!error iqr (); -%!error iqr (1, 2, 3); -%!error iqr (1); -%!error iqr (['A'; 'B']); -%!error iqr (1:10, 3); +%!error iqr () +%!error iqr (1, 2, 3) +%!error iqr (1) +%!error iqr (['A'; 'B']) +%!error iqr (1:10, 3)
--- a/scripts/statistics/base/kendall.m +++ b/scripts/statistics/base/kendall.m @@ -99,10 +99,10 @@ endif endif - if (isa (x, 'single') || isa (y, 'single')) - cls = 'single'; + if (isa (x, "single") || isa (y, "single")) + cls = "single"; else - cls = 'double'; + cls = "double"; endif r = ranks (x); m = sign (kron (r, ones (n, 1, cls)) - kron (ones (n, 1, cls), r)); @@ -121,14 +121,15 @@ %! assert (kendall (x,y), 1, 5*eps); %! assert (kendall (x,fliplr (y)), -1, 5*eps); -%!assert (kendall (logical(1)), 1); -%!assert (kendall (single(1)), single(1)); +%!assert (kendall (logical (1)), 1) +%!assert (kendall (single (1)), single (1)) %% Test input validation -%!error kendall (); -%!error kendall (1, 2, 3); -%!error kendall (['A'; 'B']); -%!error kendall (ones(2,1), ['A'; 'B']); -%!error kendall (ones (2,2,2)); -%!error kendall (ones (2,2), ones (2,2,2)); -%!error kendall (ones (2,2), ones (3,2)); +%!error kendall () +%!error kendall (1, 2, 3) +%!error kendall (['A'; 'B']) +%!error kendall (ones (2,1), ['A'; 'B']) +%!error kendall (ones (2,2,2)) +%!error kendall (ones (2,2), ones (2,2,2)) +%!error kendall (ones (2,2), ones (3,2)) +
--- a/scripts/statistics/base/kurtosis.m +++ b/scripts/statistics/base/kurtosis.m @@ -29,7 +29,7 @@ ## @ifnottex ## ## @example -## kurtosis (x) = N^(-1) std(x)^(-4) sum ((x - mean(x)).^4) - 3 +## kurtosis (x) = 1/N std(x)^(-4) sum ((x - mean(x)).^4) - 3 ## @end example ## ## @end ifnottex @@ -87,13 +87,13 @@ %! y = [x, 2*x]; %! assert (kurtosis (y), [-1.4, -1.4], sqrt (eps)); -%!assert (kurtosis (single(1)), single(0)); +%!assert (kurtosis (single (1)), single (0)) %% Test input validation %!error kurtosis () %!error kurtosis (1, 2, 3) %!error kurtosis (['A'; 'B']) -%!error kurtosis (1, ones(2,2)) +%!error kurtosis (1, ones (2,2)) %!error kurtosis (1, 1.5) %!error kurtosis (1, 0) %!error kurtosis (1, 3)
--- a/scripts/statistics/base/logit.m +++ b/scripts/statistics/base/logit.m @@ -27,7 +27,7 @@ ## @ifnottex ## ## @example -## logit(@var{p}) = log (@var{p} / (1-@var{p})) +## logit (@var{p}) = log (@var{p} / (1-@var{p})) ## @end example ## ## @end ifnottex @@ -50,10 +50,11 @@ %!test %! p = [0.01:0.01:0.99]; -%! assert(logit (p), log (p ./ (1-p)), 25*eps) +%! assert (logit (p), log (p ./ (1-p)), 25*eps); -%!assert(logit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, +Inf, NaN]) +%!assert (logit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, +Inf, NaN]) %% Test input validation %!error logit () %!error logit (1, 2) +
--- a/scripts/statistics/base/mahalanobis.m +++ b/scripts/statistics/base/mahalanobis.m @@ -71,10 +71,11 @@ %% Test input validation -%!error mahalanobis (); -%!error mahalanobis (1, 2, 3); -%!error mahalanobis ('A', 'B'); -%!error mahalanobis ([1, 2], ['A', 'B']); -%!error mahalanobis (ones (2,2,2)); -%!error mahalanobis (ones (2,2), ones (2,2,2)); -%!error mahalanobis (ones (2,2), ones (2,3)); +%!error mahalanobis () +%!error mahalanobis (1, 2, 3) +%!error mahalanobis ('A', 'B') +%!error mahalanobis ([1, 2], ['A', 'B']) +%!error mahalanobis (ones (2,2,2)) +%!error mahalanobis (ones (2,2), ones (2,2,2)) +%!error mahalanobis (ones (2,2), ones (2,3)) +
--- a/scripts/statistics/base/mean.m +++ b/scripts/statistics/base/mean.m @@ -127,25 +127,25 @@ %! x = -10:10; %! y = x'; %! z = [y, y+10]; -%! assert(mean (x) == 0); -%! assert(mean (y) == 0); -%! assert(mean (z) == [0, 10]); +%! assert (mean (x), 0); +%! assert (mean (y), 0); +%! assert (mean (z), [0, 10]); -%!assert(mean (magic(3), 1), [5, 5, 5]); -%!assert(mean (magic(3), 2), [5; 5; 5]); -%!assert(mean ([2 8], 'g'), 4); -%!assert(mean ([4 4 2], 'h'), 3); -%!assert(mean (logical ([1 0 1 1])), 0.75); -%!assert(mean (single ([1 0 1 1])), single (0.75)); +%!assert (mean (magic (3), 1), [5, 5, 5]) +%!assert (mean (magic (3), 2), [5; 5; 5]) +%!assert (mean ([2 8], "g"), 4) +%!assert (mean ([4 4 2], "h"), 3) +%!assert (mean (logical ([1 0 1 1])), 0.75) +%!assert (mean (single ([1 0 1 1])), single (0.75)) %% Test input validation -%!error mean (); -%!error mean (1, 2, 3, 4); -%!error mean ({1:5}); -%!error mean (1, 2, 3); -%!error mean (1, ones(2,2)); -%!error mean (1, 1.5); -%!error mean (1, 0); -%!error mean (1, 3); -%!error mean (1, 'b'); +%!error mean () +%!error mean (1, 2, 3, 4) +%!error mean ({1:5}) +%!error mean (1, 2, 3) +%!error mean (1, ones(2,2)) +%!error mean (1, 1.5) +%!error mean (1, 0) +%!error mean (1, 3) +%!error mean (1, "b")
--- a/scripts/statistics/base/meansq.m +++ b/scripts/statistics/base/meansq.m @@ -73,16 +73,16 @@ endfunction -%!assert(meansq (1:5), 11); -%!assert(meansq (single(1:5)), single(11)); -%!assert(meansq (magic (4)), [94.5, 92.5, 92.5, 94.5]); -%!assert(meansq (magic (4), 2), [109.5; 77.5; 77.5; 109.5]); +%!assert (meansq (1:5), 11) +%!assert (meansq (single (1:5)), single (11)) +%!assert (meansq (magic (4)), [94.5, 92.5, 92.5, 94.5]) +%!assert (meansq (magic (4), 2), [109.5; 77.5; 77.5; 109.5]) %% Test input validation %!error meansq () %!error meansq (1, 2, 3) -%!error meansq (['A'; 'B']); -%!error meansq (1, ones(2,2)) +%!error meansq (['A'; 'B']) +%!error meansq (1, ones (2,2)) %!error meansq (1, 1.5) %!error meansq (1, 0) %!error meansq (1, 3)
--- a/scripts/statistics/base/median.m +++ b/scripts/statistics/base/median.m @@ -34,9 +34,9 @@ ## ## @example ## @group -## x(ceil(N/2)), N odd -## median(x) = -## (x(N/2) + x((N/2)+1))/2, N even +## x(ceil(N/2)) N odd +## median (x) = +## (x(N/2) + x((N/2)+1))/2 N even ## @end group ## @end example ## @@ -94,20 +94,20 @@ %! y = [1, 2, 3, 4, 5, 6, 7]; %! y2 = y'; %! -%! assert(median (x) == median (x2) && median (x) == 3.5); -%! assert(median (y) == median (y2) && median (y) == 4); -%! assert(median ([x2, 2*x2]) == [3.5, 7]); -%! assert(median ([y2, 3*y2]) == [4, 12]); +%! assert (median (x) == median (x2) && median (x) == 3.5); +%! assert (median (y) == median (y2) && median (y) == 4); +%! assert (median ([x2, 2*x2]), [3.5, 7]); +%! assert (median ([y2, 3*y2]), [4, 12]); -%!assert(median (single([1,2,3])), single(2)); -%!assert(median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN]); +%!assert (median (single ([1,2,3])), single (2)) +%!assert (median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN]) %% Test input validation -%!error median (); -%!error median (1, 2, 3); -%!error median ({1:5}); -%!error median (['A'; 'B']); -%!error median (1, ones(2,2)); -%!error median (1, 1.5); -%!error median (1, 0); +%!error median () +%!error median (1, 2, 3) +%!error median ({1:5}) +%!error median (['A'; 'B']) +%!error median (1, ones(2,2)) +%!error median (1, 1.5) +%!error median (1, 0)
--- a/scripts/statistics/base/mode.m +++ b/scripts/statistics/base/mode.m @@ -116,15 +116,15 @@ %! assert (c ,c_exp); %! assert (c2,c_exp ); -%!assert(mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4]); -%!assert(mode ([2,3,1,2,3,4],2),2); -%!assert(mode ([2,3,1,2,3,4]),2); -%!assert(mode (single([2,3,1,2,3,4])), single(2)); -%!assert(mode (int8([2,3,1,2,3,4])), int8(2)); +%!assert (mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4]) +%!assert (mode ([2,3,1,2,3,4],2),2) +%!assert (mode ([2,3,1,2,3,4]),2) +%!assert (mode (single ([2,3,1,2,3,4])), single (2)) +%!assert (mode (int8 ([2,3,1,2,3,4])), int8 (2)) -%!assert(mode ([2;3;1;2;3;4],1),2); -%!assert(mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4]); -%!assert(mode ([2;3;1;2;3;4]),2); +%!assert (mode ([2;3;1;2;3;4],1),2) +%!assert (mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4]) +%!assert (mode ([2;3;1;2;3;4]),2) %!shared x %! x(:,:,1) = toeplitz (1:3); @@ -160,7 +160,7 @@ %!error mode (1, 2, 3) %!error mode ({1 2 3}) %!error mode (['A'; 'B']) -%!error mode (1, ones(2,2)) +%!error mode (1, ones (2,2)) %!error mode (1, 1.5) %!error mode (1, 0) %!error mode (1, 3)
--- a/scripts/statistics/base/moment.m +++ b/scripts/statistics/base/moment.m @@ -43,6 +43,7 @@ ## ## The optional string @var{type} specifies the type of moment to be computed. ## Valid options are: +## ## @table @asis ## @item "c" ## Central Moment. The moment about the mean defined as @@ -72,7 +73,7 @@ ## ## @example ## @group -## 1/N SUM_i ( abs(x(i)) )^p +## 1/N SUM_i ( abs (x(i)) )^p ## @end group ## @end example ## @@ -89,7 +90,7 @@ ## ## @example ## @group -## 1/N SUM_i ( abs(x(i) - mean(x)) )^p +## 1/N SUM_i ( abs (x(i) - mean(x)) )^p ## @end group ## @end example ## @@ -178,21 +179,21 @@ %! assert (moment (x,1), mean (x), 1e1*eps); %! assert (moment (x,2), meansq (x), 1e1*eps); %! assert (moment (x,1,2), mean (x,2), 1e1*eps); -%! assert (moment (x,1,'c'), mean (center (x)), 1e1*eps); -%! assert (moment (x,1,'a'), mean (abs (x)), 1e1*eps); +%! assert (moment (x,1,"c"), mean (center (x)), 1e1*eps); +%! assert (moment (x,1,"a"), mean (abs (x)), 1e1*eps); -%!assert (moment (single([1 2 3]),1), single(2)); +%!assert (moment (single ([1 2 3]), 1), single (2)) %% Test input validation %!error moment () %!error moment (1) %!error moment (1, 2, 3, 4, 5) %!error moment (['A'; 'B'], 2) -%!error moment (ones(2,0,3), 2) +%!error moment (ones (2,0,3), 2) %!error moment (1, true) -%!error moment (1, ones(2,2)) +%!error moment (1, ones (2,2)) %!error moment (1, 2, 3, 4) -%!error moment (1, 2, ones(2,2)) +%!error moment (1, 2, ones (2,2)) %!error moment (1, 2, 1.5) %!error moment (1, 2, 4)
--- a/scripts/statistics/base/ols.m +++ b/scripts/statistics/base/ols.m @@ -121,6 +121,14 @@ r = y - x * beta; endif if (isargout (2)) + + ## z is of full rank, avoid the SVD in rnk + if (p == 0) + rnk = columns (z); + else + rnk = rank (z); + endif + sigma = r' * r / (nr - rnk); endif @@ -131,14 +139,36 @@ %! x = [1:5]'; %! y = 3*x + 2; %! x = [x, ones(5,1)]; -%! assert (ols(y,x), [3; 2], 50*eps) +%! assert (ols (y,x), [3; 2], 50*eps) + +%!test +%! x = [1, 2; 3, 4]; +%! y = [1; 2]; +%! [b, s, r] = ols (x, y); +%! assert (b, [1.4, 2], 2*eps); +%! assert (s, [0.2, 0; 0, 0], 2*eps); +%! assert (r, [-0.4, 0; 0.2, 0], 2*eps); + +%!test +%! x = [1, 2; 3, 4]; +%! y = [1; 2]; +%! [b, s] = ols (x, y); +%! assert (b, [1.4, 2], 2*eps); +%! assert (s, [0.2, 0; 0, 0], 2*eps); + +%!test +%! x = [1, 2; 3, 4]; +%! y = [1; 2]; +%! b = ols (x, y); +%! assert (b, [1.4, 2], 2*eps); %% Test input validation -%!error ols (); -%!error ols (1); -%!error ols (1, 2, 3); -%!error ols ([true, true], [1, 2]); -%!error ols ([1, 2], [true, true]); -%!error ols (ones (2,2,2), ones (2,2)); -%!error ols (ones (2,2), ones (2,2,2)); -%!error ols (ones(1,2), ones(2,2)); +%!error ols () +%!error ols (1) +%!error ols (1, 2, 3) +%!error ols ([true, true], [1, 2]) +%!error ols ([1, 2], [true, true]) +%!error ols (ones (2,2,2), ones (2,2)) +%!error ols (ones (2,2), ones (2,2,2)) +%!error ols (ones (1,2), ones (2,2)) +
--- a/scripts/statistics/base/ppplot.m +++ b/scripts/statistics/base/ppplot.m @@ -79,6 +79,6 @@ %% Test input validation -%!error ppplot (); -%!error ppplot (ones(2,2)); +%!error ppplot () +%!error ppplot (ones (2,2))
--- a/scripts/statistics/base/prctile.m +++ b/scripts/statistics/base/prctile.m @@ -173,3 +173,4 @@ %!error prctile (1, 1, 1.5) %!error prctile (1, 1, 0) %!error prctile (1, 1, 3) +
--- a/scripts/statistics/base/probit.m +++ b/scripts/statistics/base/probit.m @@ -36,7 +36,8 @@ endfunction -%!assert(probit([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, Inf, NaN]); + +%!assert (probit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, Inf, NaN]) %% Test input validation %!error probit ()
--- a/scripts/statistics/base/quantile.m +++ b/scripts/statistics/base/quantile.m @@ -51,10 +51,10 @@ ## interpolation function respecting each methods' representative cdf. ## ## @enumerate 4 -## @item Method 4: p(k) = k / n. That is, linear interpolation of the +## @item Method 4: p(k) = k / n. That is, linear interpolation of the ## empirical cdf. ## -## @item Method 5: p(k) = (k - 0.5) / n. That is a piecewise linear function +## @item Method 5: p(k) = (k - 0.5) / n. That is a piecewise linear function ## where the knots are the values midway through the steps of the empirical ## cdf. ## @@ -157,7 +157,7 @@ %! p = 0.5; %! x = sort (rand (11)); %! q = quantile (x, p); -%! assert (q, x(6,:)) +%! assert (q, x(6,:)); %! x = x.'; %! q = quantile (x, p, 2); %! assert (q, x(:,6)); @@ -174,9 +174,9 @@ %! 1.0000 1.7500 2.5000 3.2500 4.0000 %! 1.0000 1.4167 2.5000 3.5833 4.0000 %! 1.0000 1.4375 2.5000 3.5625 4.0000]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -191,9 +191,9 @@ %! 1.0000 2.0000 3.0000 4.0000 5.0000 %! 1.0000 1.6667 3.0000 4.3333 5.0000 %! 1.0000 1.6875 3.0000 4.3125 5.0000]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -208,9 +208,9 @@ %! 1.0000 1.7500 3.5000 6.0000 9.0000 %! 1.0000 1.4167 3.5000 7.3333 9.0000 %! 1.0000 1.4375 3.5000 7.2500 9.0000]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -225,9 +225,9 @@ %! 1.0000 2.0000 5.0000 9.0000 11.0000 %! 1.0000 1.6667 5.0000 9.6667 11.0000 %! 1.0000 1.6875 5.0000 9.6250 11.0000]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -242,9 +242,9 @@ %! 6.0000 10.2500 11.5000 14.2500 16.0000 %! 6.0000 9.8333 11.5000 15.0000 16.0000 %! 6.0000 9.8750 11.5000 15.0000 16.0000]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -260,9 +260,9 @@ %! -2.551474 -0.571522 -0.067751 0.106855 0.495271 %! -2.551474 -0.591566 -0.067751 0.146459 0.495271 %! -2.551474 -0.590801 -0.067751 0.140686 0.495271]; -%! for m = (1:9) +%! for m = 1:9 %! q = quantile (x, p, 1, m).'; -%! assert (q, a(m,:), 0.0001) +%! assert (q, a(m,:), 0.0001); %! endfor %!test @@ -274,11 +274,11 @@ %! 0.933100, 0.931200, 0.963500, 0.779600, 0.846100]; %! tol = 0.00001; %! x(5,5) = NaN; -%! assert (quantile(x, p, 1), [0.27950, 0.79780, 0.32960, 0.55670, 0.44460], tol); +%! assert (quantile (x, p, 1), [0.27950, 0.79780, 0.32960, 0.55670, 0.44460], tol); %! x(1,1) = NaN; -%! assert (quantile(x, p, 1), [0.35415, 0.79780, 0.32960, 0.55670, 0.44460], tol); +%! assert (quantile (x, p, 1), [0.35415, 0.79780, 0.32960, 0.55670, 0.44460], tol); %! x(3,3) = NaN; -%! assert (quantile(x, p, 1), [0.35415, 0.79780, 0.42590, 0.55670, 0.44460], tol); +%! assert (quantile (x, p, 1), [0.35415, 0.79780, 0.42590, 0.55670, 0.44460], tol); %!test %! sx = [2, 3, 4];
--- a/scripts/statistics/base/range.m +++ b/scripts/statistics/base/range.m @@ -50,12 +50,13 @@ endfunction -%!assert(range (1:10), 9); -%!assert(range (single(1:10)), single(9)); -%!assert(range (magic (3)), [5, 8, 5]); -%!assert(range (magic (3), 2), [7; 4; 7]); -%!assert(range (2), 0); +%!assert (range (1:10), 9) +%!assert (range (single (1:10)), single (9)) +%!assert (range (magic (3)), [5, 8, 5]) +%!assert (range (magic (3), 2), [7; 4; 7]) +%!assert (range (2), 0) %% Test input validation %!error range () %!error range (1, 2, 3) +
--- a/scripts/statistics/base/ranks.m +++ b/scripts/statistics/base/ranks.m @@ -86,12 +86,12 @@ endfunction -%!assert(ranks (1:2:10), 1:5); -%!assert(ranks (10:-2:1), 5:-1:1); -%!assert(ranks ([2, 1, 2, 4]), [2.5, 1, 2.5, 4]); -%!assert(ranks (ones(1, 5)), 3*ones(1, 5)); -%!assert(ranks (1e6*ones(1, 5)), 3*ones(1, 5)); -%!assert(ranks (rand (1, 5), 1), ones(1, 5)); +%!assert (ranks (1:2:10), 1:5) +%!assert (ranks (10:-2:1), 5:-1:1) +%!assert (ranks ([2, 1, 2, 4]), [2.5, 1, 2.5, 4]) +%!assert (ranks (ones (1, 5)), 3*ones (1, 5)) +%!assert (ranks (1e6*ones (1, 5)), 3*ones (1, 5)) +%!assert (ranks (rand (1, 5), 1), ones (1, 5)) %% Test input validation %!error ranks ()
--- a/scripts/statistics/base/run_count.m +++ b/scripts/statistics/base/run_count.m @@ -93,10 +93,10 @@ endfunction -%!assert(run_count (magic(3), 4), [1,0,1;1,0,1;0,1,0;0,0,0]) -%!assert(run_count (magic(3), 4, 2), [1,0,1;1,0,1;0,1,0;0,0,0]') -%!assert(run_count (5:-1:1, 5), [5, 0, 0, 0, 0]) -%!assert(run_count (ones(3), 4), [0,0,0;0,0,0;1,1,1;0,0,0]) +%!assert (run_count (magic (3), 4), [1,0,1;1,0,1;0,1,0;0,0,0]) +%!assert (run_count (magic (3), 4, 2), [1,0,1;1,0,1;0,1,0;0,0,0]') +%!assert (run_count (5:-1:1, 5), [5, 0, 0, 0, 0]) +%!assert (run_count (ones (3), 4), [0,0,0;0,0,0;1,1,1;0,0,0]) %% Test input validation %!error run_count () @@ -104,10 +104,10 @@ %!error run_count (1, 2, 3, 4) %!error run_count ({1, 2}, 3) %!error run_count (['A'; 'A'; 'B'], 3) -%!error run_count (1:5, ones(2,2)) +%!error run_count (1:5, ones (2,2)) %!error run_count (1:5, 1.5) %!error run_count (1:5, -2) -%!error run_count (1:5, 3, ones(2,2)) +%!error run_count (1:5, 3, ones (2,2)) %!error run_count (1:5, 3, 1.5) %!error run_count (1:5, 3, 0)
--- a/scripts/statistics/base/runlength.m +++ b/scripts/statistics/base/runlength.m @@ -52,8 +52,8 @@ endfunction -%!assert (runlength([2 2 0 4 4 4 0 1 1 1 1]), [2 1 3 1 4]); -%!assert (runlength([2 2 0 4 4 4 0 1 1 1 1]'), [2 1 3 1 4]); +%!assert (runlength ([2 2 0 4 4 4 0 1 1 1 1]), [2 1 3 1 4]) +%!assert (runlength ([2 2 0 4 4 4 0 1 1 1 1]'), [2 1 3 1 4]) %!test %! [c, v] = runlength ([2 2 0 4 4 4 0 1 1 1 1]); %! assert (c, [2 1 3 1 4]); @@ -63,4 +63,5 @@ %!error runlength () %!error runlength (1, 2) %!error runlength (['A'; 'B']) -%!error runlength (ones(2,2)) +%!error runlength (ones (2,2)) +
--- a/scripts/statistics/base/skewness.m +++ b/scripts/statistics/base/skewness.m @@ -29,7 +29,7 @@ ## @ifnottex ## ## @example -## skewness (x) = N^(-1) std(x)^(-3) sum ((x - mean(x)).^3) +## skewness (x) = 1/N std(x)^(-3) sum ((x - mean(x)).^3) ## @end example ## ## @end ifnottex @@ -79,22 +79,23 @@ endfunction -%!assert(skewness ([-1,0,1]), 0); -%!assert(skewness ([-2,0,1]) < 0); -%!assert(skewness ([-1,0,2]) > 0); -%!assert(skewness ([-3,0,1]) == -1*skewness([-1,0,3])); +%!assert (skewness ([-1,0,1]), 0) +%!assert (skewness ([-2,0,1]) < 0) +%!assert (skewness ([-1,0,2]) > 0) +%!assert (skewness ([-3,0,1]) == -1*skewness ([-1,0,3])) %!test %! x = [0; 0; 0; 1]; %! y = [x, 2*x]; %! assert(all (abs (skewness (y) - [0.75, 0.75]) < sqrt (eps))); -%!assert (skewness (single(1)), single(0)); +%!assert (skewness (single (1)), single (0)) %% Test input validation %!error skewness () %!error skewness (1, 2, 3) %!error skewness (['A'; 'B']) -%!error skewness (1, ones(2,2)) +%!error skewness (1, ones (2,2)) %!error skewness (1, 1.5) %!error skewness (1, 0) %!error skewness (1, 3) +
--- a/scripts/statistics/base/spearman.m +++ b/scripts/statistics/base/spearman.m @@ -69,7 +69,7 @@ endif ## Restore class cleared by ranks - if (isa (x, 'single') || isa (y, 'single')) + if (isa (x, "single") || isa (y, "single")) rho = single (rho); endif @@ -82,13 +82,14 @@ %! assert (spearman (x,y), 1, 5*eps); %! assert (spearman (x,-y), -1, 5*eps); -%!assert(spearman ([1 2 3], [-1 1 -2]), -0.5, 5*eps) +%!assert (spearman ([1 2 3], [-1 1 -2]), -0.5, 5*eps) %% Test input validation -%!error spearman (); -%!error spearman (1, 2, 3); -%!error spearman (['A'; 'B']); -%!error spearman (ones(1,2), {1, 2}); -%!error spearman (ones (2,2,2)); -%!error spearman (ones (2,2), ones (2,2,2)); -%!error spearman (ones (2,2), ones (3,2)); +%!error spearman () +%!error spearman (1, 2, 3) +%!error spearman (['A'; 'B']) +%!error spearman (ones (1,2), {1, 2}) +%!error spearman (ones (2,2,2)) +%!error spearman (ones (2,2), ones (2,2,2)) +%!error spearman (ones (2,2), ones (3,2)) +
--- a/scripts/statistics/base/statistics.m +++ b/scripts/statistics/base/statistics.m @@ -81,7 +81,7 @@ %!error statistics () %!error statistics (1, 2, 3) %!error statistics (['A'; 'B']) -%!error statistics (1, ones(2,2)) +%!error statistics (1, ones (2,2)) %!error statistics (1, 1.5) %!error statistics (1, 0) %!error statistics (1, 3)
--- a/scripts/statistics/base/std.m +++ b/scripts/statistics/base/std.m @@ -92,8 +92,8 @@ n = sz(dim); if (n == 1 || isempty (x)) - if (isa (x, 'single')) - retval = zeros (sz, 'single'); + if (isa (x, "single")) + retval = zeros (sz, "single"); else retval = zeros (sz); endif @@ -107,21 +107,21 @@ %!test %! x = ones (10, 2); %! y = [1, 3]; -%! assert(std (x) == [0, 0]); -%! assert(std (y), sqrt (2), sqrt (eps)); -%! assert(std (x, 0, 2), zeros (10, 1)); +%! assert (std (x), [0, 0]); +%! assert (std (y), sqrt (2), sqrt (eps)); +%! assert (std (x, 0, 2), zeros (10, 1)); -%!assert(std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2)); -%!assert(std ([1 2], 0), sqrt(2)/2, 5*eps); -%!assert(std ([1 2], 1), 0.5, 5*eps); -%!assert(std(1), 0); -%!assert(std(single(1)), single(0)); -%!assert(std([]), []); -%!assert(std(ones (1,3,0,2)), ones (1,3,0,2)); +%!assert (std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2)); +%!assert (std ([1 2], 0), sqrt (2)/2, 5*eps); +%!assert (std ([1 2], 1), 0.5, 5*eps); +%!assert (std (1), 0); +%!assert (std (single (1)), single (0)); +%!assert (std ([]), []); +%!assert (std (ones (1,3,0,2)), ones (1,3,0,2)); %% Test input validation -%!error std (); -%!error std (1, 2, 3, 4); +%!error std () +%!error std (1, 2, 3, 4) %!error std (['A'; 'B']) -%!error std (1, -1); +%!error std (1, -1)
--- a/scripts/statistics/base/table.m +++ b/scripts/statistics/base/table.m @@ -71,3 +71,4 @@ %!error table (ones (2,2), ones (2,1)) %!error table (ones (2,1), ones (2,2)) %!error table (ones (2,1), ones (3,1)) +
--- a/scripts/statistics/base/var.m +++ b/scripts/statistics/base/var.m @@ -51,6 +51,9 @@ ## normalizes with @math{N}, this provides the second moment around the mean ## @end table ## +## If @math{N==1} the value of @var{opt} is ignored and normalization +## by @math{N} is used. +## ## If the optional argument @var{dim} is given, operate along this dimension. ## @seealso{cov, std, skewness, kurtosis, moment} ## @end deftypefn @@ -89,8 +92,8 @@ n = sz(dim); if (n == 1) - if (isa (x, 'single')) - retval = zeros (sz, 'single'); + if (isa (x, "single")) + retval = zeros (sz, "single"); else retval = zeros (sz); endif @@ -103,16 +106,16 @@ endfunction -%!assert(var (13), 0); -%!assert(var (single(13)), single(0)); -%!assert(var ([1,2,3]), 1); -%!assert(var ([1,2,3], 1), 2/3, eps); -%!assert(var ([1,2,3], [], 1), [0,0,0]); +%!assert (var (13), 0) +%!assert (var (single (13)), single (0)) +%!assert (var ([1,2,3]), 1) +%!assert (var ([1,2,3], 1), 2/3, eps) +%!assert (var ([1,2,3], [], 1), [0,0,0]) %% Test input validation %!error var () %!error var (1,2,3,4) %!error var (['A'; 'B']) -%!error var (1, -1); -%!error var ([],1) +%!error var (1, -1) +%!error var ([], 1)
--- a/scripts/statistics/base/zscore.m +++ b/scripts/statistics/base/zscore.m @@ -21,13 +21,13 @@ ## @deftypefnx {Function File} {[@var{z}, @var{mu}, @var{sigma}] =} zscore (@var{x}, @var{opt}) ## @deftypefnx {Function File} {[@var{z}, @var{mu}, @var{sigma}] =} zscore (@var{x}, @var{opt}, @var{dim}) ## If @var{x} is a vector, subtract its mean and divide by its standard -## deviation. If the standard deviation is zero, divide by 1 instead. +## deviation. If the standard deviation is zero, divide by 1 instead. ## The optional parameter @var{opt} determines the normalization to use ## when computing the standard deviation and is the same as the ## corresponding parameter for @code{std}. ## ## If @var{x} is a matrix, do the above along the first non-singleton -## dimension. If the third optional argument @var{dim} is given, operate +## dimension. If the third optional argument @var{dim} is given, operate ## along this dimension. ## ## The mean and standard deviation along @var{dim} are given in @var{mu} @@ -89,17 +89,17 @@ endfunction -%!assert(zscore ([1,2,3]), [-1,0,1]) -%!assert(zscore (single([1,2,3])), single([-1,0,1])) -%!assert(zscore (int8([1,2,3])), [-1,0,1]) -%!assert(zscore (ones (3,2,2,2)), zeros (3,2,2,2)) -%!assert(zscore ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1]) +%!assert (zscore ([1,2,3]), [-1,0,1]) +%!assert (zscore (single ([1,2,3])), single ([-1,0,1])) +%!assert (zscore (int8 ([1,2,3])), [-1,0,1]) +%!assert (zscore (ones (3,2,2,2)), zeros (3,2,2,2)) +%!assert (zscore ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1]) %% Test input validation %!error zscore () %!error zscore (1, 2, 3) %!error zscore (['A'; 'B']) -%!error zscore (1, ones(2,2)) +%!error zscore (1, ones (2,2)) %!error zscore (1, 1.5) %!error zscore (1, 1, 0) %!error zscore (1, 3)
--- a/scripts/statistics/distributions/betacdf.m +++ b/scripts/statistics/distributions/betacdf.m @@ -69,25 +69,25 @@ %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = [0 0 0.75 1 1]; -%!assert(betacdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(betacdf (x, 1, 2*ones(1,5)), y); -%!assert(betacdf (x, ones(1,5), 2), y); -%!assert(betacdf (x, [0 1 NaN 1 1], 2), [NaN 0 NaN 1 1]); -%!assert(betacdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]); -%!assert(betacdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]); +%!assert (betacdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (betacdf (x, 1, 2*ones (1,5)), y) +%!assert (betacdf (x, ones (1,5), 2), y) +%!assert (betacdf (x, [0 1 NaN 1 1], 2), [NaN 0 NaN 1 1]) +%!assert (betacdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]) +%!assert (betacdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(betacdf ([x, NaN], 1, 2), [y, NaN]); -%!assert(betacdf (single([x, NaN]), 1, 2), single([y, NaN])); -%!assert(betacdf ([x, NaN], single(1), 2), single([y, NaN])); -%!assert(betacdf ([x, NaN], 1, single(2)), single([y, NaN])); +%!assert (betacdf ([x, NaN], 1, 2), [y, NaN]) +%!assert (betacdf (single ([x, NaN]), 1, 2), single ([y, NaN])) +%!assert (betacdf ([x, NaN], single (1), 2), single ([y, NaN])) +%!assert (betacdf ([x, NaN], 1, single (2)), single ([y, NaN])) %% Test input validation %!error betacdf () %!error betacdf (1) %!error betacdf (1,2) %!error betacdf (1,2,3,4) -%!error betacdf (ones(3),ones(2),ones(2)) -%!error betacdf (ones(2),ones(3),ones(2)) -%!error betacdf (ones(2),ones(2),ones(3)) +%!error betacdf (ones (3), ones (2), ones (2)) +%!error betacdf (ones (2), ones (3), ones (2)) +%!error betacdf (ones (2), ones (2), ones (3))
--- a/scripts/statistics/distributions/betainv.m +++ b/scripts/statistics/distributions/betainv.m @@ -109,27 +109,27 @@ %!shared x %! x = [-1 0 0.75 1 2]; -%!assert(betainv (x, ones(1,5), 2*ones(1,5)), [NaN 0 0.5 1 NaN]); -%!assert(betainv (x, 1, 2*ones(1,5)), [NaN 0 0.5 1 NaN]); -%!assert(betainv (x, ones(1,5), 2), [NaN 0 0.5 1 NaN]); -%!assert(betainv (x, [1 0 NaN 1 1], 2), [NaN NaN NaN 1 NaN]); -%!assert(betainv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 1 NaN]); -%!assert(betainv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN 1 NaN]); +%!assert (betainv (x, ones (1,5), 2*ones (1,5)), [NaN 0 0.5 1 NaN]) +%!assert (betainv (x, 1, 2*ones (1,5)), [NaN 0 0.5 1 NaN]) +%!assert (betainv (x, ones (1,5), 2), [NaN 0 0.5 1 NaN]) +%!assert (betainv (x, [1 0 NaN 1 1], 2), [NaN NaN NaN 1 NaN]) +%!assert (betainv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 1 NaN]) +%!assert (betainv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN 1 NaN]) %% Test class of input preserved -%!assert(betainv ([x, NaN], 1, 2), [NaN 0 0.5 1 NaN NaN]); -%!assert(betainv (single([x, NaN]), 1, 2), single([NaN 0 0.5 1 NaN NaN])); -%!assert(betainv ([x, NaN], single(1), 2), single([NaN 0 0.5 1 NaN NaN])); -%!assert(betainv ([x, NaN], 1, single(2)), single([NaN 0 0.5 1 NaN NaN])); +%!assert (betainv ([x, NaN], 1, 2), [NaN 0 0.5 1 NaN NaN]) +%!assert (betainv (single ([x, NaN]), 1, 2), single ([NaN 0 0.5 1 NaN NaN])) +%!assert (betainv ([x, NaN], single (1), 2), single ([NaN 0 0.5 1 NaN NaN])) +%!assert (betainv ([x, NaN], 1, single (2)), single ([NaN 0 0.5 1 NaN NaN])) %% Test input validation %!error betainv () %!error betainv (1) %!error betainv (1,2) %!error betainv (1,2,3,4) -%!error betainv (ones(3),ones(2),ones(2)) -%!error betainv (ones(2),ones(3),ones(2)) -%!error betainv (ones(2),ones(2),ones(3)) +%!error betainv (ones (3), ones (2), ones (2)) +%!error betainv (ones (2), ones (3), ones (2)) +%!error betainv (ones (2), ones (2), ones (3)) %!error betainv (i, 2, 2) %!error betainv (2, i, 2) %!error betainv (2, 2, i)
--- a/scripts/statistics/distributions/betapdf.m +++ b/scripts/statistics/distributions/betapdf.m @@ -95,35 +95,35 @@ %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = [0 2 1 0 0]; -%!assert(betapdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(betapdf (x, 1, 2*ones(1,5)), y); -%!assert(betapdf (x, ones(1,5), 2), y); -%!assert(betapdf (x, [0 NaN 1 1 1], 2), [NaN NaN y(3:5)]); -%!assert(betapdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]); -%!assert(betapdf ([x, NaN], 1, 2), [y, NaN]); +%!assert (betapdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (betapdf (x, 1, 2*ones (1,5)), y) +%!assert (betapdf (x, ones (1,5), 2), y) +%!assert (betapdf (x, [0 NaN 1 1 1], 2), [NaN NaN y(3:5)]) +%!assert (betapdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]) +%!assert (betapdf ([x, NaN], 1, 2), [y, NaN]) %% Test class of input preserved -%!assert(betapdf (single([x, NaN]), 1, 2), single([y, NaN])); -%!assert(betapdf ([x, NaN], single(1), 2), single([y, NaN])); -%!assert(betapdf ([x, NaN], 1, single(2)), single([y, NaN])); +%!assert (betapdf (single ([x, NaN]), 1, 2), single ([y, NaN])) +%!assert (betapdf ([x, NaN], single (1), 2), single ([y, NaN])) +%!assert (betapdf ([x, NaN], 1, single (2)), single ([y, NaN])) %% Beta (1/2,1/2) == arcsine distribution %!test %! x = rand (10,1); %! y = 1./(pi * sqrt (x.*(1-x))); -%! assert(betapdf (x, 1/2, 1/2), y, 50*eps); +%! assert (betapdf (x, 1/2, 1/2), y, 50*eps); %% Test large input values to betapdf -%!assert (betapdf(0.5, 1000, 1000), 35.678, 1e-3) +%!assert (betapdf (0.5, 1000, 1000), 35.678, 1e-3) %% Test input validation %!error betapdf () %!error betapdf (1) %!error betapdf (1,2) %!error betapdf (1,2,3,4) -%!error betapdf (ones(3),ones(2),ones(2)) -%!error betapdf (ones(2),ones(3),ones(2)) -%!error betapdf (ones(2),ones(2),ones(3)) +%!error betapdf (ones (3), ones (2), ones (2)) +%!error betapdf (ones (2), ones (3), ones (2)) +%!error betapdf (ones (2), ones (2), ones (3)) %!error betapdf (i, 2, 2) %!error betapdf (2, i, 2) %!error betapdf (2, 2, i)
--- a/scripts/statistics/distributions/betarnd.m +++ b/scripts/statistics/distributions/betarnd.m @@ -103,35 +103,35 @@ endfunction -%!assert(size (betarnd (1,2)), [1, 1]); -%!assert(size (betarnd (ones(2,1), 2)), [2, 1]); -%!assert(size (betarnd (ones(2,2), 2)), [2, 2]); -%!assert(size (betarnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (betarnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (betarnd (1, 2, 3)), [3, 3]); -%!assert(size (betarnd (1, 2, [4 1])), [4, 1]); -%!assert(size (betarnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (betarnd (1,2)), [1, 1]) +%!assert (size (betarnd (ones (2,1), 2)), [2, 1]) +%!assert (size (betarnd (ones (2,2), 2)), [2, 2]) +%!assert (size (betarnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (betarnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (betarnd (1, 2, 3)), [3, 3]) +%!assert (size (betarnd (1, 2, [4 1])), [4, 1]) +%!assert (size (betarnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (betarnd (1, 2)), "double"); -%!assert(class (betarnd (single(1), 2)), "single"); -%!assert(class (betarnd (single([1 1]), 2)), "single"); -%!assert(class (betarnd (1, single(2))), "single"); -%!assert(class (betarnd (1, single([2 2]))), "single"); +%!assert (class (betarnd (1, 2)), "double") +%!assert (class (betarnd (single (1), 2)), "single") +%!assert (class (betarnd (single ([1 1]), 2)), "single") +%!assert (class (betarnd (1, single (2))), "single") +%!assert (class (betarnd (1, single ([2 2]))), "single") %% Test input validation %!error betarnd () %!error betarnd (1) -%!error betarnd (ones(3),ones(2)) -%!error betarnd (ones(2),ones(3)) +%!error betarnd (ones (3), ones (2)) +%!error betarnd (ones (2), ones (3)) %!error betarnd (i, 2) %!error betarnd (2, i) %!error betarnd (1,2, -1) -%!error betarnd (1,2, ones(2)) +%!error betarnd (1,2, ones (2)) %!error binornd (1,2, [2 -1 2]) -%!error betarnd (1,2, 1, ones(2)) +%!error betarnd (1,2, 1, ones (2)) %!error betarnd (1,2, 1, -1) -%!error betarnd (ones(2,2), 2, 3) -%!error betarnd (ones(2,2), 2, [3, 2]) -%!error betarnd (ones(2,2), 2, 2, 3) +%!error betarnd (ones (2,2), 2, 3) +%!error betarnd (ones (2,2), 2, [3, 2]) +%!error betarnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/binocdf.m +++ b/scripts/statistics/distributions/binocdf.m @@ -71,27 +71,27 @@ %!shared x,y %! x = [-1 0 1 2 3]; %! y = [0 1/4 3/4 1 1]; -%!assert(binocdf (x, 2*ones(1,5), 0.5*ones(1,5)), y); -%!assert(binocdf (x, 2, 0.5*ones(1,5)), y); -%!assert(binocdf (x, 2*ones(1,5), 0.5), y); -%!assert(binocdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 1]); -%!assert(binocdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 1]); -%!assert(binocdf ([x(1:2) NaN x(4:5)], 2, 0.5), [y(1:2) NaN y(4:5)]); +%!assert (binocdf (x, 2*ones (1,5), 0.5*ones (1,5)), y) +%!assert (binocdf (x, 2, 0.5*ones (1,5)), y) +%!assert (binocdf (x, 2*ones (1,5), 0.5), y) +%!assert (binocdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 1]) +%!assert (binocdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 1]) +%!assert (binocdf ([x(1:2) NaN x(4:5)], 2, 0.5), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(binocdf ([x, NaN], 2, 0.5), [y, NaN]); -%!assert(binocdf (single([x, NaN]), 2, 0.5), single([y, NaN])); -%!assert(binocdf ([x, NaN], single(2), 0.5), single([y, NaN])); -%!assert(binocdf ([x, NaN], 2, single(0.5)), single([y, NaN])); +%!assert (binocdf ([x, NaN], 2, 0.5), [y, NaN]) +%!assert (binocdf (single ([x, NaN]), 2, 0.5), single ([y, NaN])) +%!assert (binocdf ([x, NaN], single (2), 0.5), single ([y, NaN])) +%!assert (binocdf ([x, NaN], 2, single (0.5)), single ([y, NaN])) %% Test input validation %!error binocdf () %!error binocdf (1) %!error binocdf (1,2) %!error binocdf (1,2,3,4) -%!error binocdf (ones(3),ones(2),ones(2)) -%!error binocdf (ones(2),ones(3),ones(2)) -%!error binocdf (ones(2),ones(2),ones(3)) +%!error binocdf (ones (3), ones (2), ones (2)) +%!error binocdf (ones (2), ones (3), ones (2)) +%!error binocdf (ones (2), ones (2), ones (3)) %!error binocdf (i, 2, 2) %!error binocdf (2, i, 2) %!error binocdf (2, 2, i)
--- a/scripts/statistics/distributions/binoinv.m +++ b/scripts/statistics/distributions/binoinv.m @@ -88,27 +88,27 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(binoinv (x, 2*ones(1,5), 0.5*ones(1,5)), [NaN 0 1 2 NaN]); -%!assert(binoinv (x, 2, 0.5*ones(1,5)), [NaN 0 1 2 NaN]); -%!assert(binoinv (x, 2*ones(1,5), 0.5), [NaN 0 1 2 NaN]); -%!assert(binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN]); -%!assert(binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN]); -%!assert(binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN]); +%!assert (binoinv (x, 2*ones (1,5), 0.5*ones (1,5)), [NaN 0 1 2 NaN]) +%!assert (binoinv (x, 2, 0.5*ones (1,5)), [NaN 0 1 2 NaN]) +%!assert (binoinv (x, 2*ones (1,5), 0.5), [NaN 0 1 2 NaN]) +%!assert (binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN]) +%!assert (binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN]) +%!assert (binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN]) %% Test class of input preserved -%!assert(binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN]); -%!assert(binoinv (single([x, NaN]), 2, 0.5), single([NaN 0 1 2 NaN NaN])); -%!assert(binoinv ([x, NaN], single(2), 0.5), single([NaN 0 1 2 NaN NaN])); -%!assert(binoinv ([x, NaN], 2, single(0.5)), single([NaN 0 1 2 NaN NaN])); +%!assert (binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN]) +%!assert (binoinv (single ([x, NaN]), 2, 0.5), single ([NaN 0 1 2 NaN NaN])) +%!assert (binoinv ([x, NaN], single (2), 0.5), single ([NaN 0 1 2 NaN NaN])) +%!assert (binoinv ([x, NaN], 2, single (0.5)), single ([NaN 0 1 2 NaN NaN])) %% Test input validation %!error binoinv () %!error binoinv (1) %!error binoinv (1,2) %!error binoinv (1,2,3,4) -%!error binoinv (ones(3),ones(2),ones(2)) -%!error binoinv (ones(2),ones(3),ones(2)) -%!error binoinv (ones(2),ones(2),ones(3)) +%!error binoinv (ones (3), ones (2), ones (2)) +%!error binoinv (ones (2), ones (3), ones (2)) +%!error binoinv (ones (2), ones (2), ones (3)) %!error binoinv (i, 2, 2) %!error binoinv (2, i, 2) %!error binoinv (2, 2, i)
--- a/scripts/statistics/distributions/binopdf.m +++ b/scripts/statistics/distributions/binopdf.m @@ -75,26 +75,26 @@ %! endif %! x = [-1 0 1 2 3]; %! y = [0 1/4 1/2 1/4 0]; -%!assert(binopdf (x, 2*ones(1,5), 0.5*ones(1,5)), y, tol); -%!assert(binopdf (x, 2, 0.5*ones(1,5)), y, tol); -%!assert(binopdf (x, 2*ones(1,5), 0.5), y, tol); -%!assert(binopdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 0]); -%!assert(binopdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 0]); -%!assert(binopdf ([x, NaN], 2, 0.5), [y, NaN], tol); +%!assert (binopdf (x, 2*ones (1,5), 0.5*ones (1,5)), y, tol) +%!assert (binopdf (x, 2, 0.5*ones (1,5)), y, tol) +%!assert (binopdf (x, 2*ones (1,5), 0.5), y, tol) +%!assert (binopdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 0]) +%!assert (binopdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 0]) +%!assert (binopdf ([x, NaN], 2, 0.5), [y, NaN], tol) %% Test class of input preserved -%!assert(binopdf (single([x, NaN]), 2, 0.5), single([y, NaN])); -%!assert(binopdf ([x, NaN], single(2), 0.5), single([y, NaN])); -%!assert(binopdf ([x, NaN], 2, single(0.5)), single([y, NaN])); +%!assert (binopdf (single ([x, NaN]), 2, 0.5), single ([y, NaN])) +%!assert (binopdf ([x, NaN], single (2), 0.5), single ([y, NaN])) +%!assert (binopdf ([x, NaN], 2, single (0.5)), single ([y, NaN])) %% Test input validation %!error binopdf () %!error binopdf (1) %!error binopdf (1,2) %!error binopdf (1,2,3,4) -%!error binopdf (ones(3),ones(2),ones(2)) -%!error binopdf (ones(2),ones(3),ones(2)) -%!error binopdf (ones(2),ones(2),ones(3)) +%!error binopdf (ones (3), ones (2), ones (2)) +%!error binopdf (ones (2), ones (3), ones (2)) +%!error binopdf (ones (2), ones (2), ones (3)) %!error binopdf (i, 2, 2) %!error binopdf (2, i, 2) %!error binopdf (2, 2, i)
--- a/scripts/statistics/distributions/binornd.m +++ b/scripts/statistics/distributions/binornd.m @@ -120,35 +120,35 @@ %!assert (binornd (0, 0, 1), 0) %!assert (binornd ([0, 0], [0, 0], 1, 2), [0, 0]) -%!assert(size (binornd (2, 1/2)), [1, 1]); -%!assert(size (binornd (2*ones(2,1), 1/2)), [2, 1]); -%!assert(size (binornd (2*ones(2,2), 1/2)), [2, 2]); -%!assert(size (binornd (2, 1/2*ones(2,1))), [2, 1]); -%!assert(size (binornd (2, 1/2*ones(2,2))), [2, 2]); -%!assert(size (binornd (2, 1/2, 3)), [3, 3]); -%!assert(size (binornd (2, 1/2, [4 1])), [4, 1]); -%!assert(size (binornd (2, 1/2, 4, 1)), [4, 1]); +%!assert (size (binornd (2, 1/2)), [1, 1]) +%!assert (size (binornd (2*ones (2,1), 1/2)), [2, 1]) +%!assert (size (binornd (2*ones (2,2), 1/2)), [2, 2]) +%!assert (size (binornd (2, 1/2*ones (2,1))), [2, 1]) +%!assert (size (binornd (2, 1/2*ones (2,2))), [2, 2]) +%!assert (size (binornd (2, 1/2, 3)), [3, 3]) +%!assert (size (binornd (2, 1/2, [4 1])), [4, 1]) +%!assert (size (binornd (2, 1/2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (binornd (2, 0.5)), "double"); -%!assert(class (binornd (single(2), 0.5)), "single"); -%!assert(class (binornd (single([2 2]), 0.5)), "single"); -%!assert(class (binornd (2, single(0.5))), "single"); -%!assert(class (binornd (2, single([0.5 0.5]))), "single"); +%!assert (class (binornd (2, 0.5)), "double") +%!assert (class (binornd (single (2), 0.5)), "single") +%!assert (class (binornd (single ([2 2]), 0.5)), "single") +%!assert (class (binornd (2, single (0.5))), "single") +%!assert (class (binornd (2, single ([0.5 0.5]))), "single") %% Test input validation %!error binornd () %!error binornd (1) -%!error binornd (ones(3),ones(2)) -%!error binornd (ones(2),ones(3)) +%!error binornd (ones (3), ones (2)) +%!error binornd (ones (2), ones (3)) %!error binornd (i, 2) %!error binornd (2, i) %!error binornd (1,2, -1) -%!error binornd (1,2, ones(2)) +%!error binornd (1,2, ones (2)) %!error binornd (1,2, [2 -1 2]) -%!error binornd (1,2, 1, ones(2)) +%!error binornd (1,2, 1, ones (2)) %!error binornd (1,2, 1, -1) -%!error binornd (ones(2,2), 2, 3) -%!error binornd (ones(2,2), 2, [3, 2]) -%!error binornd (ones(2,2), 2, 2, 3) +%!error binornd (ones (2,2), 2, 3) +%!error binornd (ones (2,2), 2, [3, 2]) +%!error binornd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/cauchy_cdf.m +++ b/scripts/statistics/distributions/cauchy_cdf.m @@ -65,26 +65,26 @@ %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = 1/pi * atan ((x-1) / 2) + 1/2; -%!assert(cauchy_cdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(cauchy_cdf (x, 1, 2*ones(1,5)), y); -%!assert(cauchy_cdf (x, ones(1,5), 2), y); -%!assert(cauchy_cdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]); -%!assert(cauchy_cdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]); -%!assert(cauchy_cdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]); +%!assert (cauchy_cdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (cauchy_cdf (x, 1, 2*ones (1,5)), y) +%!assert (cauchy_cdf (x, ones (1,5), 2), y) +%!assert (cauchy_cdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]) +%!assert (cauchy_cdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]) +%!assert (cauchy_cdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(cauchy_cdf ([x, NaN], 1, 2), [y, NaN]); -%!assert(cauchy_cdf (single([x, NaN]), 1, 2), single([y, NaN]), eps("single")); -%!assert(cauchy_cdf ([x, NaN], single(1), 2), single([y, NaN]), eps("single")); -%!assert(cauchy_cdf ([x, NaN], 1, single(2)), single([y, NaN]), eps("single")); +%!assert (cauchy_cdf ([x, NaN], 1, 2), [y, NaN]) +%!assert (cauchy_cdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single")) +%!assert (cauchy_cdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single")) +%!assert (cauchy_cdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single")) %% Test input validation %!error cauchy_cdf () %!error cauchy_cdf (1,2) %!error cauchy_cdf (1,2,3,4) -%!error cauchy_cdf (ones(3),ones(2),ones(2)) -%!error cauchy_cdf (ones(2),ones(3),ones(2)) -%!error cauchy_cdf (ones(2),ones(2),ones(3)) +%!error cauchy_cdf (ones (3), ones (2), ones (2)) +%!error cauchy_cdf (ones (2), ones (3), ones (2)) +%!error cauchy_cdf (ones (2), ones (2), ones (3)) %!error cauchy_cdf (i, 2, 2) %!error cauchy_cdf (2, i, 2) %!error cauchy_cdf (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_inv.m +++ b/scripts/statistics/distributions/cauchy_inv.m @@ -72,26 +72,26 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(cauchy_inv (x, ones(1,5), 2*ones(1,5)), [NaN -Inf 1 Inf NaN], eps); -%!assert(cauchy_inv (x, 1, 2*ones(1,5)), [NaN -Inf 1 Inf NaN], eps); -%!assert(cauchy_inv (x, ones(1,5), 2), [NaN -Inf 1 Inf NaN], eps); -%!assert(cauchy_inv (x, [1 -Inf NaN Inf 1], 2), [NaN NaN NaN NaN NaN]); -%!assert(cauchy_inv (x, 1, 2*[1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(cauchy_inv ([x(1:2) NaN x(4:5)], 1, 2), [NaN -Inf NaN Inf NaN]); +%!assert (cauchy_inv (x, ones (1,5), 2*ones (1,5)), [NaN -Inf 1 Inf NaN], eps) +%!assert (cauchy_inv (x, 1, 2*ones (1,5)), [NaN -Inf 1 Inf NaN], eps) +%!assert (cauchy_inv (x, ones (1,5), 2), [NaN -Inf 1 Inf NaN], eps) +%!assert (cauchy_inv (x, [1 -Inf NaN Inf 1], 2), [NaN NaN NaN NaN NaN]) +%!assert (cauchy_inv (x, 1, 2*[1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (cauchy_inv ([x(1:2) NaN x(4:5)], 1, 2), [NaN -Inf NaN Inf NaN]) %% Test class of input preserved -%!assert(cauchy_inv ([x, NaN], 1, 2), [NaN -Inf 1 Inf NaN NaN], eps); -%!assert(cauchy_inv (single([x, NaN]), 1, 2), single([NaN -Inf 1 Inf NaN NaN]), eps("single")); -%!assert(cauchy_inv ([x, NaN], single(1), 2), single([NaN -Inf 1 Inf NaN NaN]), eps("single")); -%!assert(cauchy_inv ([x, NaN], 1, single(2)), single([NaN -Inf 1 Inf NaN NaN]), eps("single")); +%!assert (cauchy_inv ([x, NaN], 1, 2), [NaN -Inf 1 Inf NaN NaN], eps) +%!assert (cauchy_inv (single ([x, NaN]), 1, 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) +%!assert (cauchy_inv ([x, NaN], single (1), 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) +%!assert (cauchy_inv ([x, NaN], 1, single (2)), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) %% Test input validation %!error cauchy_inv () %!error cauchy_inv (1,2) %!error cauchy_inv (1,2,3,4) -%!error cauchy_inv (ones(3),ones(2),ones(2)) -%!error cauchy_inv (ones(2),ones(3),ones(2)) -%!error cauchy_inv (ones(2),ones(2),ones(3)) +%!error cauchy_inv (ones (3), ones (2), ones (2)) +%!error cauchy_inv (ones (2), ones (3), ones (2)) +%!error cauchy_inv (ones (2), ones (2), ones (3)) %!error cauchy_inv (i, 2, 2) %!error cauchy_inv (2, i, 2) %!error cauchy_inv (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_pdf.m +++ b/scripts/statistics/distributions/cauchy_pdf.m @@ -67,30 +67,30 @@ %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = 1/pi * ( 2 ./ ((x-1).^2 + 2^2) ); -%!assert(cauchy_pdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(cauchy_pdf (x, 1, 2*ones(1,5)), y); -%!assert(cauchy_pdf (x, ones(1,5), 2), y); -%!assert(cauchy_pdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]); -%!assert(cauchy_pdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]); -%!assert(cauchy_pdf ([x, NaN], 1, 2), [y, NaN]); +%!assert (cauchy_pdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (cauchy_pdf (x, 1, 2*ones (1,5)), y) +%!assert (cauchy_pdf (x, ones (1,5), 2), y) +%!assert (cauchy_pdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]) +%!assert (cauchy_pdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]) +%!assert (cauchy_pdf ([x, NaN], 1, 2), [y, NaN]) %% Test class of input preserved -%!assert(cauchy_pdf (single([x, NaN]), 1, 2), single([y, NaN]), eps("single")); -%!assert(cauchy_pdf ([x, NaN], single(1), 2), single([y, NaN]), eps("single")); -%!assert(cauchy_pdf ([x, NaN], 1, single(2)), single([y, NaN]), eps("single")); +%!assert (cauchy_pdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single")) +%!assert (cauchy_pdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single")) +%!assert (cauchy_pdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single")) %% Cauchy (0,1) == Student's T distribution with 1 DOF %!test %! x = rand (10, 1); -%! assert(cauchy_pdf (x, 0, 1), tpdf (x, 1), eps); +%! assert (cauchy_pdf (x, 0, 1), tpdf (x, 1), eps); %% Test input validation %!error cauchy_pdf () %!error cauchy_pdf (1,2) %!error cauchy_pdf (1,2,3,4) -%!error cauchy_pdf (ones(3),ones(2),ones(2)) -%!error cauchy_pdf (ones(2),ones(3),ones(2)) -%!error cauchy_pdf (ones(2),ones(2),ones(3)) +%!error cauchy_pdf (ones (3), ones (2), ones (2)) +%!error cauchy_pdf (ones (2), ones (3), ones (2)) +%!error cauchy_pdf (ones (2), ones (2), ones (3)) %!error cauchy_pdf (i, 2, 2) %!error cauchy_pdf (2, i, 2) %!error cauchy_pdf (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_rnd.m +++ b/scripts/statistics/distributions/cauchy_rnd.m @@ -98,35 +98,35 @@ endfunction -%!assert(size (cauchy_rnd (1,2)), [1, 1]); -%!assert(size (cauchy_rnd (ones(2,1), 2)), [2, 1]); -%!assert(size (cauchy_rnd (ones(2,2), 2)), [2, 2]); -%!assert(size (cauchy_rnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (cauchy_rnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (cauchy_rnd (1, 2, 3)), [3, 3]); -%!assert(size (cauchy_rnd (1, 2, [4 1])), [4, 1]); -%!assert(size (cauchy_rnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (cauchy_rnd (1,2)), [1, 1]) +%!assert (size (cauchy_rnd (ones (2,1), 2)), [2, 1]) +%!assert (size (cauchy_rnd (ones (2,2), 2)), [2, 2]) +%!assert (size (cauchy_rnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (cauchy_rnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (cauchy_rnd (1, 2, 3)), [3, 3]) +%!assert (size (cauchy_rnd (1, 2, [4 1])), [4, 1]) +%!assert (size (cauchy_rnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (cauchy_rnd (1, 2)), "double"); -%!assert(class (cauchy_rnd (single(1), 2)), "single"); -%!assert(class (cauchy_rnd (single([1 1]), 2)), "single"); -%!assert(class (cauchy_rnd (1, single(2))), "single"); -%!assert(class (cauchy_rnd (1, single([2 2]))), "single"); +%!assert (class (cauchy_rnd (1, 2)), "double") +%!assert (class (cauchy_rnd (single (1), 2)), "single") +%!assert (class (cauchy_rnd (single ([1 1]), 2)), "single") +%!assert (class (cauchy_rnd (1, single (2))), "single") +%!assert (class (cauchy_rnd (1, single ([2 2]))), "single") %% Test input validation %!error cauchy_rnd () %!error cauchy_rnd (1) -%!error cauchy_rnd (ones(3),ones(2)) -%!error cauchy_rnd (ones(2),ones(3)) +%!error cauchy_rnd (ones (3), ones (2)) +%!error cauchy_rnd (ones (2), ones (3)) %!error cauchy_rnd (i, 2) %!error cauchy_rnd (2, i) %!error cauchy_rnd (1,2, -1) -%!error cauchy_rnd (1,2, ones(2)) +%!error cauchy_rnd (1,2, ones (2)) %!error cauchy_rnd (1,2, [2 -1 2]) -%!error cauchy_rnd (1,2, 1, ones(2)) +%!error cauchy_rnd (1,2, 1, ones (2)) %!error cauchy_rnd (1,2, 1, -1) -%!error cauchy_rnd (ones(2,2), 2, 3) -%!error cauchy_rnd (ones(2,2), 2, [3, 2]) -%!error cauchy_rnd (ones(2,2), 2, 2, 3) +%!error cauchy_rnd (ones (2,2), 2, 3) +%!error cauchy_rnd (ones (2,2), 2, [3, 2]) +%!error cauchy_rnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/chi2cdf.m +++ b/scripts/statistics/distributions/chi2cdf.m @@ -52,22 +52,22 @@ %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = [0, 1 - exp(-x(2:end)/2)]; -%!assert(chi2cdf (x, 2*ones(1,5)), y, eps); -%!assert(chi2cdf (x, 2), y, eps); -%!assert(chi2cdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps); -%!assert(chi2cdf ([x(1:2) NaN x(4:5)], 2), [y(1:2) NaN y(4:5)], eps); +%!assert (chi2cdf (x, 2*ones (1,5)), y, eps) +%!assert (chi2cdf (x, 2), y, eps) +%!assert (chi2cdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps) +%!assert (chi2cdf ([x(1:2) NaN x(4:5)], 2), [y(1:2) NaN y(4:5)], eps) %% Test class of input preserved -%!assert(chi2cdf ([x, NaN], 2), [y, NaN], eps); -%!assert(chi2cdf (single([x, NaN]), 2), single([y, NaN]), eps("single")); -%!assert(chi2cdf ([x, NaN], single(2)), single([y, NaN]), eps("single")); +%!assert (chi2cdf ([x, NaN], 2), [y, NaN], eps) +%!assert (chi2cdf (single ([x, NaN]), 2), single ([y, NaN]), eps ("single")) +%!assert (chi2cdf ([x, NaN], single (2)), single ([y, NaN]), eps ("single")) %% Test input validation %!error chi2cdf () %!error chi2cdf (1) %!error chi2cdf (1,2,3) -%!error chi2cdf (ones(3),ones(2)) -%!error chi2cdf (ones(2),ones(3)) +%!error chi2cdf (ones (3), ones (2)) +%!error chi2cdf (ones (2), ones (3)) %!error chi2cdf (i, 2) %!error chi2cdf (2, i)
--- a/scripts/statistics/distributions/chi2inv.m +++ b/scripts/statistics/distributions/chi2inv.m @@ -51,22 +51,22 @@ %!shared x %! x = [-1 0 0.3934693402873666 1 2]; -%!assert(chi2inv (x, 2*ones(1,5)), [NaN 0 1 Inf NaN], 5*eps); -%!assert(chi2inv (x, 2), [NaN 0 1 Inf NaN], 5*eps); -%!assert(chi2inv (x, 2*[0 1 NaN 1 1]), [NaN 0 NaN Inf NaN], 5*eps); -%!assert(chi2inv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], 5*eps); +%!assert (chi2inv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], 5*eps) +%!assert (chi2inv (x, 2), [NaN 0 1 Inf NaN], 5*eps) +%!assert (chi2inv (x, 2*[0 1 NaN 1 1]), [NaN 0 NaN Inf NaN], 5*eps) +%!assert (chi2inv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], 5*eps) %% Test class of input preserved -%!assert(chi2inv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], 5*eps); -%!assert(chi2inv (single([x, NaN]), 2), single([NaN 0 1 Inf NaN NaN]), 5*eps("single")); -%!assert(chi2inv ([x, NaN], single(2)), single([NaN 0 1 Inf NaN NaN]), 5*eps("single")); +%!assert (chi2inv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], 5*eps) +%!assert (chi2inv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single")) +%!assert (chi2inv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single")) %% Test input validation %!error chi2inv () %!error chi2inv (1) %!error chi2inv (1,2,3) -%!error chi2inv (ones(3),ones(2)) -%!error chi2inv (ones(2),ones(3)) +%!error chi2inv (ones (3), ones (2)) +%!error chi2inv (ones (2), ones (3)) %!error chi2inv (i, 2) %!error chi2inv (2, i)
--- a/scripts/statistics/distributions/chi2pdf.m +++ b/scripts/statistics/distributions/chi2pdf.m @@ -52,21 +52,21 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = [0, 1/2 * exp(-x(2:5)/2)]; -%!assert(chi2pdf (x, 2*ones(1,5)), y); -%!assert(chi2pdf (x, 2), y); -%!assert(chi2pdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]); -%!assert(chi2pdf ([x, NaN], 2), [y, NaN]); +%!assert (chi2pdf (x, 2*ones (1,5)), y) +%!assert (chi2pdf (x, 2), y) +%!assert (chi2pdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) +%!assert (chi2pdf ([x, NaN], 2), [y, NaN]) %% Test class of input preserved -%!assert(chi2pdf (single([x, NaN]), 2), single([y, NaN])); -%!assert(chi2pdf ([x, NaN], single(2)), single([y, NaN])); +%!assert (chi2pdf (single ([x, NaN]), 2), single ([y, NaN])) +%!assert (chi2pdf ([x, NaN], single (2)), single ([y, NaN])) %% Test input validation %!error chi2pdf () %!error chi2pdf (1) %!error chi2pdf (1,2,3) -%!error chi2pdf (ones(3),ones(2)) -%!error chi2pdf (ones(2),ones(3)) +%!error chi2pdf (ones (3), ones (2)) +%!error chi2pdf (ones (2), ones (3)) %!error chi2pdf (i, 2) %!error chi2pdf (2, i)
--- a/scripts/statistics/distributions/chi2rnd.m +++ b/scripts/statistics/distributions/chi2rnd.m @@ -94,27 +94,27 @@ endfunction -%!assert(size (chi2rnd (2)), [1, 1]); -%!assert(size (chi2rnd (ones(2,1))), [2, 1]); -%!assert(size (chi2rnd (ones(2,2))), [2, 2]); -%!assert(size (chi2rnd (1, 3)), [3, 3]); -%!assert(size (chi2rnd (1, [4 1])), [4, 1]); -%!assert(size (chi2rnd (1, 4, 1)), [4, 1]); +%!assert (size (chi2rnd (2)), [1, 1]) +%!assert (size (chi2rnd (ones (2,1))), [2, 1]) +%!assert (size (chi2rnd (ones (2,2))), [2, 2]) +%!assert (size (chi2rnd (1, 3)), [3, 3]) +%!assert (size (chi2rnd (1, [4 1])), [4, 1]) +%!assert (size (chi2rnd (1, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (chi2rnd (2)), "double"); -%!assert(class (chi2rnd (single(2))), "single"); -%!assert(class (chi2rnd (single([2 2]))), "single"); +%!assert (class (chi2rnd (2)), "double") +%!assert (class (chi2rnd (single (2))), "single") +%!assert (class (chi2rnd (single ([2 2]))), "single") %% Test input validation %!error chi2rnd () -%!error chi2rnd (ones(3),ones(2)) -%!error chi2rnd (ones(2),ones(3)) +%!error chi2rnd (ones (3), ones (2)) +%!error chi2rnd (ones (2), ones (3)) %!error chi2rnd (i) %!error chi2rnd (1, -1) -%!error chi2rnd (1, ones(2)) +%!error chi2rnd (1, ones (2)) %!error chi2rnd (1, [2 -1 2]) -%!error chi2rnd (ones(2,2), 3) -%!error chi2rnd (ones(2,2), [3, 2]) -%!error chi2rnd (ones(2,2), 2, 3) +%!error chi2rnd (ones (2,2), 3) +%!error chi2rnd (ones (2,2), [3, 2]) +%!error chi2rnd (ones (2,2), 2, 3)
--- a/scripts/statistics/distributions/discrete_cdf.m +++ b/scripts/statistics/distributions/discrete_cdf.m @@ -58,24 +58,24 @@ %!shared x,v,p,y %! x = [-1 0.1 1.1 1.9 3]; %! v = 0.1:0.2:1.9; -%! p = 1/length(v) * ones(1, length(v)); +%! p = 1/length(v) * ones (1, length(v)); %! y = [0 0.1 0.6 1 1]; -%!assert(discrete_cdf ([x, NaN], v, p), [y, NaN], eps); +%!assert (discrete_cdf ([x, NaN], v, p), [y, NaN], eps) %% Test class of input preserved -%!assert(discrete_cdf (single([x, NaN]), v, p), single([y, NaN]), 2*eps("single")); -%!assert(discrete_cdf ([x, NaN], single(v), p), single([y, NaN]), 2*eps("single")); -%!assert(discrete_cdf ([x, NaN], v, single(p)), single([y, NaN]), 2*eps("single")); +%!assert (discrete_cdf (single ([x, NaN]), v, p), single ([y, NaN]), 2*eps ("single")) +%!assert (discrete_cdf ([x, NaN], single (v), p), single ([y, NaN]), 2*eps ("single")) +%!assert (discrete_cdf ([x, NaN], v, single (p)), single ([y, NaN]), 2*eps ("single")) %% Test input validation %!error discrete_cdf () %!error discrete_cdf (1) %!error discrete_cdf (1,2) %!error discrete_cdf (1,2,3,4) -%!error discrete_cdf (1, ones(2), ones(2,1)) -%!error discrete_cdf (1, [1 ; NaN], ones(2,1)) -%!error discrete_cdf (1, ones(2,1), ones(1,1)) -%!error discrete_cdf (1, ones(2,1), [1 -1]) -%!error discrete_cdf (1, ones(2,1), [1 NaN]) -%!error discrete_cdf (1, ones(2,1), [0 0]) +%!error discrete_cdf (1, ones (2), ones (2,1)) +%!error discrete_cdf (1, [1 ; NaN], ones (2,1)) +%!error discrete_cdf (1, ones (2,1), ones (1,1)) +%!error discrete_cdf (1, ones (2,1), [1 -1]) +%!error discrete_cdf (1, ones (2,1), [1 NaN]) +%!error discrete_cdf (1, ones (2,1), [0 0])
--- a/scripts/statistics/distributions/discrete_inv.m +++ b/scripts/statistics/distributions/discrete_inv.m @@ -73,23 +73,23 @@ %!shared x,v,p,y %! x = [-1 0 0.1 0.5 1 2]; %! v = 0.1:0.2:1.9; -%! p = 1/length(v) * ones(1, length(v)); +%! p = 1/length(v) * ones (1, length(v)); %! y = [NaN v(1) v(1) v(end/2) v(end) NaN]; -%!assert(discrete_inv ([x, NaN], v, p), [y, NaN], eps); +%!assert (discrete_inv ([x, NaN], v, p), [y, NaN], eps) %% Test class of input preserved -%!assert(discrete_inv (single([x, NaN]), v, p), single([y, NaN]), eps("single")); -%!assert(discrete_inv ([x, NaN], single(v), p), single([y, NaN]), eps("single")); -%!assert(discrete_inv ([x, NaN], v, single(p)), single([y, NaN]), eps("single")); +%!assert (discrete_inv (single ([x, NaN]), v, p), single ([y, NaN]), eps ("single")) +%!assert (discrete_inv ([x, NaN], single (v), p), single ([y, NaN]), eps ("single")) +%!assert (discrete_inv ([x, NaN], v, single (p)), single ([y, NaN]), eps ("single")) %% Test input validation %!error discrete_inv () %!error discrete_inv (1) %!error discrete_inv (1,2) %!error discrete_inv (1,2,3,4) -%!error discrete_inv (1, ones(2), ones(2,1)) -%!error discrete_inv (1, ones(2,1), ones(1,1)) -%!error discrete_inv (1, ones(2,1), [1 NaN]) -%!error discrete_inv (1, ones(2,1), [1 -1]) -%!error discrete_inv (1, ones(2,1), [0 0]) +%!error discrete_inv (1, ones (2), ones (2,1)) +%!error discrete_inv (1, ones (2,1), ones (1,1)) +%!error discrete_inv (1, ones (2,1), [1 NaN]) +%!error discrete_inv (1, ones (2,1), [1 -1]) +%!error discrete_inv (1, ones (2,1), [0 0])
--- a/scripts/statistics/distributions/discrete_pdf.m +++ b/scripts/statistics/distributions/discrete_pdf.m @@ -62,24 +62,24 @@ %!shared x,v,p,y %! x = [-1 0.1 1.1 1.9 3]; %! v = 0.1:0.2:1.9; -%! p = 1/length(v) * ones(1, length(v)); +%! p = 1/length (v) * ones (1, length (v)); %! y = [0 0.1 0.1 0.1 0]; -%!assert(discrete_pdf ([x, NaN], v, p), [y, NaN], 5*eps); +%!assert (discrete_pdf ([x, NaN], v, p), [y, NaN], 5*eps) %% Test class of input preserved -%!assert(discrete_pdf (single([x, NaN]), v, p), single([y, NaN]), 5*eps("single")); -%!assert(discrete_pdf ([x, NaN], single(v), p), single([y, NaN]), 5*eps("single")); -%!assert(discrete_pdf ([x, NaN], v, single(p)), single([y, NaN]), 5*eps("single")); +%!assert (discrete_pdf (single ([x, NaN]), v, p), single ([y, NaN]), 5*eps ("single")) +%!assert (discrete_pdf ([x, NaN], single (v), p), single ([y, NaN]), 5*eps ("single")) +%!assert (discrete_pdf ([x, NaN], v, single (p)), single ([y, NaN]), 5*eps ("single")) %% Test input validation %!error discrete_pdf () %!error discrete_pdf (1) %!error discrete_pdf (1,2) %!error discrete_pdf (1,2,3,4) -%!error discrete_pdf (1, ones(2), ones(2,1)) -%!error discrete_pdf (1, [1 ; NaN], ones(2,1)) -%!error discrete_pdf (1, ones(2,1), ones(1,1)) -%!error discrete_pdf (1, ones(2,1), [1 -1]) -%!error discrete_pdf (1, ones(2,1), [1 NaN]) -%!error discrete_pdf (1, ones(2,1), [0 0]) +%!error discrete_pdf (1, ones (2), ones (2,1)) +%!error discrete_pdf (1, [1 ; NaN], ones (2,1)) +%!error discrete_pdf (1, ones (2,1), ones (1,1)) +%!error discrete_pdf (1, ones (2,1), [1 -1]) +%!error discrete_pdf (1, ones (2,1), [1 NaN]) +%!error discrete_pdf (1, ones (2,1), [0 0])
--- a/scripts/statistics/distributions/discrete_rnd.m +++ b/scripts/statistics/distributions/discrete_rnd.m @@ -77,13 +77,13 @@ endfunction -%!assert(size (discrete_rnd (1:2, 1:2, 3)), [3, 3]); -%!assert(size (discrete_rnd (1:2, 1:2, [4 1])), [4, 1]); -%!assert(size (discrete_rnd (1:2, 1:2, 4, 1)), [4, 1]); +%!assert (size (discrete_rnd (1:2, 1:2, 3)), [3, 3]) +%!assert (size (discrete_rnd (1:2, 1:2, [4 1])), [4, 1]) +%!assert (size (discrete_rnd (1:2, 1:2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (discrete_rnd (1:2, 1:2)), "double"); -%!assert(class (discrete_rnd (single(1:2), 1:2)), "single"); +%!assert (class (discrete_rnd (1:2, 1:2)), "double") +%!assert (class (discrete_rnd (single (1:2), 1:2)), "single") ## FIXME: Maybe this should work, maybe it shouldn't. #%!assert(class (discrete_rnd (1:2, single(1:2))), "single"); @@ -91,14 +91,14 @@ %!error discrete_rnd () %!error discrete_rnd (1) %!error discrete_rnd (1:2,1:2, -1) -%!error discrete_rnd (1:2,1:2, ones(2)) +%!error discrete_rnd (1:2,1:2, ones (2)) %!error discrete_rnd (1:2,1:2, [2 -1 2]) -%!error discrete_rnd (1:2,1:2, 1, ones(2)) +%!error discrete_rnd (1:2,1:2, 1, ones (2)) %!error discrete_rnd (1:2,1:2, 1, -1) %% test v,p verification -%!error discrete_rnd (1, ones(2), ones(2,1)) -%!error discrete_rnd (1, ones(2,1), ones(1,1)) -%!error discrete_rnd (1, ones(2,1), [1 -1]) -%!error discrete_rnd (1, ones(2,1), [1 NaN]) -%!error discrete_rnd (1, ones(2,1), [0 0]) +%!error discrete_rnd (1, ones (2), ones (2,1)) +%!error discrete_rnd (1, ones (2,1), ones (1,1)) +%!error discrete_rnd (1, ones (2,1), [1 -1]) +%!error discrete_rnd (1, ones (2,1), [1 NaN]) +%!error discrete_rnd (1, ones (2,1), [0 0])
--- a/scripts/statistics/distributions/empirical_cdf.m +++ b/scripts/statistics/distributions/empirical_cdf.m @@ -46,17 +46,17 @@ %! x = [-1 0.1 1.1 1.9 3]; %! v = 0.1:0.2:1.9; %! y = [0 0.1 0.6 1 1]; -%!assert(empirical_cdf (x, v), y, eps); -%!assert(empirical_cdf ([x(1) NaN x(3:5)], v), [0 NaN 0.6 1 1], eps); +%!assert (empirical_cdf (x, v), y, eps) +%!assert (empirical_cdf ([x(1) NaN x(3:5)], v), [0 NaN 0.6 1 1], eps) %% Test class of input preserved -%!assert(empirical_cdf ([x, NaN], v), [y, NaN], eps); -%!assert(empirical_cdf (single([x, NaN]), v), single([y, NaN]), eps); -%!assert(empirical_cdf ([x, NaN], single(v)), single([y, NaN]), eps); +%!assert (empirical_cdf ([x, NaN], v), [y, NaN], eps) +%!assert (empirical_cdf (single ([x, NaN]), v), single ([y, NaN]), eps) +%!assert (empirical_cdf ([x, NaN], single (v)), single ([y, NaN]), eps) %% Test input validation %!error empirical_cdf () %!error empirical_cdf (1) %!error empirical_cdf (1,2,3) -%!error empirical_cdf (1, ones(2)) +%!error empirical_cdf (1, ones (2))
--- a/scripts/statistics/distributions/empirical_inv.m +++ b/scripts/statistics/distributions/empirical_inv.m @@ -46,16 +46,16 @@ %! x = [-1 0 0.1 0.5 1 2]; %! v = 0.1:0.2:1.9; %! y = [NaN v(1) v(1) v(end/2) v(end) NaN]; -%!assert(empirical_inv (x, v), y, eps); +%!assert (empirical_inv (x, v), y, eps) %% Test class of input preserved -%!assert(empirical_inv ([x, NaN], v), [y, NaN], eps); -%!assert(empirical_inv (single([x, NaN]), v), single([y, NaN]), eps); -%!assert(empirical_inv ([x, NaN], single(v)), single([y, NaN]), eps); +%!assert (empirical_inv ([x, NaN], v), [y, NaN], eps) +%!assert (empirical_inv (single ([x, NaN]), v), single ([y, NaN]), eps) +%!assert (empirical_inv ([x, NaN], single (v)), single ([y, NaN]), eps) %% Test input validation %!error empirical_inv () %!error empirical_inv (1) %!error empirical_inv (1,2,3) -%!error empirical_inv (1, ones(2)) +%!error empirical_inv (1, ones (2))
--- a/scripts/statistics/distributions/empirical_pdf.m +++ b/scripts/statistics/distributions/empirical_pdf.m @@ -46,15 +46,15 @@ %! x = [-1 0.1 1.1 1.9 3]; %! v = 0.1:0.2:1.9; %! y = [0 0.1 0.1 0.1 0]; -%!assert(empirical_pdf (x, v), y); +%!assert (empirical_pdf (x, v), y) %% Test class of input preserved -%!assert(empirical_pdf (single(x), v), single (y)); -%!assert(empirical_pdf (x, single(v)), single (y)); +%!assert (empirical_pdf (single (x), v), single (y)) +%!assert (empirical_pdf (x, single (v)), single (y)) %% Test input validation %!error empirical_pdf () %!error empirical_pdf (1) %!error empirical_pdf (1,2,3) -%!error empirical_inv (1, ones(2)) +%!error empirical_inv (1, ones (2))
--- a/scripts/statistics/distributions/empirical_rnd.m +++ b/scripts/statistics/distributions/empirical_rnd.m @@ -53,17 +53,17 @@ endfunction -%!assert(size (empirical_rnd (ones (3, 1))), [3, 1]); -%!assert(size (empirical_rnd (1:2, [4 1])), [4, 1]); -%!assert(size (empirical_rnd (1:2, 4, 1)), [4, 1]); +%!assert (size (empirical_rnd (ones (3, 1))), [3, 1]) +%!assert (size (empirical_rnd (1:2, [4 1])), [4, 1]) +%!assert (size (empirical_rnd (1:2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (empirical_rnd (1:2, 1)), "double"); -%!assert(class (empirical_rnd (single(1:2), 1)), "single"); +%!assert (class (empirical_rnd (1:2, 1)), "double") +%!assert (class (empirical_rnd (single (1:2), 1)), "single") %% Test input validation %!error empirical_rnd () -%!error empirical_rnd (ones(2), 1) +%!error empirical_rnd (ones (2), 1) %% test data verification -%!error empirical_rnd (ones(2), 1, 1) +%!error empirical_rnd (ones (2), 1, 1)
--- a/scripts/statistics/distributions/expcdf.m +++ b/scripts/statistics/distributions/expcdf.m @@ -71,21 +71,21 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = [0, 1 - exp(-x(2:end)/2)]; -%!assert(expcdf (x, 2*ones(1,5)), y); -%!assert(expcdf (x, 2), y); -%!assert(expcdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]); +%!assert (expcdf (x, 2*ones (1,5)), y) +%!assert (expcdf (x, 2), y) +%!assert (expcdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) %% Test class of input preserved -%!assert(expcdf ([x, NaN], 2), [y, NaN]); -%!assert(expcdf (single([x, NaN]), 2), single([y, NaN])); -%!assert(expcdf ([x, NaN], single(2)), single([y, NaN])); +%!assert (expcdf ([x, NaN], 2), [y, NaN]) +%!assert (expcdf (single ([x, NaN]), 2), single ([y, NaN])) +%!assert (expcdf ([x, NaN], single (2)), single ([y, NaN])) %% Test input validation %!error expcdf () %!error expcdf (1) %!error expcdf (1,2,3) -%!error expcdf (ones(3),ones(2)) -%!error expcdf (ones(2),ones(3)) +%!error expcdf (ones (3), ones (2)) +%!error expcdf (ones (2), ones (3)) %!error expcdf (i, 2) %!error expcdf (2, i)
--- a/scripts/statistics/distributions/expinv.m +++ b/scripts/statistics/distributions/expinv.m @@ -74,22 +74,22 @@ %!shared x %! x = [-1 0 0.3934693402873666 1 2]; -%!assert(expinv (x, 2*ones(1,5)), [NaN 0 1 Inf NaN], eps); -%!assert(expinv (x, 2), [NaN 0 1 Inf NaN], eps); -%!assert(expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps); -%!assert(expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps); +%!assert (expinv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], eps) +%!assert (expinv (x, 2), [NaN 0 1 Inf NaN], eps) +%!assert (expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps) +%!assert (expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps) %% Test class of input preserved -%!assert(expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps); -%!assert(expinv (single([x, NaN]), 2), single([NaN 0 1 Inf NaN NaN]), eps); -%!assert(expinv ([x, NaN], single(2)), single([NaN 0 1 Inf NaN NaN]), eps); +%!assert (expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps) +%!assert (expinv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), eps) +%!assert (expinv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), eps) %% Test input validation %!error expinv () %!error expinv (1) %!error expinv (1,2,3) -%!error expinv (ones(3),ones(2)) -%!error expinv (ones(2),ones(3)) +%!error expinv (ones (3), ones (2)) +%!error expinv (ones (2), ones (3)) %!error expinv (i, 2) %!error expinv (2, i)
--- a/scripts/statistics/distributions/exppdf.m +++ b/scripts/statistics/distributions/exppdf.m @@ -65,20 +65,20 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = gampdf (x, 1, 2); -%!assert(exppdf (x, 2*ones(1,5)), y); -%!assert(exppdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]); -%!assert(exppdf ([x, NaN], 2), [y, NaN]); +%!assert (exppdf (x, 2*ones (1,5)), y) +%!assert (exppdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) +%!assert (exppdf ([x, NaN], 2), [y, NaN]) %% Test class of input preserved -%!assert(exppdf (single([x, NaN]), 2), single([y, NaN])); -%!assert(exppdf ([x, NaN], single(2)), single([y, NaN])); +%!assert (exppdf (single ([x, NaN]), 2), single ([y, NaN])) +%!assert (exppdf ([x, NaN], single (2)), single ([y, NaN])) %% Test input validation %!error exppdf () %!error exppdf (1) %!error exppdf (1,2,3) -%!error exppdf (ones(3),ones(2)) -%!error exppdf (ones(2),ones(3)) +%!error exppdf (ones (3), ones (2)) +%!error exppdf (ones (2), ones (3)) %!error exppdf (i, 2) %!error exppdf (2, i)
--- a/scripts/statistics/distributions/exprnd.m +++ b/scripts/statistics/distributions/exprnd.m @@ -91,27 +91,27 @@ endfunction -%!assert(size (exprnd (2)), [1, 1]); -%!assert(size (exprnd (ones(2,1))), [2, 1]); -%!assert(size (exprnd (ones(2,2))), [2, 2]); -%!assert(size (exprnd (1, 3)), [3, 3]); -%!assert(size (exprnd (1, [4 1])), [4, 1]); -%!assert(size (exprnd (1, 4, 1)), [4, 1]); +%!assert (size (exprnd (2)), [1, 1]) +%!assert (size (exprnd (ones (2,1))), [2, 1]) +%!assert (size (exprnd (ones (2,2))), [2, 2]) +%!assert (size (exprnd (1, 3)), [3, 3]) +%!assert (size (exprnd (1, [4 1])), [4, 1]) +%!assert (size (exprnd (1, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (exprnd (1)), "double"); -%!assert(class (exprnd (single(1))), "single"); -%!assert(class (exprnd (single([1 1]))), "single"); +%!assert (class (exprnd (1)), "double") +%!assert (class (exprnd (single (1))), "single") +%!assert (class (exprnd (single ([1 1]))), "single") %% Test input validation %!error exprnd () %!error exprnd (1, -1) -%!error exprnd (1, ones(2)) +%!error exprnd (1, ones (2)) %!error exprnd (i) %!error exprnd (1, [2 -1 2]) %!error exprnd (1, 2, -1) -%!error exprnd (1, 2, ones(2)) -%!error exprnd (ones(2,2), 3) -%!error exprnd (ones(2,2), [3, 2]) -%!error exprnd (ones(2,2), 2, 3) +%!error exprnd (1, 2, ones (2)) +%!error exprnd (ones (2,2), 3) +%!error exprnd (ones (2,2), [3, 2]) +%!error exprnd (ones (2,2), 2, 3)
--- a/scripts/statistics/distributions/fcdf.m +++ b/scripts/statistics/distributions/fcdf.m @@ -69,27 +69,27 @@ %!shared x,y %! x = [-1 0 0.5 1 2 Inf]; %! y = [0 0 1/3 1/2 2/3 1]; -%!assert(fcdf (x, 2*ones(1,6), 2*ones(1,6)), y, eps); -%!assert(fcdf (x, 2, 2*ones(1,6)), y, eps); -%!assert(fcdf (x, 2*ones(1,6), 2), y, eps); -%!assert(fcdf (x, [0 NaN Inf 2 2 2], 2), [NaN NaN NaN y(4:6)], eps); -%!assert(fcdf (x, 2, [0 NaN Inf 2 2 2]), [NaN NaN NaN y(4:6)], eps); -%!assert(fcdf ([x(1:2) NaN x(4:6)], 2, 2), [y(1:2) NaN y(4:6)], eps); +%!assert (fcdf (x, 2*ones (1,6), 2*ones (1,6)), y, eps) +%!assert (fcdf (x, 2, 2*ones (1,6)), y, eps) +%!assert (fcdf (x, 2*ones (1,6), 2), y, eps) +%!assert (fcdf (x, [0 NaN Inf 2 2 2], 2), [NaN NaN NaN y(4:6)], eps) +%!assert (fcdf (x, 2, [0 NaN Inf 2 2 2]), [NaN NaN NaN y(4:6)], eps) +%!assert (fcdf ([x(1:2) NaN x(4:6)], 2, 2), [y(1:2) NaN y(4:6)], eps) %% Test class of input preserved -%!assert(fcdf ([x, NaN], 2, 2), [y, NaN], eps); -%!assert(fcdf (single([x, NaN]), 2, 2), single([y, NaN]), eps("single")); -%!assert(fcdf ([x, NaN], single(2), 2), single([y, NaN]), eps("single")); -%!assert(fcdf ([x, NaN], 2, single(2)), single([y, NaN]), eps("single")); +%!assert (fcdf ([x, NaN], 2, 2), [y, NaN], eps) +%!assert (fcdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single")) +%!assert (fcdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single")) +%!assert (fcdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single")) %% Test input validation %!error fcdf () %!error fcdf (1) %!error fcdf (1,2) %!error fcdf (1,2,3,4) -%!error fcdf (ones(3),ones(2),ones(2)) -%!error fcdf (ones(2),ones(3),ones(2)) -%!error fcdf (ones(2),ones(2),ones(3)) +%!error fcdf (ones (3), ones (2), ones (2)) +%!error fcdf (ones (2), ones (3), ones (2)) +%!error fcdf (ones (2), ones (2), ones (3)) %!error fcdf (i, 2, 2) %!error fcdf (2, i, 2) %!error fcdf (2, 2, i)
--- a/scripts/statistics/distributions/finv.m +++ b/scripts/statistics/distributions/finv.m @@ -66,27 +66,27 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(finv (x, 2*ones(1,5), 2*ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(finv (x, 2, 2*ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(finv (x, 2*ones(1,5), 2), [NaN 0 1 Inf NaN]); -%!assert(finv (x, [2 -Inf NaN Inf 2], 2), [NaN NaN NaN NaN NaN]); -%!assert(finv (x, 2, [2 -Inf NaN Inf 2]), [NaN NaN NaN NaN NaN]); -%!assert(finv ([x(1:2) NaN x(4:5)], 2, 2), [NaN 0 NaN Inf NaN]); +%!assert (finv (x, 2*ones (1,5), 2*ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (finv (x, 2, 2*ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (finv (x, 2*ones (1,5), 2), [NaN 0 1 Inf NaN]) +%!assert (finv (x, [2 -Inf NaN Inf 2], 2), [NaN NaN NaN NaN NaN]) +%!assert (finv (x, 2, [2 -Inf NaN Inf 2]), [NaN NaN NaN NaN NaN]) +%!assert (finv ([x(1:2) NaN x(4:5)], 2, 2), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(finv ([x, NaN], 2, 2), [NaN 0 1 Inf NaN NaN]); -%!assert(finv (single([x, NaN]), 2, 2), single([NaN 0 1 Inf NaN NaN])); -%!assert(finv ([x, NaN], single(2), 2), single([NaN 0 1 Inf NaN NaN])); -%!assert(finv ([x, NaN], 2, single(2)), single([NaN 0 1 Inf NaN NaN])); +%!assert (finv ([x, NaN], 2, 2), [NaN 0 1 Inf NaN NaN]) +%!assert (finv (single ([x, NaN]), 2, 2), single ([NaN 0 1 Inf NaN NaN])) +%!assert (finv ([x, NaN], single (2), 2), single ([NaN 0 1 Inf NaN NaN])) +%!assert (finv ([x, NaN], 2, single (2)), single ([NaN 0 1 Inf NaN NaN])) %% Test input validation %!error finv () %!error finv (1) %!error finv (1,2) %!error finv (1,2,3,4) -%!error finv (ones(3),ones(2),ones(2)) -%!error finv (ones(2),ones(3),ones(2)) -%!error finv (ones(2),ones(2),ones(3)) +%!error finv (ones (3), ones (2), ones (2)) +%!error finv (ones (2), ones (3), ones (2)) +%!error finv (ones (2), ones (2), ones (3)) %!error finv (i, 2, 2) %!error finv (2, i, 2) %!error finv (2, 2, i)
--- a/scripts/statistics/distributions/fpdf.m +++ b/scripts/statistics/distributions/fpdf.m @@ -74,31 +74,31 @@ %! x = rand (10,1); %! x = x(x > 0.1 & x < 0.9); %! y = tpdf (sqrt (x), 2) ./ sqrt (x); -%! assert(fpdf (x, 1, 2), y, 5*eps); +%! assert (fpdf (x, 1, 2), y, 5*eps); %!shared x,y %! x = [-1 0 0.5 1 2]; %! y = [0 0 4/9 1/4 1/9]; -%!assert(fpdf (x, 2*ones(1,5), 2*ones(1,5)), y, eps); -%!assert(fpdf (x, 2, 2*ones(1,5)), y, eps); -%!assert(fpdf (x, 2*ones(1,5), 2), y, eps); -%!assert(fpdf (x, [0 NaN Inf 2 2], 2), [NaN NaN NaN y(4:5)], eps); -%!assert(fpdf (x, 2, [0 NaN Inf 2 2]), [NaN NaN NaN y(4:5)], eps); -%!assert(fpdf ([x, NaN], 2, 2), [y, NaN], eps); +%!assert (fpdf (x, 2*ones (1,5), 2*ones (1,5)), y, eps) +%!assert (fpdf (x, 2, 2*ones (1,5)), y, eps) +%!assert (fpdf (x, 2*ones (1,5), 2), y, eps) +%!assert (fpdf (x, [0 NaN Inf 2 2], 2), [NaN NaN NaN y(4:5)], eps) +%!assert (fpdf (x, 2, [0 NaN Inf 2 2]), [NaN NaN NaN y(4:5)], eps) +%!assert (fpdf ([x, NaN], 2, 2), [y, NaN], eps) %% Test class of input preserved -%!assert(fpdf (single([x, NaN]), 2, 2), single([y, NaN]), eps("single")); -%!assert(fpdf ([x, NaN], single(2), 2), single([y, NaN]), eps("single")); -%!assert(fpdf ([x, NaN], 2, single(2)), single([y, NaN]), eps("single")); +%!assert (fpdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single")) +%!assert (fpdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single")) +%!assert (fpdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single")) %% Test input validation %!error fpdf () %!error fpdf (1) %!error fpdf (1,2) %!error fpdf (1,2,3,4) -%!error fpdf (ones(3),ones(2),ones(2)) -%!error fpdf (ones(2),ones(3),ones(2)) -%!error fpdf (ones(2),ones(2),ones(3)) +%!error fpdf (ones (3), ones (2), ones (2)) +%!error fpdf (ones (2), ones (3), ones (2)) +%!error fpdf (ones (2), ones (2), ones (3)) %!error fpdf (i, 2, 2) %!error fpdf (2, i, 2) %!error fpdf (2, 2, i)
--- a/scripts/statistics/distributions/frnd.m +++ b/scripts/statistics/distributions/frnd.m @@ -98,35 +98,35 @@ endfunction -%!assert(size (frnd (1,2)), [1, 1]); -%!assert(size (frnd (ones(2,1), 2)), [2, 1]); -%!assert(size (frnd (ones(2,2), 2)), [2, 2]); -%!assert(size (frnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (frnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (frnd (1, 2, 3)), [3, 3]); -%!assert(size (frnd (1, 2, [4 1])), [4, 1]); -%!assert(size (frnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (frnd (1,2)), [1, 1]) +%!assert (size (frnd (ones (2,1), 2)), [2, 1]) +%!assert (size (frnd (ones (2,2), 2)), [2, 2]) +%!assert (size (frnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (frnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (frnd (1, 2, 3)), [3, 3]) +%!assert (size (frnd (1, 2, [4 1])), [4, 1]) +%!assert (size (frnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (frnd (1, 2)), "double"); -%!assert(class (frnd (single(1), 2)), "single"); -%!assert(class (frnd (single([1 1]), 2)), "single"); -%!assert(class (frnd (1, single(2))), "single"); -%!assert(class (frnd (1, single([2 2]))), "single"); +%!assert (class (frnd (1, 2)), "double") +%!assert (class (frnd (single (1), 2)), "single") +%!assert (class (frnd (single ([1 1]), 2)), "single") +%!assert (class (frnd (1, single (2))), "single") +%!assert (class (frnd (1, single ([2 2]))), "single") %% Test input validation %!error frnd () %!error frnd (1) -%!error frnd (ones(3),ones(2)) -%!error frnd (ones(2),ones(3)) +%!error frnd (ones (3), ones (2)) +%!error frnd (ones (2), ones (3)) %!error frnd (i, 2) %!error frnd (2, i) %!error frnd (1,2, -1) -%!error frnd (1,2, ones(2)) +%!error frnd (1,2, ones (2)) %!error frnd (1, 2, [2 -1 2]) -%!error frnd (1,2, 1, ones(2)) +%!error frnd (1,2, 1, ones (2)) %!error frnd (1,2, 1, -1) -%!error frnd (ones(2,2), 2, 3) -%!error frnd (ones(2,2), 2, [3, 2]) -%!error frnd (ones(2,2), 2, 2, 3) +%!error frnd (ones (2,2), 2, 3) +%!error frnd (ones (2,2), 2, [3, 2]) +%!error frnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/gamcdf.m +++ b/scripts/statistics/distributions/gamcdf.m @@ -66,25 +66,25 @@ %!shared x,y %! x = [-1 0 0.5 1 2 Inf]; %! y = [0, gammainc(x(2:end), 1)]; -%!assert(gamcdf (x, ones(1,6), ones(1,6)), y); -%!assert(gamcdf (x, 1, ones(1,6)), y); -%!assert(gamcdf (x, ones(1,6), 1), y); -%!assert(gamcdf (x, [0 -Inf NaN Inf 1 1], 1), [NaN NaN NaN NaN y(5:6)]); -%!assert(gamcdf (x, 1, [0 -Inf NaN Inf 1 1]), [NaN NaN NaN NaN y(5:6)]); -%!assert(gamcdf ([x(1:2) NaN x(4:6)], 1, 1), [y(1:2) NaN y(4:6)]); +%!assert (gamcdf (x, ones (1,6), ones (1,6)), y) +%!assert (gamcdf (x, 1, ones (1,6)), y) +%!assert (gamcdf (x, ones (1,6), 1), y) +%!assert (gamcdf (x, [0 -Inf NaN Inf 1 1], 1), [NaN NaN NaN NaN y(5:6)]) +%!assert (gamcdf (x, 1, [0 -Inf NaN Inf 1 1]), [NaN NaN NaN NaN y(5:6)]) +%!assert (gamcdf ([x(1:2) NaN x(4:6)], 1, 1), [y(1:2) NaN y(4:6)]) %% Test class of input preserved -%!assert(gamcdf ([x, NaN], 1, 1), [y, NaN]); -%!assert(gamcdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single")); +%!assert (gamcdf ([x, NaN], 1, 1), [y, NaN]) +%!assert (gamcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) %% Test input validation %!error gamcdf () %!error gamcdf (1) %!error gamcdf (1,2) %!error gamcdf (1,2,3,4) -%!error gamcdf (ones(3),ones(2),ones(2)) -%!error gamcdf (ones(2),ones(3),ones(2)) -%!error gamcdf (ones(2),ones(2),ones(3)) +%!error gamcdf (ones (3), ones (2), ones (2)) +%!error gamcdf (ones (2), ones (3), ones (2)) +%!error gamcdf (ones (2), ones (2), ones (3)) %!error gamcdf (i, 2, 2) %!error gamcdf (2, i, 2) %!error gamcdf (2, 2, i)
--- a/scripts/statistics/distributions/gaminv.m +++ b/scripts/statistics/distributions/gaminv.m @@ -102,27 +102,27 @@ %!shared x %! x = [-1 0 0.63212055882855778 1 2]; -%!assert(gaminv (x, ones(1,5), ones(1,5)), [NaN 0 1 Inf NaN], eps); -%!assert(gaminv (x, 1, ones(1,5)), [NaN 0 1 Inf NaN], eps); -%!assert(gaminv (x, ones(1,5), 1), [NaN 0 1 Inf NaN], eps); -%!assert(gaminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]); -%!assert(gaminv (x, 1, [1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(gaminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]); +%!assert (gaminv (x, ones (1,5), ones (1,5)), [NaN 0 1 Inf NaN], eps) +%!assert (gaminv (x, 1, ones (1,5)), [NaN 0 1 Inf NaN], eps) +%!assert (gaminv (x, ones (1,5), 1), [NaN 0 1 Inf NaN], eps) +%!assert (gaminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]) +%!assert (gaminv (x, 1, [1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (gaminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(gaminv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps); -%!assert(gaminv (single([x, NaN]), 1, 1), single([NaN 0 1 Inf NaN NaN]), eps("single")); -%!assert(gaminv ([x, NaN], single(1), 1), single([NaN 0 1 Inf NaN NaN]), eps("single")); -%!assert(gaminv ([x, NaN], 1, single(1)), single([NaN 0 1 Inf NaN NaN]), eps("single")); +%!assert (gaminv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps) +%!assert (gaminv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) +%!assert (gaminv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) +%!assert (gaminv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %% Test input validation %!error gaminv () %!error gaminv (1) %!error gaminv (1,2) %!error gaminv (1,2,3,4) -%!error gaminv (ones(3),ones(2),ones(2)) -%!error gaminv (ones(2),ones(3),ones(2)) -%!error gaminv (ones(2),ones(2),ones(3)) +%!error gaminv (ones (3), ones (2), ones (2)) +%!error gaminv (ones (2), ones (3), ones (2)) +%!error gaminv (ones (2), ones (2), ones (3)) %!error gaminv (i, 2, 2) %!error gaminv (2, i, 2) %!error gaminv (2, 2, i)
--- a/scripts/statistics/distributions/gampdf.m +++ b/scripts/statistics/distributions/gampdf.m @@ -77,26 +77,26 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = [0 exp(-x(2:end))]; -%!assert(gampdf (x, ones(1,5), ones(1,5)), y); -%!assert(gampdf (x, 1, ones(1,5)), y); -%!assert(gampdf (x, ones(1,5), 1), y); -%!assert(gampdf (x, [0 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN y(5)]); -%!assert(gampdf (x, 1, [0 -Inf NaN Inf 1]), [NaN NaN NaN 0 y(5)]); -%!assert(gampdf ([x, NaN], 1, 1), [y, NaN]); +%!assert (gampdf (x, ones (1,5), ones (1,5)), y) +%!assert (gampdf (x, 1, ones (1,5)), y) +%!assert (gampdf (x, ones (1,5), 1), y) +%!assert (gampdf (x, [0 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN y(5)]) +%!assert (gampdf (x, 1, [0 -Inf NaN Inf 1]), [NaN NaN NaN 0 y(5)]) +%!assert (gampdf ([x, NaN], 1, 1), [y, NaN]) %% Test class of input preserved -%!assert(gampdf (single([x, NaN]), 1, 1), single([y, NaN])); -%!assert(gampdf ([x, NaN], single(1), 1), single([y, NaN])); -%!assert(gampdf ([x, NaN], 1, single(1)), single([y, NaN])); +%!assert (gampdf (single ([x, NaN]), 1, 1), single ([y, NaN])) +%!assert (gampdf ([x, NaN], single (1), 1), single ([y, NaN])) +%!assert (gampdf ([x, NaN], 1, single (1)), single ([y, NaN])) %% Test input validation %!error gampdf () %!error gampdf (1) %!error gampdf (1,2) %!error gampdf (1,2,3,4) -%!error gampdf (ones(3),ones(2),ones(2)) -%!error gampdf (ones(2),ones(3),ones(2)) -%!error gampdf (ones(2),ones(2),ones(3)) +%!error gampdf (ones (3), ones (2), ones (2)) +%!error gampdf (ones (2), ones (3), ones (2)) +%!error gampdf (ones (2), ones (2), ones (3)) %!error gampdf (i, 2, 2) %!error gampdf (2, i, 2) %!error gampdf (2, 2, i)
--- a/scripts/statistics/distributions/gamrnd.m +++ b/scripts/statistics/distributions/gamrnd.m @@ -101,35 +101,35 @@ endfunction -%!assert(size (gamrnd (1,2)), [1, 1]); -%!assert(size (gamrnd (ones(2,1), 2)), [2, 1]); -%!assert(size (gamrnd (ones(2,2), 2)), [2, 2]); -%!assert(size (gamrnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (gamrnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (gamrnd (1, 2, 3)), [3, 3]); -%!assert(size (gamrnd (1, 2, [4 1])), [4, 1]); -%!assert(size (gamrnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (gamrnd (1,2)), [1, 1]) +%!assert (size (gamrnd (ones (2,1), 2)), [2, 1]) +%!assert (size (gamrnd (ones (2,2), 2)), [2, 2]) +%!assert (size (gamrnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (gamrnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (gamrnd (1, 2, 3)), [3, 3]) +%!assert (size (gamrnd (1, 2, [4 1])), [4, 1]) +%!assert (size (gamrnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (gamrnd (1, 2)), "double"); -%!assert(class (gamrnd (single(1), 2)), "single"); -%!assert(class (gamrnd (single([1 1]), 2)), "single"); -%!assert(class (gamrnd (1, single(2))), "single"); -%!assert(class (gamrnd (1, single([2 2]))), "single"); +%!assert (class (gamrnd (1, 2)), "double") +%!assert (class (gamrnd (single (1), 2)), "single") +%!assert (class (gamrnd (single ([1 1]), 2)), "single") +%!assert (class (gamrnd (1, single (2))), "single") +%!assert (class (gamrnd (1, single ([2 2]))), "single") %% Test input validation %!error gamrnd () %!error gamrnd (1) -%!error gamrnd (ones(3),ones(2)) -%!error gamrnd (ones(2),ones(3)) +%!error gamrnd (ones (3), ones (2)) +%!error gamrnd (ones (2), ones (3)) %!error gamrnd (i, 2) %!error gamrnd (2, i) %!error gamrnd (1,2, -1) -%!error gamrnd (1,2, ones(2)) +%!error gamrnd (1,2, ones (2)) %!error gamrnd (1, 2, [2 -1 2]) -%!error gamrnd (1,2, 1, ones(2)) +%!error gamrnd (1,2, 1, ones (2)) %!error gamrnd (1,2, 1, -1) -%!error gamrnd (ones(2,2), 2, 3) -%!error gamrnd (ones(2,2), 2, [3, 2]) -%!error gamrnd (ones(2,2), 2, 2, 3) +%!error gamrnd (ones (2,2), 2, 3) +%!error gamrnd (ones (2,2), 2, [3, 2]) +%!error gamrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/geocdf.m +++ b/scripts/statistics/distributions/geocdf.m @@ -68,22 +68,22 @@ %!shared x,y %! x = [-1 0 1 Inf]; %! y = [0 0.5 0.75 1]; -%!assert(geocdf (x, 0.5*ones(1,4)), y); -%!assert(geocdf (x, 0.5), y); -%!assert(geocdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]); -%!assert(geocdf ([x(1:2) NaN x(4)], 0.5), [y(1:2) NaN y(4)]); +%!assert (geocdf (x, 0.5*ones (1,4)), y) +%!assert (geocdf (x, 0.5), y) +%!assert (geocdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]) +%!assert (geocdf ([x(1:2) NaN x(4)], 0.5), [y(1:2) NaN y(4)]) %% Test class of input preserved -%!assert(geocdf ([x, NaN], 0.5), [y, NaN]); -%!assert(geocdf (single([x, NaN]), 0.5), single([y, NaN])); -%!assert(geocdf ([x, NaN], single(0.5)), single([y, NaN])); +%!assert (geocdf ([x, NaN], 0.5), [y, NaN]) +%!assert (geocdf (single ([x, NaN]), 0.5), single ([y, NaN])) +%!assert (geocdf ([x, NaN], single (0.5)), single ([y, NaN])) %% Test input validation %!error geocdf () %!error geocdf (1) %!error geocdf (1,2,3) -%!error geocdf (ones(3),ones(2)) -%!error geocdf (ones(2),ones(3)) +%!error geocdf (ones (3), ones (2)) +%!error geocdf (ones (2), ones (3)) %!error geocdf (i, 2) %!error geocdf (2, i)
--- a/scripts/statistics/distributions/geoinv.m +++ b/scripts/statistics/distributions/geoinv.m @@ -64,22 +64,22 @@ %!shared x %! x = [-1 0 0.75 1 2]; -%!assert(geoinv (x, 0.5*ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(geoinv (x, 0.5), [NaN 0 1 Inf NaN]); -%!assert(geoinv (x, 0.5*[1 -1 NaN 4 1]), [NaN NaN NaN NaN NaN]); -%!assert(geoinv ([x(1:2) NaN x(4:5)], 0.5), [NaN 0 NaN Inf NaN]); +%!assert (geoinv (x, 0.5*ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (geoinv (x, 0.5), [NaN 0 1 Inf NaN]) +%!assert (geoinv (x, 0.5*[1 -1 NaN 4 1]), [NaN NaN NaN NaN NaN]) +%!assert (geoinv ([x(1:2) NaN x(4:5)], 0.5), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(geoinv ([x, NaN], 0.5), [NaN 0 1 Inf NaN NaN]); -%!assert(geoinv (single([x, NaN]), 0.5), single([NaN 0 1 Inf NaN NaN])); -%!assert(geoinv ([x, NaN], single(0.5)), single([NaN 0 1 Inf NaN NaN])); +%!assert (geoinv ([x, NaN], 0.5), [NaN 0 1 Inf NaN NaN]) +%!assert (geoinv (single ([x, NaN]), 0.5), single ([NaN 0 1 Inf NaN NaN])) +%!assert (geoinv ([x, NaN], single (0.5)), single ([NaN 0 1 Inf NaN NaN])) %% Test input validation %!error geoinv () %!error geoinv (1) %!error geoinv (1,2,3) -%!error geoinv (ones(3),ones(2)) -%!error geoinv (ones(2),ones(3)) +%!error geoinv (ones (3), ones (2)) +%!error geoinv (ones (2), ones (3)) %!error geoinv (i, 2) %!error geoinv (2, i)
--- a/scripts/statistics/distributions/geopdf.m +++ b/scripts/statistics/distributions/geopdf.m @@ -65,21 +65,21 @@ %!shared x,y %! x = [-1 0 1 Inf]; %! y = [0, 1/2, 1/4, NaN]; -%!assert(geopdf (x, 0.5*ones(1,4)), y); -%!assert(geopdf (x, 0.5), y); -%!assert(geopdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]); -%!assert(geopdf ([x, NaN], 0.5), [y, NaN]); +%!assert (geopdf (x, 0.5*ones (1,4)), y) +%!assert (geopdf (x, 0.5), y) +%!assert (geopdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]) +%!assert (geopdf ([x, NaN], 0.5), [y, NaN]) %% Test class of input preserved -%!assert(geopdf (single([x, NaN]), 0.5), single([y, NaN]), 5*eps("single")); -%!assert(geopdf ([x, NaN], single(0.5)), single([y, NaN]), 5*eps("single")); +%!assert (geopdf (single ([x, NaN]), 0.5), single ([y, NaN]), 5*eps ("single")) +%!assert (geopdf ([x, NaN], single (0.5)), single ([y, NaN]), 5*eps ("single")) %% Test input validation %!error geopdf () %!error geopdf (1) %!error geopdf (1,2,3) -%!error geopdf (ones(3),ones(2)) -%!error geopdf (ones(2),ones(3)) +%!error geopdf (ones (3), ones (2)) +%!error geopdf (ones (2), ones (3)) %!error geopdf (i, 2) %!error geopdf (2, i)
--- a/scripts/statistics/distributions/geornd.m +++ b/scripts/statistics/distributions/geornd.m @@ -98,28 +98,28 @@ endfunction -%!assert(size (geornd (0.5)), [1, 1]); -%!assert(size (geornd (0.5*ones(2,1))), [2, 1]); -%!assert(size (geornd (0.5*ones(2,2))), [2, 2]); -%!assert(size (geornd (0.5, 3)), [3, 3]); -%!assert(size (geornd (0.5, [4 1])), [4, 1]); -%!assert(size (geornd (0.5, 4, 1)), [4, 1]); +%!assert (size (geornd (0.5)), [1, 1]) +%!assert (size (geornd (0.5*ones (2,1))), [2, 1]) +%!assert (size (geornd (0.5*ones (2,2))), [2, 2]) +%!assert (size (geornd (0.5, 3)), [3, 3]) +%!assert (size (geornd (0.5, [4 1])), [4, 1]) +%!assert (size (geornd (0.5, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (geornd (0.5)), "double"); -%!assert(class (geornd (single(0.5))), "single"); -%!assert(class (geornd (single([0.5 0.5]))), "single"); -%!assert(class (geornd (single(0))), "single"); -%!assert(class (geornd (single(1))), "single"); +%!assert (class (geornd (0.5)), "double") +%!assert (class (geornd (single (0.5))), "single") +%!assert (class (geornd (single ([0.5 0.5]))), "single") +%!assert (class (geornd (single (0))), "single") +%!assert (class (geornd (single (1))), "single") %% Test input validation %!error geornd () -%!error geornd (ones(3),ones(2)) -%!error geornd (ones(2),ones(3)) +%!error geornd (ones (3), ones (2)) +%!error geornd (ones (2), ones (3)) %!error geornd (i) %!error geornd (1, -1) -%!error geornd (1, ones(2)) +%!error geornd (1, ones (2)) %!error geornd (1, [2 -1 2]) -%!error geornd (ones(2,2), 2, 3) -%!error geornd (ones(2,2), 3, 2) +%!error geornd (ones (2,2), 2, 3) +%!error geornd (ones (2,2), 3, 2)
--- a/scripts/statistics/distributions/hygecdf.m +++ b/scripts/statistics/distributions/hygecdf.m @@ -76,22 +76,22 @@ %!shared x,y %! x = [-1 0 1 2 3]; %! y = [0 1/6 5/6 1 1]; -%!assert(hygecdf (x, 4*ones(1,5), 2, 2), y, eps); -%!assert(hygecdf (x, 4, 2*ones(1,5), 2), y, eps); -%!assert(hygecdf (x, 4, 2, 2*ones(1,5)), y, eps); -%!assert(hygecdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [y(1) NaN NaN NaN y(5)], eps); -%!assert(hygecdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [y(1) NaN NaN NaN y(5)], eps); -%!assert(hygecdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]); -%!assert(hygecdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [y(1) NaN NaN NaN y(5)], eps); -%!assert(hygecdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]); -%!assert(hygecdf ([x(1:2) NaN x(4:5)], 4, 2, 2), [y(1:2) NaN y(4:5)], eps); +%!assert (hygecdf (x, 4*ones (1,5), 2, 2), y, eps) +%!assert (hygecdf (x, 4, 2*ones (1,5), 2), y, eps) +%!assert (hygecdf (x, 4, 2, 2*ones (1,5)), y, eps) +%!assert (hygecdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [y(1) NaN NaN NaN y(5)], eps) +%!assert (hygecdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [y(1) NaN NaN NaN y(5)], eps) +%!assert (hygecdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]) +%!assert (hygecdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [y(1) NaN NaN NaN y(5)], eps) +%!assert (hygecdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) +%!assert (hygecdf ([x(1:2) NaN x(4:5)], 4, 2, 2), [y(1:2) NaN y(4:5)], eps) %% Test class of input preserved -%!assert(hygecdf ([x, NaN], 4, 2, 2), [y, NaN], eps); -%!assert(hygecdf (single([x, NaN]), 4, 2, 2), single([y, NaN]), eps("single")); -%!assert(hygecdf ([x, NaN], single(4), 2, 2), single([y, NaN]), eps("single")); -%!assert(hygecdf ([x, NaN], 4, single(2), 2), single([y, NaN]), eps("single")); -%!assert(hygecdf ([x, NaN], 4, 2, single(2)), single([y, NaN]), eps("single")); +%!assert (hygecdf ([x, NaN], 4, 2, 2), [y, NaN], eps) +%!assert (hygecdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]), eps ("single")) +%!assert (hygecdf ([x, NaN], single (4), 2, 2), single ([y, NaN]), eps ("single")) +%!assert (hygecdf ([x, NaN], 4, single (2), 2), single ([y, NaN]), eps ("single")) +%!assert (hygecdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]), eps ("single")) %% Test input validation %!error hygecdf () @@ -99,9 +99,9 @@ %!error hygecdf (1,2) %!error hygecdf (1,2,3) %!error hygecdf (1,2,3,4,5) -%!error hygecdf (ones(2), ones(3), 1, 1) -%!error hygecdf (1, ones(2), ones(3), 1) -%!error hygecdf (1, 1, ones(2), ones(3)) +%!error hygecdf (ones (2), ones (3), 1, 1) +%!error hygecdf (1, ones (2), ones (3), 1) +%!error hygecdf (1, 1, ones (2), ones (3)) %!error hygecdf (i, 2, 2, 2) %!error hygecdf (2, i, 2, 2) %!error hygecdf (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygeinv.m +++ b/scripts/statistics/distributions/hygeinv.m @@ -80,23 +80,23 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(hygeinv (x, 4*ones(1,5), 2*ones(1,5), 2*ones(1,5)), [NaN 0 1 2 NaN]); -%!assert(hygeinv (x, 4*ones(1,5), 2, 2), [NaN 0 1 2 NaN]); -%!assert(hygeinv (x, 4, 2*ones(1,5), 2), [NaN 0 1 2 NaN]); -%!assert(hygeinv (x, 4, 2, 2*ones(1,5)), [NaN 0 1 2 NaN]); -%!assert(hygeinv (x, 4*[1 -1 NaN 1.1 1], 2, 2), [NaN NaN NaN NaN NaN]); -%!assert(hygeinv (x, 4, 2*[1 -1 NaN 1.1 1], 2), [NaN NaN NaN NaN NaN]); -%!assert(hygeinv (x, 4, 5, 2), [NaN NaN NaN NaN NaN]); -%!assert(hygeinv (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [NaN NaN NaN NaN NaN]); -%!assert(hygeinv (x, 4, 2, 5), [NaN NaN NaN NaN NaN]); -%!assert(hygeinv ([x(1:2) NaN x(4:5)], 4, 2, 2), [NaN 0 NaN 2 NaN]); +%!assert (hygeinv (x, 4*ones (1,5), 2*ones (1,5), 2*ones (1,5)), [NaN 0 1 2 NaN]) +%!assert (hygeinv (x, 4*ones (1,5), 2, 2), [NaN 0 1 2 NaN]) +%!assert (hygeinv (x, 4, 2*ones (1,5), 2), [NaN 0 1 2 NaN]) +%!assert (hygeinv (x, 4, 2, 2*ones (1,5)), [NaN 0 1 2 NaN]) +%!assert (hygeinv (x, 4*[1 -1 NaN 1.1 1], 2, 2), [NaN NaN NaN NaN NaN]) +%!assert (hygeinv (x, 4, 2*[1 -1 NaN 1.1 1], 2), [NaN NaN NaN NaN NaN]) +%!assert (hygeinv (x, 4, 5, 2), [NaN NaN NaN NaN NaN]) +%!assert (hygeinv (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [NaN NaN NaN NaN NaN]) +%!assert (hygeinv (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) +%!assert (hygeinv ([x(1:2) NaN x(4:5)], 4, 2, 2), [NaN 0 NaN 2 NaN]) %% Test class of input preserved -%!assert(hygeinv ([x, NaN], 4, 2, 2), [NaN 0 1 2 NaN NaN]); -%!assert(hygeinv (single([x, NaN]), 4, 2, 2), single([NaN 0 1 2 NaN NaN])); -%!assert(hygeinv ([x, NaN], single(4), 2, 2), single([NaN 0 1 2 NaN NaN])); -%!assert(hygeinv ([x, NaN], 4, single(2), 2), single([NaN 0 1 2 NaN NaN])); -%!assert(hygeinv ([x, NaN], 4, 2, single(2)), single([NaN 0 1 2 NaN NaN])); +%!assert (hygeinv ([x, NaN], 4, 2, 2), [NaN 0 1 2 NaN NaN]) +%!assert (hygeinv (single ([x, NaN]), 4, 2, 2), single ([NaN 0 1 2 NaN NaN])) +%!assert (hygeinv ([x, NaN], single (4), 2, 2), single ([NaN 0 1 2 NaN NaN])) +%!assert (hygeinv ([x, NaN], 4, single (2), 2), single ([NaN 0 1 2 NaN NaN])) +%!assert (hygeinv ([x, NaN], 4, 2, single (2)), single ([NaN 0 1 2 NaN NaN])) %% Test input validation %!error hygeinv () @@ -104,9 +104,9 @@ %!error hygeinv (1,2) %!error hygeinv (1,2,3) %!error hygeinv (1,2,3,4,5) -%!error hygeinv (ones(2), ones(3), 1, 1) -%!error hygeinv (1, ones(2), ones(3), 1) -%!error hygeinv (1, 1, ones(2), ones(3)) +%!error hygeinv (ones (2), ones (3), 1, 1) +%!error hygeinv (1, ones (2), ones (3), 1) +%!error hygeinv (1, 1, ones (2), ones (3)) %!error hygeinv (i, 2, 2, 2) %!error hygeinv (2, i, 2, 2) %!error hygeinv (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygepdf.m +++ b/scripts/statistics/distributions/hygepdf.m @@ -80,21 +80,21 @@ %!shared x,y %! x = [-1 0 1 2 3]; %! y = [0 1/6 4/6 1/6 0]; -%!assert(hygepdf (x, 4*ones(1,5), 2, 2), y); -%!assert(hygepdf (x, 4, 2*ones(1,5), 2), y); -%!assert(hygepdf (x, 4, 2, 2*ones(1,5)), y); -%!assert(hygepdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [0 NaN NaN NaN 0]); -%!assert(hygepdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [0 NaN NaN NaN 0]); -%!assert(hygepdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]); -%!assert(hygepdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [0 NaN NaN NaN 0]); -%!assert(hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]); -%!assert(hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps); +%!assert (hygepdf (x, 4*ones (1,5), 2, 2), y) +%!assert (hygepdf (x, 4, 2*ones (1,5), 2), y) +%!assert (hygepdf (x, 4, 2, 2*ones (1,5)), y) +%!assert (hygepdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [0 NaN NaN NaN 0]) +%!assert (hygepdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [0 NaN NaN NaN 0]) +%!assert (hygepdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]) +%!assert (hygepdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [0 NaN NaN NaN 0]) +%!assert (hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) +%!assert (hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps) %% Test class of input preserved -%!assert(hygepdf (single([x, NaN]), 4, 2, 2), single([y, NaN])); -%!assert(hygepdf ([x, NaN], single(4), 2, 2), single([y, NaN])); -%!assert(hygepdf ([x, NaN], 4, single(2), 2), single([y, NaN])); -%!assert(hygepdf ([x, NaN], 4, 2, single(2)), single([y, NaN])); +%!assert (hygepdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN])) +%!assert (hygepdf ([x, NaN], single (4), 2, 2), single ([y, NaN])) +%!assert (hygepdf ([x, NaN], 4, single (2), 2), single ([y, NaN])) +%!assert (hygepdf ([x, NaN], 4, 2, single (2)), single ([y, NaN])) %% Test input validation %!error hygepdf () @@ -102,9 +102,9 @@ %!error hygepdf (1,2) %!error hygepdf (1,2,3) %!error hygepdf (1,2,3,4,5) -%!error hygepdf (1, ones(3),ones(2),ones(2)) -%!error hygepdf (1, ones(2),ones(3),ones(2)) -%!error hygepdf (1, ones(2),ones(2),ones(3)) +%!error hygepdf (1, ones (3), ones (2), ones (2)) +%!error hygepdf (1, ones (2), ones (3), ones (2)) +%!error hygepdf (1, ones (2), ones (2), ones (3)) %!error hygepdf (i, 2, 2, 2) %!error hygepdf (2, i, 2, 2) %!error hygepdf (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygernd.m +++ b/scripts/statistics/distributions/hygernd.m @@ -110,39 +110,39 @@ endfunction -%!assert(size (hygernd (4,2,2)), [1, 1]); -%!assert(size (hygernd (4*ones(2,1), 2,2)), [2, 1]); -%!assert(size (hygernd (4*ones(2,2), 2,2)), [2, 2]); -%!assert(size (hygernd (4, 2*ones(2,1), 2)), [2, 1]); -%!assert(size (hygernd (4, 2*ones(2,2), 2)), [2, 2]); -%!assert(size (hygernd (4, 2, 2*ones(2,1))), [2, 1]); -%!assert(size (hygernd (4, 2, 2*ones(2,2))), [2, 2]); -%!assert(size (hygernd (4, 2, 2, 3)), [3, 3]); -%!assert(size (hygernd (4, 2, 2, [4 1])), [4, 1]); -%!assert(size (hygernd (4, 2, 2, 4, 1)), [4, 1]); +%!assert (size (hygernd (4,2,2)), [1, 1]) +%!assert (size (hygernd (4*ones (2,1), 2,2)), [2, 1]) +%!assert (size (hygernd (4*ones (2,2), 2,2)), [2, 2]) +%!assert (size (hygernd (4, 2*ones (2,1), 2)), [2, 1]) +%!assert (size (hygernd (4, 2*ones (2,2), 2)), [2, 2]) +%!assert (size (hygernd (4, 2, 2*ones (2,1))), [2, 1]) +%!assert (size (hygernd (4, 2, 2*ones (2,2))), [2, 2]) +%!assert (size (hygernd (4, 2, 2, 3)), [3, 3]) +%!assert (size (hygernd (4, 2, 2, [4 1])), [4, 1]) +%!assert (size (hygernd (4, 2, 2, 4, 1)), [4, 1]) -%!assert(class (hygernd (4,2,2)), "double"); -%!assert(class (hygernd (single(4),2,2)), "single"); -%!assert(class (hygernd (single([4 4]),2,2)), "single"); -%!assert(class (hygernd (4,single(2),2)), "single"); -%!assert(class (hygernd (4,single([2 2]),2)), "single"); -%!assert(class (hygernd (4,2,single(2))), "single"); -%!assert(class (hygernd (4,2,single([2 2]))), "single"); +%!assert (class (hygernd (4,2,2)), "double") +%!assert (class (hygernd (single (4),2,2)), "single") +%!assert (class (hygernd (single ([4 4]),2,2)), "single") +%!assert (class (hygernd (4,single (2),2)), "single") +%!assert (class (hygernd (4,single ([2 2]),2)), "single") +%!assert (class (hygernd (4,2,single (2))), "single") +%!assert (class (hygernd (4,2,single ([2 2]))), "single") %% Test input validation %!error hygernd () %!error hygernd (1) %!error hygernd (1,2) -%!error hygernd (ones(3),ones(2),ones(2), 2) -%!error hygernd (ones(2),ones(3),ones(2), 2) -%!error hygernd (ones(2),ones(2),ones(3), 2) +%!error hygernd (ones (3), ones (2), ones (2), 2) +%!error hygernd (ones (2), ones (3), ones (2), 2) +%!error hygernd (ones (2), ones (2), ones (3), 2) %!error hygernd (i, 2, 2) %!error hygernd (2, i, 2) %!error hygernd (2, 2, i) %!error hygernd (4,2,2, -1) -%!error hygernd (4,2,2, ones(2)) +%!error hygernd (4,2,2, ones (2)) %!error hygernd (4,2,2, [2 -1 2]) -%!error hygernd (4*ones(2),2,2, 3) -%!error hygernd (4*ones(2),2,2, [3, 2]) -%!error hygernd (4*ones(2),2,2, 3, 2) +%!error hygernd (4*ones (2),2,2, 3) +%!error hygernd (4*ones (2),2,2, [3, 2]) +%!error hygernd (4*ones (2),2,2, 3, 2)
--- a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m +++ b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m @@ -90,6 +90,6 @@ %% Test input validation %!error kolmogorov_smirnov_cdf () %!error kolmogorov_smirnov_cdf (1,2,3) -%!error kolmogorov_smirnov_cdf (1, ones(2)) +%!error kolmogorov_smirnov_cdf (1, ones (2)) %!error kolmogorov_smirnov_cdf ([], 1)
--- a/scripts/statistics/distributions/laplace_cdf.m +++ b/scripts/statistics/distributions/laplace_cdf.m @@ -44,10 +44,10 @@ %!shared x,y %! x = [-Inf -log(2) 0 log(2) Inf]; %! y = [0, 1/4, 1/2, 3/4, 1]; -%!assert(laplace_cdf ([x, NaN]), [y, NaN]); +%!assert (laplace_cdf ([x, NaN]), [y, NaN]) %% Test class of input preserved -%!assert(laplace_cdf (single([x, NaN])), single([y, NaN])); +%!assert (laplace_cdf (single ([x, NaN])), single ([y, NaN])) %% Test input validation %!error laplace_cdf ()
--- a/scripts/statistics/distributions/laplace_inv.m +++ b/scripts/statistics/distributions/laplace_inv.m @@ -51,11 +51,11 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(laplace_inv (x), [NaN -Inf 0 Inf NaN]); +%!assert (laplace_inv (x), [NaN -Inf 0 Inf NaN]) %% Test class of input preserved -%!assert(laplace_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]); -%!assert(laplace_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN])); +%!assert (laplace_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) +%!assert (laplace_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) %% Test input validation %!error laplace_inv ()
--- a/scripts/statistics/distributions/laplace_pdf.m +++ b/scripts/statistics/distributions/laplace_pdf.m @@ -44,10 +44,10 @@ %!shared x,y %! x = [-Inf -log(2) 0 log(2) Inf]; %! y = [0, 1/4, 1/2, 1/4, 0]; -%!assert(laplace_pdf ([x, NaN]), [y, NaN]); +%!assert (laplace_pdf ([x, NaN]), [y, NaN]) %% Test class of input preserved -%!assert(laplace_pdf (single([x, NaN])), single([y, NaN])); +%!assert (laplace_pdf (single ([x, NaN])), single ([y, NaN])) %% Test input validation %!error laplace_pdf ()
--- a/scripts/statistics/distributions/laplace_rnd.m +++ b/scripts/statistics/distributions/laplace_rnd.m @@ -60,15 +60,15 @@ endfunction -%!assert(size (laplace_rnd (3)), [3, 3]); -%!assert(size (laplace_rnd ([4 1])), [4, 1]); -%!assert(size (laplace_rnd (4,1)), [4, 1]); +%!assert (size (laplace_rnd (3)), [3, 3]) +%!assert (size (laplace_rnd ([4 1])), [4, 1]) +%!assert (size (laplace_rnd (4,1)), [4, 1]) %% Test input validation %!error laplace_rnd () %!error laplace_rnd (-1) -%!error laplace_rnd (ones(2)) +%!error laplace_rnd (ones (2)) %!error laplace_rnd ([2 -1 2]) -%!error laplace_rnd (1, ones(2)) +%!error laplace_rnd (1, ones (2)) %!error laplace_rnd (1, -1)
--- a/scripts/statistics/distributions/logistic_cdf.m +++ b/scripts/statistics/distributions/logistic_cdf.m @@ -44,10 +44,10 @@ %!shared x,y %! x = [-Inf -log(3) 0 log(3) Inf]; %! y = [0, 1/4, 1/2, 3/4, 1]; -%!assert(logistic_cdf ([x, NaN]), [y, NaN], eps); +%!assert (logistic_cdf ([x, NaN]), [y, NaN], eps) %% Test class of input preserved -%!assert(logistic_cdf (single([x, NaN])), single([y, NaN]), eps ("single")); +%!assert (logistic_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) %% Test input validation %!error logistic_cdf ()
--- a/scripts/statistics/distributions/logistic_inv.m +++ b/scripts/statistics/distributions/logistic_inv.m @@ -56,11 +56,11 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(logistic_inv (x), [NaN -Inf 0 Inf NaN]); +%!assert (logistic_inv (x), [NaN -Inf 0 Inf NaN]) %% Test class of input preserved -%!assert(logistic_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]); -%!assert(logistic_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN])); +%!assert (logistic_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) +%!assert (logistic_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) %% Test input validation %!error logistic_inv ()
--- a/scripts/statistics/distributions/logistic_pdf.m +++ b/scripts/statistics/distributions/logistic_pdf.m @@ -44,10 +44,10 @@ %!shared x,y %! x = [-Inf -log(4) 0 log(4) Inf]; %! y = [0, 0.16, 1/4, 0.16, 0]; -%!assert(logistic_pdf ([x, NaN]), [y, NaN], eps); +%!assert (logistic_pdf ([x, NaN]), [y, NaN], eps) %% Test class of input preserved -%!assert(logistic_pdf (single([x, NaN])), single([y, NaN]), eps ("single")); +%!assert (logistic_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) %% Test input validation %!error logistic_pdf ()
--- a/scripts/statistics/distributions/logistic_rnd.m +++ b/scripts/statistics/distributions/logistic_rnd.m @@ -59,15 +59,15 @@ endfunction -%!assert(size (logistic_rnd (3)), [3, 3]); -%!assert(size (logistic_rnd ([4 1])), [4, 1]); -%!assert(size (logistic_rnd (4,1)), [4, 1]); +%!assert (size (logistic_rnd (3)), [3, 3]) +%!assert (size (logistic_rnd ([4 1])), [4, 1]) +%!assert (size (logistic_rnd (4,1)), [4, 1]) %% Test input validation %!error logistic_rnd () %!error logistic_rnd (-1) -%!error logistic_rnd (ones(2)) +%!error logistic_rnd (ones (2)) %!error logistic_rnd ([2 -1 2]) -%!error logistic_rnd (1, ones(2)) +%!error logistic_rnd (1, ones (2)) %!error logistic_rnd (1, -1)
--- a/scripts/statistics/distributions/logncdf.m +++ b/scripts/statistics/distributions/logncdf.m @@ -74,26 +74,26 @@ %!shared x,y %! x = [-1 0 1 e Inf]; %! y = [0, 0, 0.5, 1/2+1/2*erf(1/2), 1]; -%!assert(logncdf (x, zeros(1,5), sqrt(2)*ones(1,5)), y); -%!assert(logncdf (x, 0, sqrt(2)*ones(1,5)), y); -%!assert(logncdf (x, zeros(1,5), sqrt(2)), y); -%!assert(logncdf (x, [0 1 NaN 0 1], sqrt(2)), [0 0 NaN y(4:5)]); -%!assert(logncdf (x, 0, sqrt(2)*[0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]); -%!assert(logncdf ([x(1:3) NaN x(5)], 0, sqrt(2)), [y(1:3) NaN y(5)]); +%!assert (logncdf (x, zeros (1,5), sqrt(2)*ones (1,5)), y) +%!assert (logncdf (x, 0, sqrt(2)*ones (1,5)), y) +%!assert (logncdf (x, zeros (1,5), sqrt(2)), y) +%!assert (logncdf (x, [0 1 NaN 0 1], sqrt(2)), [0 0 NaN y(4:5)]) +%!assert (logncdf (x, 0, sqrt(2)*[0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]) +%!assert (logncdf ([x(1:3) NaN x(5)], 0, sqrt(2)), [y(1:3) NaN y(5)]) %% Test class of input preserved -%!assert(logncdf ([x, NaN], 0, sqrt(2)), [y, NaN]); -%!assert(logncdf (single([x, NaN]), 0, sqrt(2)), single([y, NaN]), eps("single")); -%!assert(logncdf ([x, NaN], single(0), sqrt(2)), single([y, NaN]), eps("single")); -%!assert(logncdf ([x, NaN], 0, single(sqrt(2))), single([y, NaN]), eps("single")); +%!assert (logncdf ([x, NaN], 0, sqrt(2)), [y, NaN]) +%!assert (logncdf (single ([x, NaN]), 0, sqrt(2)), single ([y, NaN]), eps ("single")) +%!assert (logncdf ([x, NaN], single (0), sqrt(2)), single ([y, NaN]), eps ("single")) +%!assert (logncdf ([x, NaN], 0, single (sqrt(2))), single ([y, NaN]), eps ("single")) %% Test input validation %!error logncdf () %!error logncdf (1,2) %!error logncdf (1,2,3,4) -%!error logncdf (ones(3),ones(2),ones(2)) -%!error logncdf (ones(2),ones(3),ones(2)) -%!error logncdf (ones(2),ones(2),ones(3)) +%!error logncdf (ones (3), ones (2), ones (2)) +%!error logncdf (ones (2), ones (3), ones (2)) +%!error logncdf (ones (2), ones (2), ones (3)) %!error logncdf (i, 2, 2) %!error logncdf (2, i, 2) %!error logncdf (2, 2, i)
--- a/scripts/statistics/distributions/logninv.m +++ b/scripts/statistics/distributions/logninv.m @@ -73,26 +73,26 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(logninv (x, ones(1,5), ones(1,5)), [NaN 0 e Inf NaN]); -%!assert(logninv (x, 1, ones(1,5)), [NaN 0 e Inf NaN]); -%!assert(logninv (x, ones(1,5), 1), [NaN 0 e Inf NaN]); -%!assert(logninv (x, [1 1 NaN 0 1], 1), [NaN 0 NaN Inf NaN]); -%!assert(logninv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(logninv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN Inf NaN]); +%!assert (logninv (x, ones (1,5), ones (1,5)), [NaN 0 e Inf NaN]) +%!assert (logninv (x, 1, ones (1,5)), [NaN 0 e Inf NaN]) +%!assert (logninv (x, ones (1,5), 1), [NaN 0 e Inf NaN]) +%!assert (logninv (x, [1 1 NaN 0 1], 1), [NaN 0 NaN Inf NaN]) +%!assert (logninv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (logninv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(logninv ([x, NaN], 1, 1), [NaN 0 e Inf NaN NaN]); -%!assert(logninv (single([x, NaN]), 1, 1), single([NaN 0 e Inf NaN NaN])); -%!assert(logninv ([x, NaN], single(1), 1), single([NaN 0 e Inf NaN NaN])); -%!assert(logninv ([x, NaN], 1, single(1)), single([NaN 0 e Inf NaN NaN])); +%!assert (logninv ([x, NaN], 1, 1), [NaN 0 e Inf NaN NaN]) +%!assert (logninv (single ([x, NaN]), 1, 1), single ([NaN 0 e Inf NaN NaN])) +%!assert (logninv ([x, NaN], single (1), 1), single ([NaN 0 e Inf NaN NaN])) +%!assert (logninv ([x, NaN], 1, single (1)), single ([NaN 0 e Inf NaN NaN])) %% Test input validation %!error logninv () %!error logninv (1,2) %!error logninv (1,2,3,4) -%!error logninv (ones(3),ones(2),ones(2)) -%!error logninv (ones(2),ones(3),ones(2)) -%!error logninv (ones(2),ones(2),ones(3)) +%!error logninv (ones (3), ones (2), ones (2)) +%!error logninv (ones (2), ones (3), ones (2)) +%!error logninv (ones (2), ones (2), ones (3)) %!error logninv (i, 2, 2) %!error logninv (2, i, 2) %!error logninv (2, 2, i)
--- a/scripts/statistics/distributions/lognpdf.m +++ b/scripts/statistics/distributions/lognpdf.m @@ -71,25 +71,25 @@ %!shared x,y %! x = [-1 0 e Inf]; %! y = [0, 0, 1/(e*sqrt(2*pi)) * exp(-1/2), 0]; -%!assert(lognpdf (x, zeros(1,4), ones(1,4)), y, eps); -%!assert(lognpdf (x, 0, ones(1,4)), y, eps); -%!assert(lognpdf (x, zeros(1,4), 1), y, eps); -%!assert(lognpdf (x, [0 1 NaN 0], 1), [0 0 NaN y(4)], eps); -%!assert(lognpdf (x, 0, [0 NaN Inf 1]), [NaN NaN NaN y(4)], eps); -%!assert(lognpdf ([x, NaN], 0, 1), [y, NaN], eps); +%!assert (lognpdf (x, zeros (1,4), ones (1,4)), y, eps) +%!assert (lognpdf (x, 0, ones (1,4)), y, eps) +%!assert (lognpdf (x, zeros (1,4), 1), y, eps) +%!assert (lognpdf (x, [0 1 NaN 0], 1), [0 0 NaN y(4)], eps) +%!assert (lognpdf (x, 0, [0 NaN Inf 1]), [NaN NaN NaN y(4)], eps) +%!assert (lognpdf ([x, NaN], 0, 1), [y, NaN], eps) %% Test class of input preserved -%!assert(lognpdf (single([x, NaN]), 0, 1), single([y, NaN]), eps("single")); -%!assert(lognpdf ([x, NaN], single(0), 1), single([y, NaN]), eps("single")); -%!assert(lognpdf ([x, NaN], 0, single(1)), single([y, NaN]), eps("single")); +%!assert (lognpdf (single ([x, NaN]), 0, 1), single ([y, NaN]), eps ("single")) +%!assert (lognpdf ([x, NaN], single (0), 1), single ([y, NaN]), eps ("single")) +%!assert (lognpdf ([x, NaN], 0, single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error lognpdf () %!error lognpdf (1,2) %!error lognpdf (1,2,3,4) -%!error lognpdf (ones(3),ones(2),ones(2)) -%!error lognpdf (ones(2),ones(3),ones(2)) -%!error lognpdf (ones(2),ones(2),ones(3)) +%!error lognpdf (ones (3), ones (2), ones (2)) +%!error lognpdf (ones (2), ones (3), ones (2)) +%!error lognpdf (ones (2), ones (2), ones (3)) %!error lognpdf (i, 2, 2) %!error lognpdf (2, i, 2) %!error lognpdf (2, 2, i)
--- a/scripts/statistics/distributions/lognrnd.m +++ b/scripts/statistics/distributions/lognrnd.m @@ -98,35 +98,35 @@ endfunction -%!assert(size (lognrnd (1,2)), [1, 1]); -%!assert(size (lognrnd (ones(2,1), 2)), [2, 1]); -%!assert(size (lognrnd (ones(2,2), 2)), [2, 2]); -%!assert(size (lognrnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (lognrnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (lognrnd (1, 2, 3)), [3, 3]); -%!assert(size (lognrnd (1, 2, [4 1])), [4, 1]); -%!assert(size (lognrnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (lognrnd (1,2)), [1, 1]) +%!assert (size (lognrnd (ones (2,1), 2)), [2, 1]) +%!assert (size (lognrnd (ones (2,2), 2)), [2, 2]) +%!assert (size (lognrnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (lognrnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (lognrnd (1, 2, 3)), [3, 3]) +%!assert (size (lognrnd (1, 2, [4 1])), [4, 1]) +%!assert (size (lognrnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (lognrnd (1, 2)), "double"); -%!assert(class (lognrnd (single(1), 2)), "single"); -%!assert(class (lognrnd (single([1 1]), 2)), "single"); -%!assert(class (lognrnd (1, single(2))), "single"); -%!assert(class (lognrnd (1, single([2 2]))), "single"); +%!assert (class (lognrnd (1, 2)), "double") +%!assert (class (lognrnd (single (1), 2)), "single") +%!assert (class (lognrnd (single ([1 1]), 2)), "single") +%!assert (class (lognrnd (1, single (2))), "single") +%!assert (class (lognrnd (1, single ([2 2]))), "single") %% Test input validation %!error lognrnd () %!error lognrnd (1) -%!error lognrnd (ones(3),ones(2)) -%!error lognrnd (ones(2),ones(3)) +%!error lognrnd (ones (3), ones (2)) +%!error lognrnd (ones (2), ones (3)) %!error lognrnd (i, 2) %!error lognrnd (2, i) %!error lognrnd (1,2, -1) -%!error lognrnd (1,2, ones(2)) +%!error lognrnd (1,2, ones (2)) %!error lognrnd (1, 2, [2 -1 2]) -%!error lognrnd (1,2, 1, ones(2)) +%!error lognrnd (1,2, 1, ones (2)) %!error lognrnd (1,2, 1, -1) -%!error lognrnd (ones(2,2), 2, 3) -%!error lognrnd (ones(2,2), 2, [3, 2]) -%!error lognrnd (ones(2,2), 2, 2, 3) +%!error lognrnd (ones (2,2), 2, 3) +%!error lognrnd (ones (2,2), 2, [3, 2]) +%!error lognrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/nbincdf.m +++ b/scripts/statistics/distributions/nbincdf.m @@ -78,27 +78,27 @@ %!shared x,y %! x = [-1 0 1 2 Inf]; %! y = [0 1/2 3/4 7/8 1]; -%!assert(nbincdf (x, ones(1,5), 0.5*ones(1,5)), y); -%!assert(nbincdf (x, 1, 0.5*ones(1,5)), y); -%!assert(nbincdf (x, ones(1,5), 0.5), y); -%!assert(nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps); -%!assert(nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]); -%!assert(nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)]); +%!assert (nbincdf (x, ones (1,5), 0.5*ones (1,5)), y) +%!assert (nbincdf (x, 1, 0.5*ones (1,5)), y) +%!assert (nbincdf (x, ones (1,5), 0.5), y) +%!assert (nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps) +%!assert (nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]) +%!assert (nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(nbincdf ([x, NaN], 1, 0.5), [y, NaN]); -%!assert(nbincdf (single([x, NaN]), 1, 0.5), single([y, NaN])); -%!assert(nbincdf ([x, NaN], single(1), 0.5), single([y, NaN])); -%!assert(nbincdf ([x, NaN], 1, single(0.5)), single([y, NaN])); +%!assert (nbincdf ([x, NaN], 1, 0.5), [y, NaN]) +%!assert (nbincdf (single ([x, NaN]), 1, 0.5), single ([y, NaN])) +%!assert (nbincdf ([x, NaN], single (1), 0.5), single ([y, NaN])) +%!assert (nbincdf ([x, NaN], 1, single (0.5)), single ([y, NaN])) %% Test input validation %!error nbincdf () %!error nbincdf (1) %!error nbincdf (1,2) %!error nbincdf (1,2,3,4) -%!error nbincdf (ones(3),ones(2),ones(2)) -%!error nbincdf (ones(2),ones(3),ones(2)) -%!error nbincdf (ones(2),ones(2),ones(3)) +%!error nbincdf (ones (3), ones (2), ones (2)) +%!error nbincdf (ones (2), ones (3), ones (2)) +%!error nbincdf (ones (2), ones (2), ones (3)) %!error nbincdf (i, 2, 2) %!error nbincdf (2, i, 2) %!error nbincdf (2, 2, i)
--- a/scripts/statistics/distributions/nbininv.m +++ b/scripts/statistics/distributions/nbininv.m @@ -100,28 +100,28 @@ %!shared x %! x = [-1 0 3/4 1 2]; -%!assert(nbininv (x, ones(1,5), 0.5*ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(nbininv (x, 1, 0.5*ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(nbininv (x, ones(1,5), 0.5), [NaN 0 1 Inf NaN]); -%!assert(nbininv (x, [1 0 NaN Inf 1], 0.5), [NaN NaN NaN NaN NaN]); -%!assert(nbininv (x, [1 0 1.5 Inf 1], 0.5), [NaN NaN 2 NaN NaN]); -%!assert(nbininv (x, 1, 0.5*[1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(nbininv ([x(1:2) NaN x(4:5)], 1, 0.5), [NaN 0 NaN Inf NaN]); +%!assert (nbininv (x, ones (1,5), 0.5*ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (nbininv (x, 1, 0.5*ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (nbininv (x, ones (1,5), 0.5), [NaN 0 1 Inf NaN]) +%!assert (nbininv (x, [1 0 NaN Inf 1], 0.5), [NaN NaN NaN NaN NaN]) +%!assert (nbininv (x, [1 0 1.5 Inf 1], 0.5), [NaN NaN 2 NaN NaN]) +%!assert (nbininv (x, 1, 0.5*[1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (nbininv ([x(1:2) NaN x(4:5)], 1, 0.5), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(nbininv ([x, NaN], 1, 0.5), [NaN 0 1 Inf NaN NaN]); -%!assert(nbininv (single([x, NaN]), 1, 0.5), single([NaN 0 1 Inf NaN NaN])); -%!assert(nbininv ([x, NaN], single(1), 0.5), single([NaN 0 1 Inf NaN NaN])); -%!assert(nbininv ([x, NaN], 1, single(0.5)), single([NaN 0 1 Inf NaN NaN])); +%!assert (nbininv ([x, NaN], 1, 0.5), [NaN 0 1 Inf NaN NaN]) +%!assert (nbininv (single ([x, NaN]), 1, 0.5), single ([NaN 0 1 Inf NaN NaN])) +%!assert (nbininv ([x, NaN], single (1), 0.5), single ([NaN 0 1 Inf NaN NaN])) +%!assert (nbininv ([x, NaN], 1, single (0.5)), single ([NaN 0 1 Inf NaN NaN])) %% Test input validation %!error nbininv () %!error nbininv (1) %!error nbininv (1,2) %!error nbininv (1,2,3,4) -%!error nbininv (ones(3),ones(2),ones(2)) -%!error nbininv (ones(2),ones(3),ones(2)) -%!error nbininv (ones(2),ones(2),ones(3)) +%!error nbininv (ones (3), ones (2), ones (2)) +%!error nbininv (ones (2), ones (3), ones (2)) +%!error nbininv (ones (2), ones (2), ones (3)) %!error nbininv (i, 2, 2) %!error nbininv (2, i, 2) %!error nbininv (2, 2, i)
--- a/scripts/statistics/distributions/nbinpdf.m +++ b/scripts/statistics/distributions/nbinpdf.m @@ -76,26 +76,26 @@ %!shared x,y %! x = [-1 0 1 2 Inf]; %! y = [0 1/2 1/4 1/8 NaN]; -%!assert(nbinpdf (x, ones(1,5), 0.5*ones(1,5)), y); -%!assert(nbinpdf (x, 1, 0.5*ones(1,5)), y); -%!assert(nbinpdf (x, ones(1,5), 0.5), y); -%!assert(nbinpdf (x, [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN 1.875*0.5^1.5/4 NaN], eps); -%!assert(nbinpdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]); -%!assert(nbinpdf ([x, NaN], 1, 0.5), [y, NaN]); +%!assert (nbinpdf (x, ones (1,5), 0.5*ones (1,5)), y) +%!assert (nbinpdf (x, 1, 0.5*ones (1,5)), y) +%!assert (nbinpdf (x, ones (1,5), 0.5), y) +%!assert (nbinpdf (x, [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN 1.875*0.5^1.5/4 NaN], eps) +%!assert (nbinpdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]) +%!assert (nbinpdf ([x, NaN], 1, 0.5), [y, NaN]) %% Test class of input preserved -%!assert(nbinpdf (single([x, NaN]), 1, 0.5), single([y, NaN])); -%!assert(nbinpdf ([x, NaN], single(1), 0.5), single([y, NaN])); -%!assert(nbinpdf ([x, NaN], 1, single(0.5)), single([y, NaN])); +%!assert (nbinpdf (single ([x, NaN]), 1, 0.5), single ([y, NaN])) +%!assert (nbinpdf ([x, NaN], single (1), 0.5), single ([y, NaN])) +%!assert (nbinpdf ([x, NaN], 1, single (0.5)), single ([y, NaN])) %% Test input validation %!error nbinpdf () %!error nbinpdf (1) %!error nbinpdf (1,2) %!error nbinpdf (1,2,3,4) -%!error nbinpdf (ones(3),ones(2),ones(2)) -%!error nbinpdf (ones(2),ones(3),ones(2)) -%!error nbinpdf (ones(2),ones(2),ones(3)) +%!error nbinpdf (ones (3), ones (2), ones (2)) +%!error nbinpdf (ones (2), ones (3), ones (2)) +%!error nbinpdf (ones (2), ones (2), ones (3)) %!error nbinpdf (i, 2, 2) %!error nbinpdf (2, i, 2) %!error nbinpdf (2, 2, i)
--- a/scripts/statistics/distributions/nbinrnd.m +++ b/scripts/statistics/distributions/nbinrnd.m @@ -106,35 +106,35 @@ endfunction -%!assert(size (nbinrnd (2, 1/2)), [1, 1]); -%!assert(size (nbinrnd (2*ones(2,1), 1/2)), [2, 1]); -%!assert(size (nbinrnd (2*ones(2,2), 1/2)), [2, 2]); -%!assert(size (nbinrnd (2, 1/2*ones(2,1))), [2, 1]); -%!assert(size (nbinrnd (2, 1/2*ones(2,2))), [2, 2]); -%!assert(size (nbinrnd (2, 1/2, 3)), [3, 3]); -%!assert(size (nbinrnd (2, 1/2, [4 1])), [4, 1]); -%!assert(size (nbinrnd (2, 1/2, 4, 1)), [4, 1]); +%!assert (size (nbinrnd (2, 1/2)), [1, 1]) +%!assert (size (nbinrnd (2*ones (2,1), 1/2)), [2, 1]) +%!assert (size (nbinrnd (2*ones (2,2), 1/2)), [2, 2]) +%!assert (size (nbinrnd (2, 1/2*ones (2,1))), [2, 1]) +%!assert (size (nbinrnd (2, 1/2*ones (2,2))), [2, 2]) +%!assert (size (nbinrnd (2, 1/2, 3)), [3, 3]) +%!assert (size (nbinrnd (2, 1/2, [4 1])), [4, 1]) +%!assert (size (nbinrnd (2, 1/2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (nbinrnd (2, 1/2)), "double"); -%!assert(class (nbinrnd (single(2), 1/2)), "single"); -%!assert(class (nbinrnd (single([2 2]), 1/2)), "single"); -%!assert(class (nbinrnd (2, single(1/2))), "single"); -%!assert(class (nbinrnd (2, single([1/2 1/2]))), "single"); +%!assert (class (nbinrnd (2, 1/2)), "double") +%!assert (class (nbinrnd (single (2), 1/2)), "single") +%!assert (class (nbinrnd (single ([2 2]), 1/2)), "single") +%!assert (class (nbinrnd (2, single (1/2))), "single") +%!assert (class (nbinrnd (2, single ([1/2 1/2]))), "single") %% Test input validation %!error nbinrnd () %!error nbinrnd (1) -%!error nbinrnd (ones(3),ones(2)) -%!error nbinrnd (ones(2),ones(3)) +%!error nbinrnd (ones (3), ones (2)) +%!error nbinrnd (ones (2), ones (3)) %!error nbinrnd (i, 2) %!error nbinrnd (2, i) %!error nbinrnd (1,2, -1) -%!error nbinrnd (1,2, ones(2)) +%!error nbinrnd (1,2, ones (2)) %!error nbinrnd (1, 2, [2 -1 2]) -%!error nbinrnd (1,2, 1, ones(2)) +%!error nbinrnd (1,2, 1, ones (2)) %!error nbinrnd (1,2, 1, -1) -%!error nbinrnd (ones(2,2), 2, 3) -%!error nbinrnd (ones(2,2), 2, [3, 2]) -%!error nbinrnd (ones(2,2), 2, 2, 3) +%!error nbinrnd (ones (2,2), 2, 3) +%!error nbinrnd (ones (2,2), 2, [3, 2]) +%!error nbinrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/normcdf.m +++ b/scripts/statistics/distributions/normcdf.m @@ -73,26 +73,26 @@ %!shared x,y %! x = [-Inf 1 2 Inf]; %! y = [0, 0.5, 1/2*(1+erf(1/sqrt(2))), 1]; -%!assert(normcdf (x, ones(1,4), ones(1,4)), y); -%!assert(normcdf (x, 1, ones(1,4)), y); -%!assert(normcdf (x, ones(1,4), 1), y); -%!assert(normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]); -%!assert(normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]); -%!assert(normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]); +%!assert (normcdf (x, ones (1,4), ones (1,4)), y) +%!assert (normcdf (x, 1, ones (1,4)), y) +%!assert (normcdf (x, ones (1,4), 1), y) +%!assert (normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]) +%!assert (normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) +%!assert (normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]) %% Test class of input preserved -%!assert(normcdf ([x, NaN], 1, 1), [y, NaN]); -%!assert(normcdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single")); -%!assert(normcdf ([x, NaN], single(1), 1), single([y, NaN]), eps("single")); -%!assert(normcdf ([x, NaN], 1, single(1)), single([y, NaN]), eps("single")); +%!assert (normcdf ([x, NaN], 1, 1), [y, NaN]) +%!assert (normcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) +%!assert (normcdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) +%!assert (normcdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error normcdf () %!error normcdf (1,2) %!error normcdf (1,2,3,4) -%!error normcdf (ones(3),ones(2),ones(2)) -%!error normcdf (ones(2),ones(3),ones(2)) -%!error normcdf (ones(2),ones(2),ones(3)) +%!error normcdf (ones (3), ones (2), ones (2)) +%!error normcdf (ones (2), ones (3), ones (2)) +%!error normcdf (ones (2), ones (2), ones (3)) %!error normcdf (i, 2, 2) %!error normcdf (2, i, 2) %!error normcdf (2, 2, i)
--- a/scripts/statistics/distributions/norminv.m +++ b/scripts/statistics/distributions/norminv.m @@ -67,26 +67,26 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(norminv (x, ones(1,5), ones(1,5)), [NaN -Inf 1 Inf NaN]); -%!assert(norminv (x, 1, ones(1,5)), [NaN -Inf 1 Inf NaN]); -%!assert(norminv (x, ones(1,5), 1), [NaN -Inf 1 Inf NaN]); -%!assert(norminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]); -%!assert(norminv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(norminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN -Inf NaN Inf NaN]); +%!assert (norminv (x, ones (1,5), ones (1,5)), [NaN -Inf 1 Inf NaN]) +%!assert (norminv (x, 1, ones (1,5)), [NaN -Inf 1 Inf NaN]) +%!assert (norminv (x, ones (1,5), 1), [NaN -Inf 1 Inf NaN]) +%!assert (norminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]) +%!assert (norminv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (norminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN -Inf NaN Inf NaN]) %% Test class of input preserved -%!assert(norminv ([x, NaN], 1, 1), [NaN -Inf 1 Inf NaN NaN]); -%!assert(norminv (single([x, NaN]), 1, 1), single([NaN -Inf 1 Inf NaN NaN])); -%!assert(norminv ([x, NaN], single(1), 1), single([NaN -Inf 1 Inf NaN NaN])); -%!assert(norminv ([x, NaN], 1, single(1)), single([NaN -Inf 1 Inf NaN NaN])); +%!assert (norminv ([x, NaN], 1, 1), [NaN -Inf 1 Inf NaN NaN]) +%!assert (norminv (single ([x, NaN]), 1, 1), single ([NaN -Inf 1 Inf NaN NaN])) +%!assert (norminv ([x, NaN], single (1), 1), single ([NaN -Inf 1 Inf NaN NaN])) +%!assert (norminv ([x, NaN], 1, single (1)), single ([NaN -Inf 1 Inf NaN NaN])) %% Test input validation %!error norminv () %!error norminv (1,2) %!error norminv (1,2,3,4) -%!error norminv (ones(3),ones(2),ones(2)) -%!error norminv (ones(2),ones(3),ones(2)) -%!error norminv (ones(2),ones(2),ones(3)) +%!error norminv (ones (3), ones (2), ones (2)) +%!error norminv (ones (2), ones (3), ones (2)) +%!error norminv (ones (2), ones (2), ones (3)) %!error norminv (i, 2, 2) %!error norminv (2, i, 2) %!error norminv (2, 2, i)
--- a/scripts/statistics/distributions/normpdf.m +++ b/scripts/statistics/distributions/normpdf.m @@ -73,25 +73,25 @@ %!shared x,y %! x = [-Inf 1 2 Inf]; %! y = 1/sqrt(2*pi)*exp (-(x-1).^2/2); -%!assert(normpdf (x, ones(1,4), ones(1,4)), y); -%!assert(normpdf (x, 1, ones(1,4)), y); -%!assert(normpdf (x, ones(1,4), 1), y); -%!assert(normpdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]); -%!assert(normpdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]); -%!assert(normpdf ([x, NaN], 1, 1), [y, NaN]); +%!assert (normpdf (x, ones (1,4), ones (1,4)), y) +%!assert (normpdf (x, 1, ones (1,4)), y) +%!assert (normpdf (x, ones (1,4), 1), y) +%!assert (normpdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]) +%!assert (normpdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) +%!assert (normpdf ([x, NaN], 1, 1), [y, NaN]) %% Test class of input preserved -%!assert(normpdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single")); -%!assert(normpdf ([x, NaN], single(1), 1), single([y, NaN]), eps("single")); -%!assert(normpdf ([x, NaN], 1, single(1)), single([y, NaN]), eps("single")); +%!assert (normpdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) +%!assert (normpdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) +%!assert (normpdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error normpdf () %!error normpdf (1,2) %!error normpdf (1,2,3,4) -%!error normpdf (ones(3),ones(2),ones(2)) -%!error normpdf (ones(2),ones(3),ones(2)) -%!error normpdf (ones(2),ones(2),ones(3)) +%!error normpdf (ones (3), ones (2), ones (2)) +%!error normpdf (ones (2), ones (3), ones (2)) +%!error normpdf (ones (2), ones (2), ones (3)) %!error normpdf (i, 2, 2) %!error normpdf (2, i, 2) %!error normpdf (2, 2, i)
--- a/scripts/statistics/distributions/normrnd.m +++ b/scripts/statistics/distributions/normrnd.m @@ -97,35 +97,35 @@ endfunction -%!assert(size (normrnd (1,2)), [1, 1]); -%!assert(size (normrnd (ones(2,1), 2)), [2, 1]); -%!assert(size (normrnd (ones(2,2), 2)), [2, 2]); -%!assert(size (normrnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (normrnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (normrnd (1, 2, 3)), [3, 3]); -%!assert(size (normrnd (1, 2, [4 1])), [4, 1]); -%!assert(size (normrnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (normrnd (1,2)), [1, 1]) +%!assert (size (normrnd (ones (2,1), 2)), [2, 1]) +%!assert (size (normrnd (ones (2,2), 2)), [2, 2]) +%!assert (size (normrnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (normrnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (normrnd (1, 2, 3)), [3, 3]) +%!assert (size (normrnd (1, 2, [4 1])), [4, 1]) +%!assert (size (normrnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (normrnd (1, 2)), "double"); -%!assert(class (normrnd (single(1), 2)), "single"); -%!assert(class (normrnd (single([1 1]), 2)), "single"); -%!assert(class (normrnd (1, single(2))), "single"); -%!assert(class (normrnd (1, single([2 2]))), "single"); +%!assert (class (normrnd (1, 2)), "double") +%!assert (class (normrnd (single (1), 2)), "single") +%!assert (class (normrnd (single ([1 1]), 2)), "single") +%!assert (class (normrnd (1, single (2))), "single") +%!assert (class (normrnd (1, single ([2 2]))), "single") %% Test input validation %!error normrnd () %!error normrnd (1) -%!error normrnd (ones(3),ones(2)) -%!error normrnd (ones(2),ones(3)) +%!error normrnd (ones (3), ones (2)) +%!error normrnd (ones (2), ones (3)) %!error normrnd (i, 2) %!error normrnd (2, i) %!error normrnd (1,2, -1) -%!error normrnd (1,2, ones(2)) +%!error normrnd (1,2, ones (2)) %!error normrnd (1, 2, [2 -1 2]) -%!error normrnd (1,2, 1, ones(2)) +%!error normrnd (1,2, 1, ones (2)) %!error normrnd (1,2, 1, -1) -%!error normrnd (ones(2,2), 2, 3) -%!error normrnd (ones(2,2), 2, [3, 2]) -%!error normrnd (ones(2,2), 2, 2, 3) +%!error normrnd (ones (2,2), 2, 3) +%!error normrnd (ones (2,2), 2, [3, 2]) +%!error normrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/poisscdf.m +++ b/scripts/statistics/distributions/poisscdf.m @@ -68,23 +68,23 @@ %!shared x,y %! x = [-1 0 1 2 Inf]; -%! y = [0, gammainc(1, (x(2:4) +1), 'upper'), 1]; -%!assert(poisscdf (x, ones(1,5)), y); -%!assert(poisscdf (x, 1), y); -%!assert(poisscdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]); -%!assert(poisscdf ([x(1:2) NaN Inf x(5)], 1), [y(1:2) NaN 1 y(5)]); +%! y = [0, gammainc(1, (x(2:4) +1), "upper"), 1]; +%!assert (poisscdf (x, ones (1,5)), y) +%!assert (poisscdf (x, 1), y) +%!assert (poisscdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) +%!assert (poisscdf ([x(1:2) NaN Inf x(5)], 1), [y(1:2) NaN 1 y(5)]) %% Test class of input preserved -%!assert(poisscdf ([x, NaN], 1), [y, NaN]); -%!assert(poisscdf (single([x, NaN]), 1), single([y, NaN]), eps("single")); -%!assert(poisscdf ([x, NaN], single(1)), single([y, NaN]), eps("single")); +%!assert (poisscdf ([x, NaN], 1), [y, NaN]) +%!assert (poisscdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) +%!assert (poisscdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error poisscdf () %!error poisscdf (1) %!error poisscdf (1,2,3) -%!error poisscdf (ones(3),ones(2)) -%!error poisscdf (ones(2),ones(3)) +%!error poisscdf (ones (3), ones (2)) +%!error poisscdf (ones (2), ones (3)) %!error poisscdf (i, 2) %!error poisscdf (2, i)
--- a/scripts/statistics/distributions/poissinv.m +++ b/scripts/statistics/distributions/poissinv.m @@ -82,22 +82,22 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(poissinv (x, ones(1,5)), [NaN 0 1 Inf NaN]); -%!assert(poissinv (x, 1), [NaN 0 1 Inf NaN]); -%!assert(poissinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN]); -%!assert(poissinv ([x(1:2) NaN x(4:5)], 1), [NaN 0 NaN Inf NaN]); +%!assert (poissinv (x, ones (1,5)), [NaN 0 1 Inf NaN]) +%!assert (poissinv (x, 1), [NaN 0 1 Inf NaN]) +%!assert (poissinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN]) +%!assert (poissinv ([x(1:2) NaN x(4:5)], 1), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(poissinv ([x, NaN], 1), [NaN 0 1 Inf NaN NaN]); -%!assert(poissinv (single([x, NaN]), 1), single([NaN 0 1 Inf NaN NaN])); -%!assert(poissinv ([x, NaN], single(1)), single([NaN 0 1 Inf NaN NaN])); +%!assert (poissinv ([x, NaN], 1), [NaN 0 1 Inf NaN NaN]) +%!assert (poissinv (single ([x, NaN]), 1), single ([NaN 0 1 Inf NaN NaN])) +%!assert (poissinv ([x, NaN], single (1)), single ([NaN 0 1 Inf NaN NaN])) %% Test input validation %!error poissinv () %!error poissinv (1) %!error poissinv (1,2,3) -%!error poissinv (ones(3),ones(2)) -%!error poissinv (ones(2),ones(3)) +%!error poissinv (ones (3), ones (2)) +%!error poissinv (ones (2), ones (3)) %!error poissinv (i, 2) %!error poissinv (2, i)
--- a/scripts/statistics/distributions/poisspdf.m +++ b/scripts/statistics/distributions/poisspdf.m @@ -65,21 +65,21 @@ %!shared x,y %! x = [-1 0 1 2 Inf]; %! y = [0, exp(-1)*[1 1 0.5], 0]; -%!assert(poisspdf (x, ones(1,5)), y, eps); -%!assert(poisspdf (x, 1), y, eps); -%!assert(poisspdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps); -%!assert(poisspdf ([x, NaN], 1), [y, NaN], eps); +%!assert (poisspdf (x, ones (1,5)), y, eps) +%!assert (poisspdf (x, 1), y, eps) +%!assert (poisspdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps) +%!assert (poisspdf ([x, NaN], 1), [y, NaN], eps) %% Test class of input preserved -%!assert(poisspdf (single([x, NaN]), 1), single([y, NaN]), eps("single")); -%!assert(poisspdf ([x, NaN], single(1)), single([y, NaN]), eps("single")); +%!assert (poisspdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) +%!assert (poisspdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error poisspdf () %!error poisspdf (1) %!error poisspdf (1,2,3) -%!error poisspdf (ones(3),ones(2)) -%!error poisspdf (ones(2),ones(3)) +%!error poisspdf (ones (3), ones (2)) +%!error poisspdf (ones (2), ones (3)) %!error poisspdf (i, 2) %!error poisspdf (2, i)
--- a/scripts/statistics/distributions/poissrnd.m +++ b/scripts/statistics/distributions/poissrnd.m @@ -94,27 +94,27 @@ endfunction -%!assert(size (poissrnd (2)), [1, 1]); -%!assert(size (poissrnd (ones(2,1))), [2, 1]); -%!assert(size (poissrnd (ones(2,2))), [2, 2]); -%!assert(size (poissrnd (1, 3)), [3, 3]); -%!assert(size (poissrnd (1, [4 1])), [4, 1]); -%!assert(size (poissrnd (1, 4, 1)), [4, 1]); +%!assert (size (poissrnd (2)), [1, 1]) +%!assert (size (poissrnd (ones (2,1))), [2, 1]) +%!assert (size (poissrnd (ones (2,2))), [2, 2]) +%!assert (size (poissrnd (1, 3)), [3, 3]) +%!assert (size (poissrnd (1, [4 1])), [4, 1]) +%!assert (size (poissrnd (1, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (poissrnd (2)), "double"); -%!assert(class (poissrnd (single(2))), "single"); -%!assert(class (poissrnd (single([2 2]))), "single"); +%!assert (class (poissrnd (2)), "double") +%!assert (class (poissrnd (single (2))), "single") +%!assert (class (poissrnd (single ([2 2]))), "single") %% Test input validation %!error poissrnd () %!error poissrnd (1, -1) -%!error poissrnd (1, ones(2)) -%!error poissrnd (1, 2, ones(2)) +%!error poissrnd (1, ones (2)) +%!error poissrnd (1, 2, ones (2)) %!error poissrnd (i) %!error poissrnd (1, 2, -1) %!error poissrnd (1, [2 -1 2]) -%!error poissrnd (ones(2,2), 3) -%!error poissrnd (ones(2,2), [3, 2]) -%!error poissrnd (ones(2,2), 2, 3) +%!error poissrnd (ones (2,2), 3) +%!error poissrnd (ones (2,2), [3, 2]) +%!error poissrnd (ones (2,2), 2, 3)
--- a/scripts/statistics/distributions/stdnormal_cdf.m +++ b/scripts/statistics/distributions/stdnormal_cdf.m @@ -45,10 +45,10 @@ %!shared x,y %! x = [-Inf 0 1 Inf]; %! y = [0, 0.5, 1/2*(1+erf(1/sqrt(2))), 1]; -%!assert(stdnormal_cdf ([x, NaN]), [y, NaN]); +%!assert (stdnormal_cdf ([x, NaN]), [y, NaN]) %% Test class of input preserved -%!assert(stdnormal_cdf (single([x, NaN])), single([y, NaN]), eps("single")); +%!assert (stdnormal_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) %% Test input validation %!error stdnormal_cdf ()
--- a/scripts/statistics/distributions/stdnormal_inv.m +++ b/scripts/statistics/distributions/stdnormal_inv.m @@ -44,11 +44,11 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(stdnormal_inv (x), [NaN -Inf 0 Inf NaN]); +%!assert (stdnormal_inv (x), [NaN -Inf 0 Inf NaN]) %% Test class of input preserved -%!assert(stdnormal_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]); -%!assert(stdnormal_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN])); +%!assert (stdnormal_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) +%!assert (stdnormal_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) %% Test input validation %!error stdnormal_inv ()
--- a/scripts/statistics/distributions/stdnormal_pdf.m +++ b/scripts/statistics/distributions/stdnormal_pdf.m @@ -45,10 +45,10 @@ %!shared x,y %! x = [-Inf 0 1 Inf]; %! y = 1/sqrt(2*pi)*exp (-x.^2/2); -%!assert(stdnormal_pdf ([x, NaN]), [y, NaN], eps); +%!assert (stdnormal_pdf ([x, NaN]), [y, NaN], eps) %% Test class of input preserved -%!assert(stdnormal_pdf (single([x, NaN])), single([y, NaN]), eps("single")); +%!assert (stdnormal_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) %% Test input validation %!error stdnormal_pdf ()
--- a/scripts/statistics/distributions/stdnormal_rnd.m +++ b/scripts/statistics/distributions/stdnormal_rnd.m @@ -60,15 +60,15 @@ endfunction -%!assert(size (stdnormal_rnd (3)), [3, 3]); -%!assert(size (stdnormal_rnd ([4 1])), [4, 1]); -%!assert(size (stdnormal_rnd (4,1)), [4, 1]); +%!assert (size (stdnormal_rnd (3)), [3, 3]) +%!assert (size (stdnormal_rnd ([4 1])), [4, 1]) +%!assert (size (stdnormal_rnd (4,1)), [4, 1]) %% Test input validation %!error stdnormal_rnd () %!error stdnormal_rnd (-1) -%!error stdnormal_rnd (ones(2)) +%!error stdnormal_rnd (ones (2)) %!error stdnormal_rnd ([2 -1 2]) -%!error stdnormal_rnd (1, ones(2)) +%!error stdnormal_rnd (1, ones (2)) %!error stdnormal_rnd (1, -1)
--- a/scripts/statistics/distributions/tcdf.m +++ b/scripts/statistics/distributions/tcdf.m @@ -73,22 +73,22 @@ %!shared x,y %! x = [-Inf 0 1 Inf]; %! y = [0 1/2 3/4 1]; -%!assert(tcdf (x, ones(1,4)), y, eps); -%!assert(tcdf (x, 1), y, eps); -%!assert(tcdf (x, [0 1 NaN 1]), [NaN 1/2 NaN 1], eps); -%!assert(tcdf ([x(1:2) NaN x(4)], 1), [y(1:2) NaN y(4)], eps); +%!assert (tcdf (x, ones (1,4)), y, eps) +%!assert (tcdf (x, 1), y, eps) +%!assert (tcdf (x, [0 1 NaN 1]), [NaN 1/2 NaN 1], eps) +%!assert (tcdf ([x(1:2) NaN x(4)], 1), [y(1:2) NaN y(4)], eps) %% Test class of input preserved -%!assert(tcdf ([x, NaN], 1), [y, NaN], eps); -%!assert(tcdf (single([x, NaN]), 1), single([y, NaN]), eps("single")); -%!assert(tcdf ([x, NaN], single(1)), single([y, NaN]), eps("single")); +%!assert (tcdf ([x, NaN], 1), [y, NaN], eps) +%!assert (tcdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) +%!assert (tcdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error tcdf () %!error tcdf (1) %!error tcdf (1,2,3) -%!error tcdf (ones(3),ones(2)) -%!error tcdf (ones(2),ones(3)) +%!error tcdf (ones (3), ones (2)) +%!error tcdf (ones (2), ones (3)) %!error tcdf (i, 2) %!error tcdf (2, i)
--- a/scripts/statistics/distributions/tinv.m +++ b/scripts/statistics/distributions/tinv.m @@ -87,22 +87,22 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(tinv (x, ones(1,5)), [NaN -Inf 0 Inf NaN]); -%!assert(tinv (x, 1), [NaN -Inf 0 Inf NaN], eps); -%!assert(tinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps); -%!assert(tinv ([x(1:2) NaN x(4:5)], 1), [NaN -Inf NaN Inf NaN]); +%!assert (tinv (x, ones (1,5)), [NaN -Inf 0 Inf NaN]) +%!assert (tinv (x, 1), [NaN -Inf 0 Inf NaN], eps) +%!assert (tinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps) +%!assert (tinv ([x(1:2) NaN x(4:5)], 1), [NaN -Inf NaN Inf NaN]) %% Test class of input preserved -%!assert(tinv ([x, NaN], 1), [NaN -Inf 0 Inf NaN NaN], eps); -%!assert(tinv (single([x, NaN]), 1), single([NaN -Inf 0 Inf NaN NaN]), eps("single")); -%!assert(tinv ([x, NaN], single(1)), single([NaN -Inf 0 Inf NaN NaN]), eps("single")); +%!assert (tinv ([x, NaN], 1), [NaN -Inf 0 Inf NaN NaN], eps) +%!assert (tinv (single ([x, NaN]), 1), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single")) +%!assert (tinv ([x, NaN], single (1)), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single")) %% Test input validation %!error tinv () %!error tinv (1) %!error tinv (1,2,3) -%!error tinv (ones(3),ones(2)) -%!error tinv (ones(2),ones(3)) +%!error tinv (ones (3), ones (2)) +%!error tinv (ones (2), ones (3)) %!error tinv (i, 2) %!error tinv (2, i)
--- a/scripts/statistics/distributions/tpdf.m +++ b/scripts/statistics/distributions/tpdf.m @@ -68,26 +68,26 @@ %!test %! x = rand (10,1); %! y = 1./(pi * (1 + x.^2)); -%! assert(tpdf (x, 1), y, 5*eps); +%! assert (tpdf (x, 1), y, 5*eps); %!shared x,y %! x = [-Inf 0 0.5 1 Inf]; %! y = 1./(pi * (1 + x.^2)); -%!assert(tpdf (x, ones(1,5)), y, eps); -%!assert(tpdf (x, 1), y, eps); -%!assert(tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps); +%!assert (tpdf (x, ones (1,5)), y, eps) +%!assert (tpdf (x, 1), y, eps) +%!assert (tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps) %% Test class of input preserved -%!assert(tpdf ([x, NaN], 1), [y, NaN], eps); -%!assert(tpdf (single([x, NaN]), 1), single([y, NaN]), eps("single")); -%!assert(tpdf ([x, NaN], single(1)), single([y, NaN]), eps("single")); +%!assert (tpdf ([x, NaN], 1), [y, NaN], eps) +%!assert (tpdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) +%!assert (tpdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) %% Test input validation %!error tpdf () %!error tpdf (1) %!error tpdf (1,2,3) -%!error tpdf (ones(3),ones(2)) -%!error tpdf (ones(2),ones(3)) +%!error tpdf (ones (3), ones (2)) +%!error tpdf (ones (2), ones (3)) %!error tpdf (i, 2) %!error tpdf (2, i)
--- a/scripts/statistics/distributions/trnd.m +++ b/scripts/statistics/distributions/trnd.m @@ -91,27 +91,27 @@ endfunction -%!assert(size (trnd (2)), [1, 1]); -%!assert(size (trnd (ones(2,1))), [2, 1]); -%!assert(size (trnd (ones(2,2))), [2, 2]); -%!assert(size (trnd (1, 3)), [3, 3]); -%!assert(size (trnd (1, [4 1])), [4, 1]); -%!assert(size (trnd (1, 4, 1)), [4, 1]); +%!assert (size (trnd (2)), [1, 1]) +%!assert (size (trnd (ones (2,1))), [2, 1]) +%!assert (size (trnd (ones (2,2))), [2, 2]) +%!assert (size (trnd (1, 3)), [3, 3]) +%!assert (size (trnd (1, [4 1])), [4, 1]) +%!assert (size (trnd (1, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (trnd (1)), "double"); -%!assert(class (trnd (single(1))), "single"); -%!assert(class (trnd (single([1 1]))), "single"); +%!assert (class (trnd (1)), "double") +%!assert (class (trnd (single (1))), "single") +%!assert (class (trnd (single ([1 1]))), "single") %% Test input validation %!error trnd () %!error trnd (1, -1) -%!error trnd (1, ones(2)) +%!error trnd (1, ones (2)) %!error trnd (i) %!error trnd (1, [2 -1 2]) -%!error trnd (1, 2, ones(2)) +%!error trnd (1, 2, ones (2)) %!error trnd (1, 2, -1) -%!error trnd (ones(2,2), 3) -%!error trnd (ones(2,2), [3, 2]) -%!error trnd (ones(2,2), 2, 3) +%!error trnd (ones (2,2), 3) +%!error trnd (ones (2,2), [3, 2]) +%!error trnd (ones (2,2), 2, 3)
--- a/scripts/statistics/distributions/unidcdf.m +++ b/scripts/statistics/distributions/unidcdf.m @@ -68,22 +68,22 @@ %!shared x,y %! x = [0 1 2.5 10 11]; %! y = [0, 0.1 0.2 1.0 1.0]; -%!assert(unidcdf (x, 10*ones(1,5)), y); -%!assert(unidcdf (x, 10), y); -%!assert(unidcdf (x, 10*[0 1 NaN 1 1]), [NaN 0.1 NaN y(4:5)]); -%!assert(unidcdf ([x(1:2) NaN Inf x(5)], 10), [y(1:2) NaN 1 y(5)]); +%!assert (unidcdf (x, 10*ones (1,5)), y) +%!assert (unidcdf (x, 10), y) +%!assert (unidcdf (x, 10*[0 1 NaN 1 1]), [NaN 0.1 NaN y(4:5)]) +%!assert (unidcdf ([x(1:2) NaN Inf x(5)], 10), [y(1:2) NaN 1 y(5)]) %% Test class of input preserved -%!assert(unidcdf ([x, NaN], 10), [y, NaN]); -%!assert(unidcdf (single([x, NaN]), 10), single([y, NaN])); -%!assert(unidcdf ([x, NaN], single(10)), single([y, NaN])); +%!assert (unidcdf ([x, NaN], 10), [y, NaN]) +%!assert (unidcdf (single ([x, NaN]), 10), single ([y, NaN])) +%!assert (unidcdf ([x, NaN], single (10)), single ([y, NaN])) %% Test input validation %!error unidcdf () %!error unidcdf (1) %!error unidcdf (1,2,3) -%!error unidcdf (ones(3),ones(2)) -%!error unidcdf (ones(2),ones(3)) +%!error unidcdf (ones (3), ones (2)) +%!error unidcdf (ones (2), ones (3)) %!error unidcdf (i, 2) %!error unidcdf (2, i)
--- a/scripts/statistics/distributions/unidinv.m +++ b/scripts/statistics/distributions/unidinv.m @@ -60,22 +60,22 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(unidinv (x, 10*ones(1,5)), [NaN NaN 5 10 NaN], eps); -%!assert(unidinv (x, 10), [NaN NaN 5 10 NaN], eps); -%!assert(unidinv (x, 10*[0 1 NaN 1 1]), [NaN NaN NaN 10 NaN], eps); -%!assert(unidinv ([x(1:2) NaN x(4:5)], 10), [NaN NaN NaN 10 NaN], eps); +%!assert (unidinv (x, 10*ones (1,5)), [NaN NaN 5 10 NaN], eps) +%!assert (unidinv (x, 10), [NaN NaN 5 10 NaN], eps) +%!assert (unidinv (x, 10*[0 1 NaN 1 1]), [NaN NaN NaN 10 NaN], eps) +%!assert (unidinv ([x(1:2) NaN x(4:5)], 10), [NaN NaN NaN 10 NaN], eps) %% Test class of input preserved -%!assert(unidinv ([x, NaN], 10), [NaN NaN 5 10 NaN NaN], eps); -%!assert(unidinv (single([x, NaN]), 10), single([NaN NaN 5 10 NaN NaN]), eps); -%!assert(unidinv ([x, NaN], single(10)), single([NaN NaN 5 10 NaN NaN]), eps); +%!assert (unidinv ([x, NaN], 10), [NaN NaN 5 10 NaN NaN], eps) +%!assert (unidinv (single ([x, NaN]), 10), single ([NaN NaN 5 10 NaN NaN]), eps) +%!assert (unidinv ([x, NaN], single (10)), single ([NaN NaN 5 10 NaN NaN]), eps) %% Test input validation %!error unidinv () %!error unidinv (1) %!error unidinv (1,2,3) -%!error unidinv (ones(3),ones(2)) -%!error unidinv (ones(2),ones(3)) +%!error unidinv (ones (3), ones (2)) +%!error unidinv (ones (2), ones (3)) %!error unidinv (i, 2) %!error unidinv (2, i)
--- a/scripts/statistics/distributions/unidpdf.m +++ b/scripts/statistics/distributions/unidpdf.m @@ -67,21 +67,21 @@ %!shared x,y %! x = [-1 0 1 2 10 11]; %! y = [0 0 0.1 0.1 0.1 0]; -%!assert(unidpdf (x, 10*ones(1,6)), y); -%!assert(unidpdf (x, 10), y); -%!assert(unidpdf (x, 10*[0 NaN 1 1 1 1]), [NaN NaN y(3:6)]); -%!assert(unidpdf ([x, NaN], 10), [y, NaN]); +%!assert (unidpdf (x, 10*ones (1,6)), y) +%!assert (unidpdf (x, 10), y) +%!assert (unidpdf (x, 10*[0 NaN 1 1 1 1]), [NaN NaN y(3:6)]) +%!assert (unidpdf ([x, NaN], 10), [y, NaN]) %% Test class of input preserved -%!assert(unidpdf (single([x, NaN]), 10), single([y, NaN])); -%!assert(unidpdf ([x, NaN], single(10)), single([y, NaN])); +%!assert (unidpdf (single ([x, NaN]), 10), single ([y, NaN])) +%!assert (unidpdf ([x, NaN], single (10)), single ([y, NaN])) %% Test input validation %!error unidpdf () %!error unidpdf (1) %!error unidpdf (1,2,3) -%!error unidpdf (ones(3),ones(2)) -%!error unidpdf (ones(2),ones(3)) +%!error unidpdf (ones (3), ones (2)) +%!error unidpdf (ones (2), ones (3)) %!error unidpdf (i, 2) %!error unidpdf (2, i)
--- a/scripts/statistics/distributions/unidrnd.m +++ b/scripts/statistics/distributions/unidrnd.m @@ -91,21 +91,21 @@ endfunction -%!assert(size (unidrnd (2)), [1, 1]); -%!assert(size (unidrnd (ones(2,1))), [2, 1]); -%!assert(size (unidrnd (ones(2,2))), [2, 2]); -%!assert(size (unidrnd (10, [4 1])), [4, 1]); -%!assert(size (unidrnd (10, 4, 1)), [4, 1]); +%!assert (size (unidrnd (2)), [1, 1]) +%!assert (size (unidrnd (ones (2,1))), [2, 1]) +%!assert (size (unidrnd (ones (2,2))), [2, 2]) +%!assert (size (unidrnd (10, [4 1])), [4, 1]) +%!assert (size (unidrnd (10, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (unidrnd (2)), "double"); -%!assert(class (unidrnd (single(2))), "single"); -%!assert(class (unidrnd (single([2 2]))), "single"); +%!assert (class (unidrnd (2)), "double") +%!assert (class (unidrnd (single (2))), "single") +%!assert (class (unidrnd (single ([2 2]))), "single") %% Test input validation %!error unidrnd () %!error unidrnd (10, [1;2;3]) -%!error unidrnd (10, 2, ones(2)) -%!error unidrnd (10*ones(2), 2, 1) +%!error unidrnd (10, 2, ones (2)) +%!error unidrnd (10*ones (2), 2, 1) %!error unidrnd (i)
--- a/scripts/statistics/distributions/unifcdf.m +++ b/scripts/statistics/distributions/unifcdf.m @@ -72,26 +72,26 @@ %!shared x,y %! x = [-1 0 0.5 1 2] + 1; %! y = [0 0 0.5 1 1]; -%!assert(unifcdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(unifcdf (x, 1, 2*ones(1,5)), y); -%!assert(unifcdf (x, ones(1,5), 2), y); -%!assert(unifcdf (x, [2 1 NaN 1 1], 2), [NaN 0 NaN 1 1]); -%!assert(unifcdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]); -%!assert(unifcdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]); +%!assert (unifcdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (unifcdf (x, 1, 2*ones (1,5)), y) +%!assert (unifcdf (x, ones (1,5), 2), y) +%!assert (unifcdf (x, [2 1 NaN 1 1], 2), [NaN 0 NaN 1 1]) +%!assert (unifcdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]) +%!assert (unifcdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(unifcdf ([x, NaN], 1, 2), [y, NaN]); -%!assert(unifcdf (single([x, NaN]), 1, 2), single([y, NaN])); -%!assert(unifcdf ([x, NaN], single(1), 2), single([y, NaN])); -%!assert(unifcdf ([x, NaN], 1, single(2)), single([y, NaN])); +%!assert (unifcdf ([x, NaN], 1, 2), [y, NaN]) +%!assert (unifcdf (single ([x, NaN]), 1, 2), single ([y, NaN])) +%!assert (unifcdf ([x, NaN], single (1), 2), single ([y, NaN])) +%!assert (unifcdf ([x, NaN], 1, single (2)), single ([y, NaN])) %% Test input validation %!error unifcdf () %!error unifcdf (1,2) %!error unifcdf (1,2,3,4) -%!error unifcdf (ones(3),ones(2),ones(2)) -%!error unifcdf (ones(2),ones(3),ones(2)) -%!error unifcdf (ones(2),ones(2),ones(3)) +%!error unifcdf (ones (3), ones (2), ones (2)) +%!error unifcdf (ones (2), ones (3), ones (2)) +%!error unifcdf (ones (2), ones (2), ones (3)) %!error unifcdf (i, 2, 2) %!error unifcdf (2, i, 2) %!error unifcdf (2, 2, i)
--- a/scripts/statistics/distributions/unifinv.m +++ b/scripts/statistics/distributions/unifinv.m @@ -65,26 +65,26 @@ %!shared x %! x = [-1 0 0.5 1 2]; -%!assert(unifinv (x, ones(1,5), 2*ones(1,5)), [NaN 1 1.5 2 NaN]); -%!assert(unifinv (x, 1, 2*ones(1,5)), [NaN 1 1.5 2 NaN]); -%!assert(unifinv (x, ones(1,5), 2), [NaN 1 1.5 2 NaN]); -%!assert(unifinv (x, [1 2 NaN 1 1], 2), [NaN NaN NaN 2 NaN]); -%!assert(unifinv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 2 NaN]); -%!assert(unifinv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 1 NaN 2 NaN]); +%!assert (unifinv (x, ones (1,5), 2*ones (1,5)), [NaN 1 1.5 2 NaN]) +%!assert (unifinv (x, 1, 2*ones (1,5)), [NaN 1 1.5 2 NaN]) +%!assert (unifinv (x, ones (1,5), 2), [NaN 1 1.5 2 NaN]) +%!assert (unifinv (x, [1 2 NaN 1 1], 2), [NaN NaN NaN 2 NaN]) +%!assert (unifinv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 2 NaN]) +%!assert (unifinv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 1 NaN 2 NaN]) %% Test class of input preserved -%!assert(unifinv ([x, NaN], 1, 2), [NaN 1 1.5 2 NaN NaN]); -%!assert(unifinv (single([x, NaN]), 1, 2), single([NaN 1 1.5 2 NaN NaN])); -%!assert(unifinv ([x, NaN], single(1), 2), single([NaN 1 1.5 2 NaN NaN])); -%!assert(unifinv ([x, NaN], 1, single(2)), single([NaN 1 1.5 2 NaN NaN])); +%!assert (unifinv ([x, NaN], 1, 2), [NaN 1 1.5 2 NaN NaN]) +%!assert (unifinv (single ([x, NaN]), 1, 2), single ([NaN 1 1.5 2 NaN NaN])) +%!assert (unifinv ([x, NaN], single (1), 2), single ([NaN 1 1.5 2 NaN NaN])) +%!assert (unifinv ([x, NaN], 1, single (2)), single ([NaN 1 1.5 2 NaN NaN])) %% Test input validation %!error unifinv () %!error unifinv (1,2) %!error unifinv (1,2,3,4) -%!error unifinv (ones(3),ones(2),ones(2)) -%!error unifinv (ones(2),ones(3),ones(2)) -%!error unifinv (ones(2),ones(2),ones(3)) +%!error unifinv (ones (3), ones (2), ones (2)) +%!error unifinv (ones (2), ones (3), ones (2)) +%!error unifinv (ones (2), ones (2), ones (3)) %!error unifinv (i, 2, 2) %!error unifinv (2, i, 2) %!error unifinv (2, 2, i)
--- a/scripts/statistics/distributions/unifpdf.m +++ b/scripts/statistics/distributions/unifpdf.m @@ -68,25 +68,25 @@ %!shared x,y %! x = [-1 0 0.5 1 2] + 1; %! y = [0 1 1 1 0]; -%!assert(unifpdf (x, ones(1,5), 2*ones(1,5)), y); -%!assert(unifpdf (x, 1, 2*ones(1,5)), y); -%!assert(unifpdf (x, ones(1,5), 2), y); -%!assert(unifpdf (x, [2 NaN 1 1 1], 2), [NaN NaN y(3:5)]); -%!assert(unifpdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]); -%!assert(unifpdf ([x, NaN], 1, 2), [y, NaN]); +%!assert (unifpdf (x, ones (1,5), 2*ones (1,5)), y) +%!assert (unifpdf (x, 1, 2*ones (1,5)), y) +%!assert (unifpdf (x, ones (1,5), 2), y) +%!assert (unifpdf (x, [2 NaN 1 1 1], 2), [NaN NaN y(3:5)]) +%!assert (unifpdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]) +%!assert (unifpdf ([x, NaN], 1, 2), [y, NaN]) %% Test class of input preserved -%!assert(unifpdf (single([x, NaN]), 1, 2), single([y, NaN])); -%!assert(unifpdf (single([x, NaN]), single(1), 2), single([y, NaN])); -%!assert(unifpdf ([x, NaN], 1, single(2)), single([y, NaN])); +%!assert (unifpdf (single ([x, NaN]), 1, 2), single ([y, NaN])) +%!assert (unifpdf (single ([x, NaN]), single (1), 2), single ([y, NaN])) +%!assert (unifpdf ([x, NaN], 1, single (2)), single ([y, NaN])) %% Test input validation %!error unifpdf () %!error unifpdf (1,2) %!error unifpdf (1,2,3,4) -%!error unifpdf (ones(3),ones(2),ones(2)) -%!error unifpdf (ones(2),ones(3),ones(2)) -%!error unifpdf (ones(2),ones(2),ones(3)) +%!error unifpdf (ones (3), ones (2), ones (2)) +%!error unifpdf (ones (2), ones (3), ones (2)) +%!error unifpdf (ones (2), ones (2), ones (3)) %!error unifpdf (i, 2, 2) %!error unifpdf (2, i, 2) %!error unifpdf (2, 2, i)
--- a/scripts/statistics/distributions/unifrnd.m +++ b/scripts/statistics/distributions/unifrnd.m @@ -98,35 +98,35 @@ endfunction -%!assert(size (unifrnd (1,2)), [1, 1]); -%!assert(size (unifrnd (ones(2,1), 2)), [2, 1]); -%!assert(size (unifrnd (ones(2,2), 2)), [2, 2]); -%!assert(size (unifrnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (unifrnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (unifrnd (1, 2, 3)), [3, 3]); -%!assert(size (unifrnd (1, 2, [4 1])), [4, 1]); -%!assert(size (unifrnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (unifrnd (1,2)), [1, 1]) +%!assert (size (unifrnd (ones (2,1), 2)), [2, 1]) +%!assert (size (unifrnd (ones (2,2), 2)), [2, 2]) +%!assert (size (unifrnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (unifrnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (unifrnd (1, 2, 3)), [3, 3]) +%!assert (size (unifrnd (1, 2, [4 1])), [4, 1]) +%!assert (size (unifrnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (unifrnd (1, 2)), "double"); -%!assert(class (unifrnd (single(1), 2)), "single"); -%!assert(class (unifrnd (single([1 1]), 2)), "single"); -%!assert(class (unifrnd (1, single(2))), "single"); -%!assert(class (unifrnd (1, single([2 2]))), "single"); +%!assert (class (unifrnd (1, 2)), "double") +%!assert (class (unifrnd (single (1), 2)), "single") +%!assert (class (unifrnd (single ([1 1]), 2)), "single") +%!assert (class (unifrnd (1, single (2))), "single") +%!assert (class (unifrnd (1, single ([2 2]))), "single") %% Test input validation %!error unifrnd () %!error unifrnd (1) -%!error unifrnd (ones(3),ones(2)) -%!error unifrnd (ones(2),ones(3)) +%!error unifrnd (ones (3), ones (2)) +%!error unifrnd (ones (2), ones (3)) %!error unifrnd (i, 2) %!error unifrnd (2, i) %!error unifrnd (1,2, -1) -%!error unifrnd (1,2, ones(2)) +%!error unifrnd (1,2, ones (2)) %!error unifrnd (1, 2, [2 -1 2]) -%!error unifrnd (1,2, 1, ones(2)) +%!error unifrnd (1,2, 1, ones (2)) %!error unifrnd (1,2, 1, -1) -%!error unifrnd (ones(2,2), 2, 3) -%!error unifrnd (ones(2,2), 2, [3, 2]) -%!error unifrnd (ones(2,2), 2, 2, 3) +%!error unifrnd (ones (2,2), 2, 3) +%!error unifrnd (ones (2,2), 2, [3, 2]) +%!error unifrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/distributions/wblcdf.m +++ b/scripts/statistics/distributions/wblcdf.m @@ -88,25 +88,25 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = [0, 1-exp(-x(2:4)), 1]; -%!assert(wblcdf (x, ones(1,5), ones(1,5)), y); -%!assert(wblcdf (x, 1, ones(1,5)), y); -%!assert(wblcdf (x, ones(1,5), 1), y); -%!assert(wblcdf (x, [0 1 NaN Inf 1], 1), [NaN 0 NaN NaN 1]); -%!assert(wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN NaN 1]); -%!assert(wblcdf ([x(1:2) NaN x(4:5)], 1, 1), [y(1:2) NaN y(4:5)]); +%!assert (wblcdf (x, ones (1,5), ones (1,5)), y) +%!assert (wblcdf (x, 1, ones (1,5)), y) +%!assert (wblcdf (x, ones (1,5), 1), y) +%!assert (wblcdf (x, [0 1 NaN Inf 1], 1), [NaN 0 NaN NaN 1]) +%!assert (wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN NaN 1]) +%!assert (wblcdf ([x(1:2) NaN x(4:5)], 1, 1), [y(1:2) NaN y(4:5)]) %% Test class of input preserved -%!assert(wblcdf ([x, NaN], 1, 1), [y, NaN]); -%!assert(wblcdf (single([x, NaN]), 1, 1), single([y, NaN])); -%!assert(wblcdf ([x, NaN], single(1), 1), single([y, NaN])); -%!assert(wblcdf ([x, NaN], 1, single(1)), single([y, NaN])); +%!assert (wblcdf ([x, NaN], 1, 1), [y, NaN]) +%!assert (wblcdf (single ([x, NaN]), 1, 1), single ([y, NaN])) +%!assert (wblcdf ([x, NaN], single (1), 1), single ([y, NaN])) +%!assert (wblcdf ([x, NaN], 1, single (1)), single ([y, NaN])) %% Test input validation %!error wblcdf () %!error wblcdf (1,2,3,4) -%!error wblcdf (ones(3),ones(2),ones(2)) -%!error wblcdf (ones(2),ones(3),ones(2)) -%!error wblcdf (ones(2),ones(2),ones(3)) +%!error wblcdf (ones (3), ones (2), ones (2)) +%!error wblcdf (ones (2), ones (3), ones (2)) +%!error wblcdf (ones (2), ones (2), ones (3)) %!error wblcdf (i, 2, 2) %!error wblcdf (2, i, 2) %!error wblcdf (2, 2, i)
--- a/scripts/statistics/distributions/wblinv.m +++ b/scripts/statistics/distributions/wblinv.m @@ -74,25 +74,25 @@ %!shared x %! x = [-1 0 0.63212055882855778 1 2]; -%!assert(wblinv (x, ones(1,5), ones(1,5)), [NaN 0 1 Inf NaN], eps); -%!assert(wblinv (x, 1, ones(1,5)), [NaN 0 1 Inf NaN], eps); -%!assert(wblinv (x, ones(1,5), 1), [NaN 0 1 Inf NaN], eps); -%!assert(wblinv (x, [1 -1 NaN Inf 1], 1), [NaN NaN NaN NaN NaN]); -%!assert(wblinv (x, 1, [1 -1 NaN Inf 1]), [NaN NaN NaN NaN NaN]); -%!assert(wblinv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]); +%!assert (wblinv (x, ones (1,5), ones (1,5)), [NaN 0 1 Inf NaN], eps) +%!assert (wblinv (x, 1, ones (1,5)), [NaN 0 1 Inf NaN], eps) +%!assert (wblinv (x, ones (1,5), 1), [NaN 0 1 Inf NaN], eps) +%!assert (wblinv (x, [1 -1 NaN Inf 1], 1), [NaN NaN NaN NaN NaN]) +%!assert (wblinv (x, 1, [1 -1 NaN Inf 1]), [NaN NaN NaN NaN NaN]) +%!assert (wblinv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]) %% Test class of input preserved -%!assert(wblinv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps); -%!assert(wblinv (single([x, NaN]), 1, 1), single([NaN 0 1 Inf NaN NaN]), eps("single")); -%!assert(wblinv ([x, NaN], single(1), 1), single([NaN 0 1 Inf NaN NaN]), eps("single")); -%!assert(wblinv ([x, NaN], 1, single(1)), single([NaN 0 1 Inf NaN NaN]), eps("single")); +%!assert (wblinv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps) +%!assert (wblinv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) +%!assert (wblinv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) +%!assert (wblinv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %% Test input validation %!error wblinv () %!error wblinv (1,2,3,4) -%!error wblinv (ones(3),ones(2),ones(2)) -%!error wblinv (ones(2),ones(3),ones(2)) -%!error wblinv (ones(2),ones(2),ones(3)) +%!error wblinv (ones (3), ones (2), ones (2)) +%!error wblinv (ones (2), ones (3), ones (2)) +%!error wblinv (ones (2), ones (2), ones (3)) %!error wblinv (i, 2, 2) %!error wblinv (2, i, 2) %!error wblinv (2, 2, i)
--- a/scripts/statistics/distributions/wblpdf.m +++ b/scripts/statistics/distributions/wblpdf.m @@ -30,7 +30,7 @@ ## @ifnottex ## ## @example -## shape * scale^(-shape) * x^(shape-1) * exp (-(x/scale)^shape) +## shape * scale^(-shape) * x^(shape-1) * exp (-(x/scale)^shape) ## @end example ## ## @end ifnottex @@ -88,24 +88,24 @@ %!shared x,y %! x = [-1 0 0.5 1 Inf]; %! y = [0, exp(-x(2:4)), NaN]; -%!assert(wblpdf (x, ones(1,5), ones(1,5)), y); -%!assert(wblpdf (x, 1, ones(1,5)), y); -%!assert(wblpdf (x, ones(1,5), 1), y); -%!assert(wblpdf (x, [0 NaN Inf 1 1], 1), [NaN NaN NaN y(4:5)]); -%!assert(wblpdf (x, 1, [0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]); -%!assert(wblpdf ([x, NaN], 1, 1), [y, NaN]); +%!assert (wblpdf (x, ones (1,5), ones (1,5)), y) +%!assert (wblpdf (x, 1, ones (1,5)), y) +%!assert (wblpdf (x, ones (1,5), 1), y) +%!assert (wblpdf (x, [0 NaN Inf 1 1], 1), [NaN NaN NaN y(4:5)]) +%!assert (wblpdf (x, 1, [0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]) +%!assert (wblpdf ([x, NaN], 1, 1), [y, NaN]) %% Test class of input preserved -%!assert(wblpdf (single([x, NaN]), 1, 1), single([y, NaN])); -%!assert(wblpdf ([x, NaN], single(1), 1), single([y, NaN])); -%!assert(wblpdf ([x, NaN], 1, single(1)), single([y, NaN])); +%!assert (wblpdf (single ([x, NaN]), 1, 1), single ([y, NaN])) +%!assert (wblpdf ([x, NaN], single (1), 1), single ([y, NaN])) +%!assert (wblpdf ([x, NaN], 1, single (1)), single ([y, NaN])) %% Test input validation %!error wblpdf () %!error wblpdf (1,2,3,4) -%!error wblpdf (ones(3),ones(2),ones(2)) -%!error wblpdf (ones(2),ones(3),ones(2)) -%!error wblpdf (ones(2),ones(2),ones(3)) +%!error wblpdf (ones (3), ones (2), ones (2)) +%!error wblpdf (ones (2), ones (3), ones (2)) +%!error wblpdf (ones (2), ones (2), ones (3)) %!error wblpdf (i, 2, 2) %!error wblpdf (2, i, 2) %!error wblpdf (2, 2, i)
--- a/scripts/statistics/distributions/wblrnd.m +++ b/scripts/statistics/distributions/wblrnd.m @@ -98,35 +98,35 @@ endfunction -%!assert(size (wblrnd (1,2)), [1, 1]); -%!assert(size (wblrnd (ones(2,1), 2)), [2, 1]); -%!assert(size (wblrnd (ones(2,2), 2)), [2, 2]); -%!assert(size (wblrnd (1, 2*ones(2,1))), [2, 1]); -%!assert(size (wblrnd (1, 2*ones(2,2))), [2, 2]); -%!assert(size (wblrnd (1, 2, 3)), [3, 3]); -%!assert(size (wblrnd (1, 2, [4 1])), [4, 1]); -%!assert(size (wblrnd (1, 2, 4, 1)), [4, 1]); +%!assert (size (wblrnd (1,2)), [1, 1]) +%!assert (size (wblrnd (ones (2,1), 2)), [2, 1]) +%!assert (size (wblrnd (ones (2,2), 2)), [2, 2]) +%!assert (size (wblrnd (1, 2*ones (2,1))), [2, 1]) +%!assert (size (wblrnd (1, 2*ones (2,2))), [2, 2]) +%!assert (size (wblrnd (1, 2, 3)), [3, 3]) +%!assert (size (wblrnd (1, 2, [4 1])), [4, 1]) +%!assert (size (wblrnd (1, 2, 4, 1)), [4, 1]) %% Test class of input preserved -%!assert(class (wblrnd (1, 2)), "double"); -%!assert(class (wblrnd (single(1), 2)), "single"); -%!assert(class (wblrnd (single([1 1]), 2)), "single"); -%!assert(class (wblrnd (1, single(2))), "single"); -%!assert(class (wblrnd (1, single([2 2]))), "single"); +%!assert (class (wblrnd (1, 2)), "double") +%!assert (class (wblrnd (single (1), 2)), "single") +%!assert (class (wblrnd (single ([1 1]), 2)), "single") +%!assert (class (wblrnd (1, single (2))), "single") +%!assert (class (wblrnd (1, single ([2 2]))), "single") %% Test input validation %!error wblrnd () %!error wblrnd (1) -%!error wblrnd (ones(3),ones(2)) -%!error wblrnd (ones(2),ones(3)) +%!error wblrnd (ones (3), ones (2)) +%!error wblrnd (ones (2), ones (3)) %!error wblrnd (i, 2) %!error wblrnd (2, i) %!error wblrnd (1,2, -1) -%!error wblrnd (1,2, ones(2)) +%!error wblrnd (1,2, ones (2)) %!error wblrnd (1, 2, [2 -1 2]) -%!error wblrnd (1,2, 1, ones(2)) +%!error wblrnd (1,2, 1, ones (2)) %!error wblrnd (1,2, 1, -1) -%!error wblrnd (ones(2,2), 2, 3) -%!error wblrnd (ones(2,2), 2, [3, 2]) -%!error wblrnd (ones(2,2), 2, 2, 3) +%!error wblrnd (ones (2,2), 2, 3) +%!error wblrnd (ones (2,2), 2, [3, 2]) +%!error wblrnd (ones (2,2), 2, 2, 3)
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -110,17 +110,18 @@ endfunction -%!error <Invalid call to kolmogorov_smirnov_test> -%! kolmogorov_smirnov_test (1); -%!error <kolmogorov_smirnov_test: X must be a vector> -%! kolmogorov_smirnov_test ({}, "unif", 2, 4); -%!error <kolmogorov_smirnov_test: no not_a_distcdf or not_a_dist_cdf function found> + +## test for recognition of unifcdf function +%!assert (kolmogorov_smirnov_test (0:100, "unif", 0, 100), 1.0, eps) +## test for recognition of logistic_cdf function +%!assert (kolmogorov_smirnov_test (0:100, "logistic"), 0) +## test for F < G +%!assert (kolmogorov_smirnov_test (50:100, "unif", 0, 50, "<")) + +%!error kolmogorov_smirnov_test (1) +%!error <X must be a vector> kolmogorov_smirnov_test ({}, "unif", 2, 4) +%!error <no not_a_distcdf or not_a_dist_cdf function found> %! kolmogorov_smirnov_test (1, "not_a_dist"); -%!error <kolmogorov_smirnov_test: alternative bla not recognized> -%! kolmogorov_smirnov_test (1, "unif", 2, 4, "bla"); -%!test # for recognition of unifcdf function -%! assert (kolmogorov_smirnov_test (0:100, "unif", 0, 100), 1.0, eps); -%!test # for recognition of logistic_cdf function -%! assert (kolmogorov_smirnov_test (0:100, "logistic"), 0); -%!test # F < G -%! assert (kolmogorov_smirnov_test (50:100, "unif", 0, 50, "<")); +%!error <alternative foo not recognized> +%! kolmogorov_smirnov_test (1, "unif", 2, 4, "foo"); +
--- a/scripts/statistics/tests/kruskal_wallis_test.m +++ b/scripts/statistics/tests/kruskal_wallis_test.m @@ -94,5 +94,6 @@ endfunction + ## Test with ties -%!assert (abs(kruskal_wallis_test([86 86], [74]) - 0.157299207050285) < 0.0000000000001) +%!assert (abs (kruskal_wallis_test ([86 86], [74]) - 0.157299207050285) < 0.0000000000001)
--- a/scripts/strings/base2dec.m +++ b/scripts/strings/base2dec.m @@ -24,7 +24,7 @@ ## @example ## @group ## base2dec ("11120", 3) -## @result{} 123 +## @result{} 123 ## @end group ## @end example ## @@ -42,7 +42,7 @@ ## @example ## @group ## base2dec ("yyyzx", "xyz") -## @result{} 123 +## @result{} 123 ## @end group ## @end example ## @seealso{dec2base, bin2dec, hex2dec} @@ -98,17 +98,17 @@ endfunction -%!assert(base2dec ("11120", 3), 123); -%!assert(base2dec ("yyyzx", "xyz"), 123); -%!assert(base2dec ("-1", 2), NaN); -%!assert(base2dec ({"A1", "1A"}, 16), [161; 26]); +%!assert (base2dec ("11120", 3), 123) +%!assert (base2dec ("yyyzx", "xyz"), 123) +%!assert (base2dec ("-1", 2), NaN) +%!assert (base2dec ({"A1", "1A"}, 16), [161; 26]) %%Test input validation -%!error base2dec (); -%!error base2dec ("11120"); -%!error base2dec ("11120", 3, 4); -%!error base2dec ("11120", "1231"); -%!error base2dec ("11120", "12 3"); -%!error base2dec ("11120", ones(2)); -%!error base2dec ("11120", 37); +%!error base2dec () +%!error base2dec ("11120") +%!error base2dec ("11120", 3, 4) +%!error base2dec ("11120", "1231") +%!error base2dec ("11120", "12 3") +%!error base2dec ("11120", ones (2)) +%!error base2dec ("11120", 37)
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -50,13 +50,13 @@ endfunction -%!assert(bin2dec ("0000"), 0); -%!assert(bin2dec ("1110"), 14); -%!assert(bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1); -%!assert(bin2dec ({"1110", "1111"}), [14; 15]); +%!assert (bin2dec ("0000"), 0) +%!assert (bin2dec ("1110"), 14) +%!assert (bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) +%!assert (bin2dec ({"1110", "1111"}), [14; 15]) %%Test input validation -%!error bin2dec (); -%!error bin2dec (1); -%!error bin2dec ("1", 2); +%!error bin2dec () +%!error bin2dec (1) +%!error bin2dec ("1", 2)
--- a/scripts/strings/blanks.m +++ b/scripts/strings/blanks.m @@ -52,9 +52,9 @@ ## There really isn't that much to test here -%!assert(blanks (0), "") -%!assert(blanks (5), " ") -%!assert(blanks (10), " ") +%!assert (blanks (0), "") +%!assert (blanks (5), " ") +%!assert (blanks (10), " ") %% Test input validation %!error blanks ()
--- a/scripts/strings/cstrcat.m +++ b/scripts/strings/cstrcat.m @@ -24,7 +24,7 @@ ## @example ## @group ## cstrcat ("ab ", "cd") -## @result{} "ab cd" +## @result{} "ab cd" ## @end group ## @end example ## @@ -32,8 +32,7 @@ ## @group ## s = [ "ab"; "cde" ]; ## cstrcat (s, s, s) -## @result{} ans = -## "ab ab ab " +## @result{} "ab ab ab " ## "cdecdecde" ## @end group ## @end example @@ -65,6 +64,6 @@ %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]) %% Test input validation -%!error cstrcat (); -%!error cstrcat (1, 2); +%!error cstrcat () +%!error cstrcat (1, 2)
--- a/scripts/strings/deblank.m +++ b/scripts/strings/deblank.m @@ -75,15 +75,15 @@ endfunction -%!assert (deblank (" f o o \0"), " f o o"); -%!assert (deblank (' '), ''); -%!assert (deblank (" "), ""); -%!assert (deblank (""), ""); -%!assert (deblank ({}), {}); -%!assert (deblank ({" abc ", {" def "}}), {" abc", {" def"}}); +%!assert (deblank (" f o o \0"), " f o o") +%!assert (deblank (' '), '') +%!assert (deblank (" "), "") +%!assert (deblank (""), "") +%!assert (deblank ({}), {}) +%!assert (deblank ({" abc ", {" def "}}), {" abc", {" def"}}) -%!error <Invalid call to deblank> deblank (); -%!error <Invalid call to deblank> deblank ("foo", "bar"); -%!error <argument must be a string> deblank (1); -%!error <argument must be a string> deblank ({[]}); +%!error <Invalid call to deblank> deblank () +%!error <Invalid call to deblank> deblank ("foo", "bar") +%!error <argument must be a string> deblank (1) +%!error <argument must be a string> deblank ({[]})
--- a/scripts/strings/dec2base.m +++ b/scripts/strings/dec2base.m @@ -25,7 +25,7 @@ ## @example ## @group ## dec2base (123, 3) -## @result{} "11120" +## @result{} "11120" ## @end group ## @end example ## @@ -40,7 +40,7 @@ ## @example ## @group ## dec2base (123, "aei") -## @result{} "eeeia" +## @result{} "eeeia" ## @end group ## @end example ## @@ -119,23 +119,23 @@ %!test -%! s0 = ''; +%! s0 = ""; %! for n = 1:13 %! for b = 2:16 %! pp = dec2base (b^n+1, b); -%! assert (dec2base(b^n, b), ['1',s0,'0']); -%! assert (dec2base(b^n+1, b), ['1',s0,'1']); +%! assert (dec2base (b^n, b), ['1',s0,'0']); +%! assert (dec2base (b^n+1, b), ['1',s0,'1']); %! endfor %! s0 = [s0,'0']; %! endfor %!test -%! digits='0123456789ABCDEF'; +%! digits = "0123456789ABCDEF"; %! for n = 1:13 %! for b = 2:16 -%! pm = dec2base(b^n-1, b); +%! pm = dec2base (b^n-1, b); %! assert (length (pm), n); -%! assert (all (pm==digits(b))); +%! assert (all (pm == digits(b))); %! endfor %! endfor @@ -144,12 +144,12 @@ %! assert (dec2base (0, b), '0'); %! endfor -%!assert(dec2base (0, 2, 4), "0000"); -%!assert(dec2base (2^51-1, 2), ... -%! '111111111111111111111111111111111111111111111111111'); -%!assert(dec2base(uint64(2)^63-1, 16), '7FFFFFFFFFFFFFFF'); -%!assert(dec2base([1, 2; 3, 4], 2, 3), ["001"; "011"; "010"; "100"]); -%!assert(dec2base({1, 2; 3, 4}, 2, 3), ["001"; "011"; "010"; "100"]); +%!assert (dec2base (0, 2, 4), "0000") +%!assert (dec2base (2^51-1, 2), ... +%! "111111111111111111111111111111111111111111111111111") +%!assert (dec2base (uint64 (2)^63-1, 16), "7FFFFFFFFFFFFFFF") +%!assert (dec2base ([1, 2; 3, 4], 2, 3), ["001"; "011"; "010"; "100"]) +%!assert (dec2base ({1, 2; 3, 4}, 2, 3), ["001"; "011"; "010"; "100"]) %%Test input validation %!error dec2base ()
--- a/scripts/strings/dec2bin.m +++ b/scripts/strings/dec2bin.m @@ -53,11 +53,11 @@ endfunction -%!assert(dec2bin (14), "1110"); -%!assert(dec2bin (14, 6), "001110"); -%!assert(dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"]); +%!assert (dec2bin (14), "1110") +%!assert (dec2bin (14, 6), "001110") +%!assert (dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"]) %%Test input validation -%!error dec2bin (); -%!error dec2bin (1, 2, 3); +%!error dec2bin () +%!error dec2bin (1, 2, 3)
--- a/scripts/strings/dec2hex.m +++ b/scripts/strings/dec2hex.m @@ -53,11 +53,11 @@ endfunction -%!assert(dec2hex (2748), "ABC"); -%!assert(dec2hex (2748, 5), "00ABC"); -%!assert(dec2hex ({2748, 2746}), ["ABC"; "ABA"]); +%!assert (dec2hex (2748), "ABC") +%!assert (dec2hex (2748, 5), "00ABC") +%!assert (dec2hex ({2748, 2746}), ["ABC"; "ABA"]) %% Test input validation -%!error dec2hex (); -%!error dec2hex (1, 2, 3); +%!error dec2hex () +%!error dec2hex (1, 2, 3)
--- a/scripts/strings/findstr.m +++ b/scripts/strings/findstr.m @@ -133,11 +133,11 @@ %!assert (findstr ("abababa", "a"), [1, 3, 5, 7]) -%!assert (findstr ("abababa", "aba"), [1, 3, 5]); -%!assert (findstr ("aba", "abababa", 0), [1, 5]); +%!assert (findstr ("abababa", "aba"), [1, 3, 5]) +%!assert (findstr ("aba", "abababa", 0), [1, 5]) %% Test input validation %!error findstr () -%!error findstr ("foo", "bar", 3, 4); -%!error findstr (["AB" ; "CD"], "C"); +%!error findstr ("foo", "bar", 3, 4) +%!error <must have only one non-singleton dimension> findstr (["AB" ; "CD"], "C")
--- a/scripts/strings/hex2dec.m +++ b/scripts/strings/hex2dec.m @@ -53,13 +53,13 @@ endfunction -%!assert(hex2dec ("0000"), 0); -%!assert(hex2dec ("1FFFFFFFFFFFFF"), 2^53-1); -%!assert(hex2dec (["12b"; "12B"]), [299; 299]); -%!assert(hex2dec ({"A1", "1A"}), [161; 26]); +%!assert (hex2dec ("0000"), 0) +%!assert (hex2dec ("1FFFFFFFFFFFFF"), 2^53-1) +%!assert (hex2dec (["12b"; "12B"]), [299; 299]) +%!assert (hex2dec ({"A1", "1A"}), [161; 26]) %%Test input validation -%!error hex2dec (); -%!error hex2dec (1); -%!error hex2dec ("1", 2); +%!error hex2dec () +%!error hex2dec (1) +%!error hex2dec ("1", 2)
--- a/scripts/strings/index.m +++ b/scripts/strings/index.m @@ -28,7 +28,7 @@ ## @example ## @group ## index ("Teststring", "t") -## @result{} 4 +## @result{} 4 ## @end group ## @end example ## @@ -84,20 +84,21 @@ endfunction -%!assert (index ("foobarbaz", "b") == 4 && index ("foobarbaz", "z") == 9); +%!assert (index ("foobarbaz", "b"), 4) +%!assert (index ("foobarbaz", "z"), 9) -%!assert (index("astringbstringcstring", "s"), 2) -%!assert (index("astringbstringcstring", "st"), 2) -%!assert (index("astringbstringcstring", "str"), 2) -%!assert (index("astringbstringcstring", "string"), 2) -%!assert (index("abc---", "abc+++"), 0) +%!assert (index ("astringbstringcstring", "s"), 2) +%!assert (index ("astringbstringcstring", "st"), 2) +%!assert (index ("astringbstringcstring", "str"), 2) +%!assert (index ("astringbstringcstring", "string"), 2) +%!assert (index ("abc---", "abc+++"), 0) ## test everything out in reverse -%!assert (index("astringbstringcstring", "s", "last"), 16) -%!assert (index("astringbstringcstring", "st", "last"), 16) -%!assert (index("astringbstringcstring", "str", "last"), 16) -%!assert (index("astringbstringcstring", "string", "last"), 16) -%!assert (index("abc---", "abc+++", "last"), 0) +%!assert (index ("astringbstringcstring", "s", "last"), 16) +%!assert (index ("astringbstringcstring", "st", "last"), 16) +%!assert (index ("astringbstringcstring", "str", "last"), 16) +%!assert (index ("astringbstringcstring", "string", "last"), 16) +%!assert (index ("abc---", "abc+++", "last"), 0) %!test %! str = char ("Hello", "World", "Goodbye", "World");
--- a/scripts/strings/isletter.m +++ b/scripts/strings/isletter.m @@ -36,5 +36,7 @@ endfunction -%!error isletter(); -%!error isletter("a", "b"); + +%!error isletter () +%!error isletter ("a", "b") +
--- a/scripts/strings/mat2str.m +++ b/scripts/strings/mat2str.m @@ -128,20 +128,20 @@ endfunction -%!assert (mat2str (0.7), "0.7"); -%!assert (mat2str (pi), "3.14159265358979"); -%!assert (mat2str (pi, 5), "3.1416"); -%!assert (mat2str (single (pi), 5, "class"), "single(3.1416)"); +%!assert (mat2str (0.7), "0.7") +%!assert (mat2str (pi), "3.14159265358979") +%!assert (mat2str (pi, 5), "3.1416") +%!assert (mat2str (single (pi), 5, "class"), "single(3.1416)") %!assert (mat2str ([-1/3 + i/7; 1/3 - i/7], [4 2]), "[-0.3333+0.14i;0.3333-0.14i]") %!assert (mat2str ([-1/3 +i/7; 1/3 -i/7], [4 2]), "[-0.3333+0i 0+0.14i;0.3333+0i -0-0.14i]") -%!assert (mat2str (int16 ([1 -1]), 'class'), "int16([1 -1])") -%!assert (mat2str (true), "true"); -%!assert (mat2str (false), "false"); -%!assert (mat2str (logical (eye (2))), "[true false;false true]"); +%!assert (mat2str (int16 ([1 -1]), "class"), "int16([1 -1])") +%!assert (mat2str (true), "true") +%!assert (mat2str (false), "false") +%!assert (mat2str (logical (eye (2))), "[true false;false true]") %% Test input validation %!error mat2str () %!error mat2str (1,2,3,4) %!error mat2str (["Hello"]) -%!error mat2str (ones(3,3,2)) +%!error <X must be two dimensional> mat2str (ones(3,3,2))
--- a/scripts/strings/rindex.m +++ b/scripts/strings/rindex.m @@ -52,7 +52,8 @@ endfunction -%!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3); +%!assert (rindex ("foobarbaz", "b"), 7) +%!assert (rindex ("foobarbaz", "o"), 3) %!test %! str = char ("Hello", "World", "Goodbye", "World");
--- a/scripts/strings/str2num.m +++ b/scripts/strings/str2num.m @@ -27,9 +27,8 @@ ## str2num ("3.141596") ## @result{} 3.141596 ## -## str2num (["1, 2, 3"; "4, 5, 6"]); -## @result{} ans = -## 1 2 3 +## str2num (["1, 2, 3"; "4, 5, 6"]) +## @result{} 1 2 3 ## 4 5 6 ## @end group ## @end example @@ -69,8 +68,8 @@ endfunction -%!assert(str2num ("-1.3e2"), -130); -%!assert(str2num ("[1, 2; 3, 4]"), [1, 2; 3, 4]); +%!assert (str2num ("-1.3e2"), -130) +%!assert (str2num ("[1, 2; 3, 4]"), [1, 2; 3, 4]) %!test %! [x, state] = str2num ("pi");
--- a/scripts/strings/strcat.m +++ b/scripts/strings/strcat.m @@ -30,7 +30,7 @@ ## @group ## s = [ "ab"; "cde" ]; ## strcat (s, s, s) -## @result{} ans = +## @result{} ## "ab ab ab " ## "cdecdecde" ## @end group @@ -40,7 +40,7 @@ ## @group ## s = @{ "ab"; "cde" @}; ## strcat (s, s, s) -## @result{} ans = +## @result{} ## @{ ## [1,1] = ababab ## [2,1] = cdecdecde @@ -96,32 +96,31 @@ ## test the dimensionality ## 1d -%!assert(strcat("ab ", "ab "), "abab") -%!assert(strcat({"ab "}, "ab "), {"ab ab"}) -%!assert(strcat("ab ", {"ab "}), {"abab "}) -%!assert(strcat({"ab "}, {"ab "}), {"ab ab "}) -%!assert(strcat("", "ab"), "ab") -%!assert(strcat("", {"ab"}, {""}), {"ab"}) +%!assert (strcat ("ab ", "ab "), "abab") +%!assert (strcat ({"ab "}, "ab "), {"ab ab"}) +%!assert (strcat ("ab ", {"ab "}), {"abab "}) +%!assert (strcat ({"ab "}, {"ab "}), {"ab ab "}) +%!assert (strcat ("", "ab"), "ab") +%!assert (strcat ("", {"ab"}, {""}), {"ab"}) ## 2d -%!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["abab ";"cdecde"]) +%!assert (strcat (["ab ";"cde"], ["ab ";"cde"]), ["abab ";"cdecde"]) ## test for deblanking implied trailing spaces of character input -%!assert((strcmp (strcat ("foo", "bar"), "foobar") -%! && strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["afoo "; "bbbar"]))); +%!assert (strcat ("foo", "bar"), "foobar") +%!assert (strcat (["a"; "bb"], ["foo"; "bar"]), ["afoo "; "bbbar"]) ## test for mixing character and cell inputs -%!assert(all (strcmp (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"}))) +%!assert (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"}) ## test for scalar strings with vector strings -%!assert(all (strcmp (strcat (["a"; "b"], "c"), ["ac"; "bc"]))) +%!assert (strcat (["a"; "b"], "c"), ["ac"; "bc"]) ## test with cells with strings of differing lengths -%!assert(all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"}))) -%!assert(all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"}))) - -%!error strcat (); +%!assert (all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"}))) +%!assert (all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"}))) %!assert (strcat (1, 2), strcat (char(1), char(2))) +%!assert (strcat ("", 2), strcat ([], char(2))) -%!assert (strcat ('', 2), strcat ([], char(2))) +%!error strcat ()
--- a/scripts/strings/strjust.m +++ b/scripts/strings/strjust.m @@ -32,11 +32,11 @@ ## @example ## @group ## strjust (["a"; "ab"; "abc"; "abcd"]) -## @result{} ans = -## a -## ab -## abc -## abcd +## @result{} +## " a" +## " ab" +## " abc" +## "abcd" ## @end group ## @end example ## @seealso{deblank, strrep, strtrim, untabify} @@ -97,16 +97,16 @@ %!assert (strjust (["a"; "ab"; "abc"; "abcd"]), -%! [" a";" ab"; " abc"; "abcd"]); +%! [" a";" ab"; " abc"; "abcd"]) %!assert (strjust ([" a"; " ab"; "abc"; "abcd"], "left"), -%! ["a "; "ab "; "abc "; "abcd"]); +%! ["a "; "ab "; "abc "; "abcd"]) %!assert (strjust (["a"; "ab"; "abc"; "abcd"], "CENTER"), -%! [" a "; " ab"; "abc "; "abcd"]); -%!assert (strjust (["";""]), ""); +%! [" a "; " ab"; "abc "; "abcd"]) +%!assert (strjust (["";""]), "") %% Test input validation %!error <Invalid call to strjust> strjust () %!error <Invalid call to strjust> strjust (["a";"ab"], "center", 1) -%!error <S must be a string> strjust (ones(3,3)) -%!error <S must be a string> strjust (char (ones(3,3,3))) +%!error <S must be a string> strjust (ones (3,3)) +%!error <S must be a string> strjust (char (ones (3,3,3)))
--- a/scripts/strings/strmatch.m +++ b/scripts/strings/strmatch.m @@ -97,23 +97,23 @@ endfunction -%!assert (strmatch("a", {"aaa", "bab", "bbb"}), 1); -%!assert (strmatch ("apple", "apple juice"), 1); -%!assert (strmatch ("apple", ["apple pie"; "apple juice"; "an apple"]), [1; 2]); -%!assert (strmatch ("apple", {"apple pie"; "apple juice"; "tomato"}), [1; 2]); -%!assert (strmatch ("apple pie", "apple"), []); -%!assert (strmatch ("a ", "a"), 1); -%!assert (strmatch ("a", "a \0", "exact"), 1); -%!assert (strmatch ("a b", {"a b", "a c", "c d"}), 1); -%!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4]); -%!assert (strmatch ('', { '', '% comment', 'var a = 5', ''}, 'exact'), [1,4]); +%!assert (strmatch ("a", {"aaa", "bab", "bbb"}), 1) +%!assert (strmatch ("apple", "apple juice"), 1) +%!assert (strmatch ("apple", ["apple pie"; "apple juice"; "an apple"]), [1; 2]) +%!assert (strmatch ("apple", {"apple pie"; "apple juice"; "tomato"}), [1; 2]) +%!assert (strmatch ("apple pie", "apple"), []) +%!assert (strmatch ("a ", "a"), 1) +%!assert (strmatch ("a", "a \0", "exact"), 1) +%!assert (strmatch ("a b", {"a b", "a c", "c d"}), 1) +%!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4]) +%!assert (strmatch ('', { '', '% comment', 'var a = 5', ''}, 'exact'), [1,4]) %% Test input validation -%!error <Invalid call to strmatch> strmatch(); -%!error <Invalid call to strmatch> strmatch("a"); -%!error <Invalid call to strmatch> strmatch("a", "aaa", "exact", 1); -%!error <S must be a string> strmatch(1, "aaa"); -%!error <S must be a string> strmatch(char ("a", "bb"), "aaa"); -%!error <A must be a string> strmatch("a", 1); -%!error <A must be a string> strmatch("a", {"hello", [1]}); +%!error <Invalid call to strmatch> strmatch () +%!error <Invalid call to strmatch> strmatch ("a") +%!error <Invalid call to strmatch> strmatch ("a", "aaa", "exact", 1) +%!error <S must be a string> strmatch (1, "aaa") +%!error <S must be a string> strmatch (char ("a", "bb"), "aaa") +%!error <A must be a string> strmatch ("a", 1) +%!error <A must be a string> strmatch ("a", {"hello", [1]})
--- a/scripts/strings/strsplit.m +++ b/scripts/strings/strsplit.m @@ -32,7 +32,7 @@ ## @example ## @group ## strsplit ("a,b,c", ",") -## @result{} +## @result{} ## @{ ## [1,1] = a ## [1,2] = b @@ -40,7 +40,7 @@ ## @} ## ## strsplit (["a,b" ; "cde"], ",") -## @result{} +## @result{} ## @{ ## [1,1] = a ## [1,2] = b @@ -114,5 +114,5 @@ %!error strsplit ("abc", "b", true, 4) %!error <S and SEP must be string values> strsplit (123, "b") %!error <S and SEP must be string values> strsplit ("abc", 1) -%!error <STRIP_EMPTY must be a scalar value> strsplit ("abc", "def", ones(3,3)) +%!error <STRIP_EMPTY must be a scalar value> strsplit ("abc", "def", ones (3,3))
--- a/scripts/strings/strtok.m +++ b/scripts/strings/strtok.m @@ -190,19 +190,19 @@ %! assert (r{7}, ""); %% Simple check for 2, 3, and 4 delimeters -%!assert(strtok ("this is", "i "), "th"); -%!assert(strtok ("this is", "ij "), "th"); -%!assert(strtok ("this is", "ijk "), "th"); +%!assert (strtok ("this is", "i "), "th") +%!assert (strtok ("this is", "ij "), "th") +%!assert (strtok ("this is", "ijk "), "th") %% Test all cases for 8 delimiters since a different %!# algorithm is used when more than 7 delimiters -%!assert (strtok ("","jklmnop "), ""); -%!assert (strtok ("this","jklmnop "), "this"); -%!assert (strtok ("this ","jklmnop "), "this"); -%!assert (strtok ("this is","jklmnop "), "this"); -%!assert (strtok (" this","jklmnop "), "this"); -%!assert (strtok (" this ","jklmnop "), "this"); -%!assert (strtok (" ","jklmnop "), ""(1:0)); +%!assert (strtok ("","jklmnop "), "") +%!assert (strtok ("this","jklmnop "), "this") +%!assert (strtok ("this ","jklmnop "), "this") +%!assert (strtok ("this is","jklmnop "), "this") +%!assert (strtok (" this","jklmnop "), "this") +%!assert (strtok (" this ","jklmnop "), "this") +%!assert (strtok (" ","jklmnop "), ""(1:0)) %% Test 'bad' string orientations %!assert (strtok (" this ".'), "this".'); # delimiter at start and end @@ -213,7 +213,7 @@ %! for ch = "\t\n\v\f\r" %! [t, r] = strtok (cstrcat ("beg", ch, "end")); %! assert (t, "beg"); -%! assert (r, cstrcat (ch, "end")) +%! assert (r, cstrcat (ch, "end")); %! endfor %% Test input validation
--- a/scripts/strings/strtrim.m +++ b/scripts/strings/strtrim.m @@ -74,15 +74,15 @@ endfunction -%!assert (strtrim (" abc "), "abc"); -%!assert (strtrim (" "), ""); -%!assert (strtrim ("abc"), "abc"); -%!assert (strtrim ([" abc "; " def "]), ["abc "; " def"]); -%!assert (strtrim ({" abc "; " def "}), {"abc"; "def"}); -%!assert (strtrim ({" abc ", {" def "}}), {"abc", {"def"}}); +%!assert (strtrim (" abc "), "abc") +%!assert (strtrim (" "), "") +%!assert (strtrim ("abc"), "abc") +%!assert (strtrim ([" abc "; " def "]), ["abc "; " def"]) +%!assert (strtrim ({" abc "; " def "}), {"abc"; "def"}) +%!assert (strtrim ({" abc ", {" def "}}), {"abc", {"def"}}) -%!error <Invalid call to strtrim> strtrim (); -%!error <Invalid call to strtrim> strtrim ("abc", "def"); -%!error <argument must be a string> strtrim (1); -%!error <argument must be a string> strtrim ({[]}); +%!error <Invalid call to strtrim> strtrim () +%!error <Invalid call to strtrim> strtrim ("abc", "def") +%!error <argument must be a string> strtrim (1) +%!error <argument must be a string> strtrim ({[]})
--- a/scripts/strings/strtrunc.m +++ b/scripts/strings/strtrunc.m @@ -55,12 +55,12 @@ endfunction -%!assert (strtrunc("abcdefg", 4), "abcd"); -%!assert (strtrunc("abcdefg", 10), "abcdefg"); -%!assert (strtrunc(char ("abcdef", "fedcba"), 3), ["abc"; "fed"]); -%!assert (strtrunc({"abcdef", "fedcba"}, 3), {"abc", "fed"}); -%!assert (strtrunc({"", "1", "21", "321"}, 1), {"", "1", "2", "3"}) -%!assert (strtrunc({"1", "", "2"}, 1), {"1", "", "2"}) +%!assert (strtrunc ("abcdefg", 4), "abcd") +%!assert (strtrunc ("abcdefg", 10), "abcdefg") +%!assert (strtrunc (char ("abcdef", "fedcba"), 3), ["abc"; "fed"]) +%!assert (strtrunc ({"abcdef", "fedcba"}, 3), {"abc", "fed"}) +%!assert (strtrunc ({"", "1", "21", "321"}, 1), {"", "1", "2", "3"}) +%!assert (strtrunc ({"1", "", "2"}, 1), {"1", "", "2"}) %!test %! cstr = {"line1"; ["line2"; "line3"]; "line4"}; %! y = strtrunc (cstr, 4);
--- a/scripts/strings/substr.m +++ b/scripts/strings/substr.m @@ -92,12 +92,12 @@ endfunction -%!assert (substr ("This is a test string", 6, 9), "is a test"); -%!assert (substr ("This is a test string", -11), "test string"); -%!assert (substr ("This is a test string", -11, 4), "test"); -%!assert (substr ("This is a test string", -11, -7), "test"); -%!assert (substr ("This is a test string", 1, -7), "This is a test"); -%!assert (isempty (substr ("This is a test string", 1, 0))); +%!assert (substr ("This is a test string", 6, 9), "is a test") +%!assert (substr ("This is a test string", -11), "test string") +%!assert (substr ("This is a test string", -11, 4), "test") +%!assert (substr ("This is a test string", -11, -7), "test") +%!assert (substr ("This is a test string", 1, -7), "This is a test") +%!assert (isempty (substr ("This is a test string", 1, 0))) %% Test input validation %!error substr ()
--- a/scripts/strings/validatestring.m +++ b/scripts/strings/validatestring.m @@ -138,12 +138,13 @@ %!shared strarray -%! strarray = {"octave" "Oct" "octopus" "octaves"}; +%! strarray = {"octave" "Oct" "octopus" "octaves"}; %!assert (validatestring ("octave", strarray), "octave") %!assert (validatestring ("oct", strarray), "Oct") %!assert (validatestring ("octa", strarray), "octave") -%! strarray = {"abc1" "def" "abc2"}; +%! strarray = {"abc1" "def" "abc2"}; %!assert (validatestring ("d", strarray), "def") + %!error <'xyz' does not match any> validatestring ("xyz", strarray) %!error <Function: DUMMY_TEST> validatestring ("xyz", strarray, "DUMMY_TEST") %!error <Function: DUMMY_TEST Variable: DUMMY_VAR:> validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR")
--- a/scripts/testfun/demo.m +++ b/scripts/testfun/demo.m @@ -19,8 +19,8 @@ ## -*- texinfo -*- ## @deftypefn {Command} {} demo @var{name} ## @deftypefnx {Command} {} demo @var{name} @var{n} -## @deftypefnx {Function File} {} demo ('@var{name}') -## @deftypefnx {Function File} {} demo ('@var{name}', @var{n}) +## @deftypefnx {Function File} {} demo ("@var{name}") +## @deftypefnx {Function File} {} demo ("@var{name}", @var{n}) ## ## Run example code block @var{n} associated with the function @var{name}. ## If @var{n} is not specified, all examples are run. @@ -34,12 +34,12 @@ ## ## @example ## @group -## %!demo -## %! t = 0:0.01:2*pi; -## %! x = sin (t); -## %! plot (t,x); -## %! %------------------------------------------------- -## %! % the figure window shows one cycle of a sine wave +## %!demo +## %! t = 0:0.01:2*pi; +## %! x = sin (t); +## %! plot (t, x); +## %! %------------------------------------------------- +## %! % the figure window shows one cycle of a sine wave ## @end group ## @end example ## @@ -53,7 +53,7 @@ ## with the code ## ## @example -## %! input("Press <enter> to continue: ","s"); +## %! input("Press <enter> to continue: ","s"); ## @end example ## ## @noindent @@ -65,19 +65,19 @@ ## Also, because demo evaluates within a function context, you cannot ## define new functions inside a demo. If you must have function blocks, ## rather than just anonymous functions or inline functions, you will have to -## use @code{eval(example('function',n))} to see them. Because eval only +## use @code{eval(example("function",n))} to see them. Because eval only ## evaluates one line, or one statement if the statement crosses ## multiple lines, you must wrap your demo in "if 1 <demo stuff> endif" ## with the 'if' on the same line as 'demo'. For example: ## ## @example ## @group -## %!demo if 1 -## %! function y=f(x) -## %! y=x; -## %! endfunction -## %! f(3) -## %! endif +## %!demo if 1 +## %! function y=f(x) +## %! y=x; +## %! endfunction +## %! f(3) +## %! endif ## @end group ## @end example ## @@ -149,9 +149,10 @@ %!demo %! t = 0:0.01:2*pi; %! x = sin (t); -%! plot (t,x); +%! plot (t, x); %! %------------------------------------------------- %! % the figure window shows one cycle of a sine wave -%!error demo (); -%!error demo (1, 2, 3); +%!error demo () +%!error demo (1, 2, 3) +
--- a/scripts/testfun/example.m +++ b/scripts/testfun/example.m @@ -19,12 +19,12 @@ ## -*- texinfo -*- ## @deftypefn {Command} {} example @var{name} ## @deftypefnx {Command} {} example @var{name} @var{n} -## @deftypefnx {Function File} {} example ('@var{name}') -## @deftypefnx {Function File} {} example ('@var{name}', @var{n}) +## @deftypefnx {Function File} {} example ("@var{name}") +## @deftypefnx {Function File} {} example ("@var{name}", @var{n}) ## @deftypefnx {Function File} {[@var{s}, @var{idx}] =} example (@dots{}) ## ## Display the code for example @var{n} associated with the function -## '@var{name}', but do not run it. If @var{n} is not specified, all examples +## "@var{name}", but do not run it. If @var{n} is not specified, all examples ## are displayed. ## ## When called with output arguments, the examples are returned in the form of @@ -86,21 +86,21 @@ ## WARNING: don't modify the demos without modifying the tests! %!demo -%! example ('example'); +%! example ("example"); %!demo %! clf; -%! t=0:0.01:2*pi; x = sin(t); +%! t = 0:0.01:2*pi; x = sin (t); %! plot (t,x) -%!assert (example('example',1), "\n example ('example');"); +%!assert (example ("example",1), "\n example (\"example\");"); %!test -%! [code, idx] = example ('example'); +%! [code, idx] = example ("example"); %! assert (code, ... -%! "\n example ('example');\n clf;\n t=0:0.01:2*pi; x = sin(t);\n plot (t,x)") -%! assert (idx, [1, 23, 69]); +%! "\n example (\"example\");\n clf;\n t = 0:0.01:2*pi; x = sin (t);\n plot (t,x)") +%! assert (idx, [1, 23, 73]); %% Test input validation %!error example -%!error example ('example', 3, 5) +%!error example ("example", 3, 5)
--- a/scripts/testfun/fail.m +++ b/scripts/testfun/fail.m @@ -22,7 +22,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} fail (@var{code}) ## @deftypefnx {Function File} {} fail (@var{code}, @var{pattern}) -## @deftypefnx {Function File} {} fail (@var{code}, 'warning', @var{pattern}) +## @deftypefnx {Function File} {} fail (@var{code}, "warning", @var{pattern}) ## ## Return true if @var{code} fails with an error message matching ## @var{pattern}, otherwise produce an error. Note that @var{code} @@ -130,15 +130,16 @@ endfunction -%!fail ('[1,2]*[2,3]', 'nonconformant') +%!fail ("[1,2]*[2,3]", "nonconformant") %!fail ("fail('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none") %!fail ("fail('[1,2]*[2,3]','usage:')", "expected error <usage:>\nbut got.*nonconformant") -%!fail ("warning('test warning')", 'warning','test warning'); +%!fail ("warning('test warning')", "warning", "test warning"); ##% !fail ("warning('next test')",'warning','next test'); ## only allowed one warning test?!? %% Test that fail() itself will generate an error -%!error fail ("1"); -%!error <undefined> fail ('a*[2;3]', 'nonconformant') -%!error <expected error> fail ('a*[2,3]', 'usage:') -%!error <warning failure> fail ("warning('warning failure')", 'warning', 'success') +%!error fail ("1") +%!error <undefined> fail ("a*[2;3]", "nonconformant") +%!error <expected error> fail ("a*[2,3]", "usage:") +%!error <warning failure> fail ("warning('warning failure')", "warning", "success") +
--- a/scripts/testfun/speed.m +++ b/scripts/testfun/speed.m @@ -356,63 +356,63 @@ %% Unfortunately, we can't remove them from the user's workspace %% because of another bug (#34497). %!demo -%! fstr_build_orig = cstrcat ( -%! "function x = build_orig (n)\n", -%! " ## extend the target vector on the fly\n", -%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", -%! "endfunction"); -%! fstr_build = cstrcat ( -%! "function x = build (n)\n", -%! " ## preallocate the target vector\n", -%! " x = zeros (1, n*100);\n", -%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", -%! "endfunction"); +%! fstr_build_orig = cstrcat ( +%! "function x = build_orig (n)\n", +%! " ## extend the target vector on the fly\n", +%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", +%! "endfunction"); +%! fstr_build = cstrcat ( +%! "function x = build (n)\n", +%! " ## preallocate the target vector\n", +%! " x = zeros (1, n*100);\n", +%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", +%! "endfunction"); %! -%! disp ("-----------------------"); -%! disp (fstr_build_orig); -%! disp ("-----------------------"); -%! disp (fstr_build); -%! disp ("-----------------------"); +%! disp ("-----------------------"); +%! disp (fstr_build_orig); +%! disp ("-----------------------"); +%! disp (fstr_build); +%! disp ("-----------------------"); %! -%! ## Eval functions strings to create them in the current context -%! eval (fstr_build_orig); -%! eval (fstr_build); +%! ## Eval functions strings to create them in the current context +%! eval (fstr_build_orig); +%! eval (fstr_build); %! -%! disp ("Preallocated vector test.\nThis takes a little while..."); -%! speed("build (n)", "", 1000, "build_orig (n)"); -%! clear -f build build_orig -%! disp ("-----------------------"); -%! disp ("Note how much faster it is to pre-allocate a vector."); -%! disp ("Notice the peak speedup ratio."); +%! disp ("Preallocated vector test.\nThis takes a little while..."); +%! speed("build (n)", "", 1000, "build_orig (n)"); +%! clear -f build build_orig +%! disp ("-----------------------"); +%! disp ("Note how much faster it is to pre-allocate a vector."); +%! disp ("Notice the peak speedup ratio."); %!demo -%! fstr_build_orig = cstrcat ( -%! "function x = build_orig (n)\n", -%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", -%! "endfunction"); -%! fstr_build = cstrcat ( -%! "function x = build (n)\n", -%! " idx = [1:100]';\n", -%! " x = idx(:,ones(1,n));\n", -%! " x = reshape (x, 1, n*100);\n", -%! "endfunction"); +%! fstr_build_orig = cstrcat ( +%! "function x = build_orig (n)\n", +%! " for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n", +%! "endfunction"); +%! fstr_build = cstrcat ( +%! "function x = build (n)\n", +%! " idx = [1:100]';\n", +%! " x = idx(:,ones(1,n));\n", +%! " x = reshape (x, 1, n*100);\n", +%! "endfunction"); %! -%! disp ("-----------------------"); -%! disp (fstr_build_orig); -%! disp ("-----------------------"); -%! disp (fstr_build); -%! disp ("-----------------------"); +%! disp ("-----------------------"); +%! disp (fstr_build_orig); +%! disp ("-----------------------"); +%! disp (fstr_build); +%! disp ("-----------------------"); %! -%! ## Eval functions strings to create them in the current context -%! eval (fstr_build_orig); -%! eval (fstr_build); +%! ## Eval functions strings to create them in the current context +%! eval (fstr_build_orig); +%! eval (fstr_build); %! -%! disp ("Vectorized test.\nThis takes a little while..."); -%! speed("build (n)", "", 1000, "build_orig (n)"); -%! clear -f build build_orig -%! disp ("-----------------------"); -%! disp ("This time, the for loop is done away with entirely."); -%! disp ("Notice how much bigger the speedup is than in example 1."); +%! disp ("Vectorized test.\nThis takes a little while..."); +%! speed("build (n)", "", 1000, "build_orig (n)"); +%! clear -f build build_orig +%! disp ("-----------------------"); +%! disp ("This time, the for loop is done away with entirely."); +%! disp ("Notice how much bigger the speedup is than in example 1."); %!test %! [order, n, T_f1, T_f2] = speed ("airy (x)", "x = rand (n, 10)", [100, 1000]); @@ -441,6 +441,6 @@ %! assert (length (T_f2) > 10); %% Test input validation -%!error speed (); -%!error speed (1, 2, 3, 4, 5, 6, 7); +%!error speed () +%!error speed (1, 2, 3, 4, 5, 6, 7)
--- a/scripts/testfun/test.m +++ b/scripts/testfun/test.m @@ -19,11 +19,11 @@ ## -*- texinfo -*- ## @deftypefn {Command} {} test @var{name} ## @deftypefnx {Command} {} test @var{name} quiet|normal|verbose -## @deftypefnx {Function File} {} test ('@var{name}', 'quiet|normal|verbose', @var{fid}) -## @deftypefnx {Function File} {} test ([], 'explain', @var{fid}) +## @deftypefnx {Function File} {} test ("@var{name}", "quiet|normal|verbose", @var{fid}) +## @deftypefnx {Function File} {} test ([], "explain", @var{fid}) ## @deftypefnx {Function File} {@var{success} =} test (@dots{}) ## @deftypefnx {Function File} {[@var{n}, @var{max}] =} test (@dots{}) -## @deftypefnx {Function File} {[@var{code}, @var{idx}] =} test ('@var{name}', 'grabdemo') +## @deftypefnx {Function File} {[@var{code}, @var{idx}] =} test ("@var{name}", "grabdemo") ## ## Perform tests from the first file in the loadpath matching @var{name}. ## @code{test} can be called as a command or as a function. Called with @@ -34,14 +34,14 @@ ## output is selected. ## ## @table @asis -## @item 'quiet' +## @item "quiet" ## Don't report all the tests as they happen, just the errors. ## -## @item 'normal' +## @item "normal" ## Report all tests as they happen, but don't do tests which require ## user interaction. ## -## @item 'verbose' +## @item "verbose" ## Do tests which require user interaction. ## @end table ## @@ -58,12 +58,12 @@ ## @var{n} and @var{max}, the number of successful tests and the total number ## of tests in the file @var{name} are returned. ## -## If the second argument is the string 'grabdemo', the contents of the demo +## If the second argument is the string "grabdemo", the contents of the demo ## blocks are extracted but not executed. Code for all code blocks is ## concatenated and returned as @var{code} with @var{idx} being a vector of ## positions of the ends of the demo blocks. ## -## If the second argument is 'explain', then @var{name} is ignored and an +## If the second argument is "explain", then @var{name} is ignored and an ## explanation of the line markers used is written to the file @var{fid}. ## @seealso{assert, fail, error, demo, example} ## @end deftypefn
--- a/scripts/time/addtodate.m +++ b/scripts/time/addtodate.m @@ -77,7 +77,7 @@ ## tests %!shared d -%! d = datenum (2008, 1, 1); +%! d = datenum (2008, 1, 1); ## Identity %!assert (addtodate (d, 0, "year"), d) %!assert (addtodate (d, 0, "month"), d)
--- a/scripts/time/asctime.m +++ b/scripts/time/asctime.m @@ -47,8 +47,8 @@ %!test %! t = time (); -%! assert(strcmp (asctime (localtime (t)), ctime (t))); +%! assert (strcmp (asctime (localtime (t)), ctime (t))); -%!error asctime (); -%!error asctime (1, 2); +%!error asctime () +%!error asctime (1, 2)
--- a/scripts/time/clock.m +++ b/scripts/time/clock.m @@ -57,5 +57,5 @@ %!test %! t1 = clock; %! t2 = str2num (strftime ("[%Y, %m, %d, %H, %M, %S]", localtime (time ()))); -%! assert(etime (t1, t2) < 1); +%! assert (etime (t1, t2) < 1);
--- a/scripts/time/ctime.m +++ b/scripts/time/ctime.m @@ -26,7 +26,7 @@ ## @example ## @group ## ctime (time ()) -## @result{} "Mon Feb 17 01:15:06 1997" +## @result{} "Mon Feb 17 01:15:06 1997" ## @end group ## @end example ## @seealso{asctime, time, localtime} @@ -47,8 +47,8 @@ %!test %! t = time (); -%! assert(strcmp (asctime (localtime (t)), ctime (t))); +%! assert (strcmp (asctime (localtime (t)), ctime (t))); -%!error ctime (); -%!error ctime (1, 2); +%!error ctime () +%!error ctime (1, 2)
--- a/scripts/time/date.m +++ b/scripts/time/date.m @@ -25,7 +25,7 @@ ## @example ## @group ## date () -## @result{} "20-Aug-1993" +## @result{} "20-Aug-1993" ## @end group ## @end example ## @seealso{now, clock, datestr, localtime} @@ -39,5 +39,6 @@ endfunction -%!assert(strcmp (date (), strftime ("%d-%b-%Y", localtime (time ())))); +%!assert (strcmp (date (), strftime ("%d-%b-%Y", localtime (time ())))) +
--- a/scripts/time/datenum.m +++ b/scripts/time/datenum.m @@ -159,19 +159,19 @@ %! assert (datenum (t(1,:), t(2,:), t(3,:), t(4,:), t(5,:), t(6,:)), n, 2*eps); ## Test mixed vectors and scalars -%!assert (datenum([2008;2009], 1, 1), [datenum(2008, 1, 1);datenum(2009, 1, 1)]); -%!assert (datenum(2008, [1;2], 1), [datenum(2008, 1, 1);datenum(2008, 2, 1)]); -%!assert (datenum(2008, 1, [1;2]), [datenum(2008, 1, 1);datenum(2008, 1, 2)]); -%!assert (datenum([2008;2009], [1;2], 1), [datenum(2008, 1, 1);datenum(2009, 2, 1)]); -%!assert (datenum([2008;2009], 1, [1;2]), [datenum(2008, 1, 1);datenum(2009, 1, 2)]); -%!assert (datenum(2008, [1;2], [1;2]), [datenum(2008, 1, 1);datenum(2008, 2, 2)]); +%!assert (datenum ([2008;2009],1,1), [datenum(2008,1,1);datenum(2009,1,1)]) +%!assert (datenum (2008, [1;2], 1), [datenum(2008,1,1);datenum(2008,2,1)]) +%!assert (datenum (2008, 1, [1;2]), [datenum(2008,1,1);datenum(2008,1,2)]) +%!assert (datenum ([2008;2009], [1;2], 1), [datenum(2008,1,1);datenum(2009,2,1)]) +%!assert (datenum ([2008;2009], 1, [1;2]), [datenum(2008,1,1);datenum(2009,1,2)]) +%!assert (datenum (2008, [1;2], [1;2]), [datenum(2008,1,1);datenum(2008,2,2)]) ## And the other orientation -%!assert (datenum([2008 2009], 1, 1), [datenum(2008, 1, 1) datenum(2009, 1, 1)]); -%!assert (datenum(2008, [1 2], 1), [datenum(2008, 1, 1) datenum(2008, 2, 1)]); -%!assert (datenum(2008, 1, [1 2]), [datenum(2008, 1, 1) datenum(2008, 1, 2)]); -%!assert (datenum([2008 2009], [1 2], 1), [datenum(2008, 1, 1) datenum(2009, 2, 1)]); -%!assert (datenum([2008 2009], 1, [1 2]), [datenum(2008, 1, 1) datenum(2009, 1, 2)]); -%!assert (datenum(2008, [1 2], [1 2]), [datenum(2008, 1, 1) datenum(2008, 2, 2)]); +%!assert (datenum ([2008 2009], 1, 1), [datenum(2008,1,1) datenum(2009,1,1)]) +%!assert (datenum (2008, [1 2], 1), [datenum(2008,1,1) datenum(2008,2,1)]) +%!assert (datenum (2008, 1, [1 2]), [datenum(2008,1,1) datenum(2008,1,2)]) +%!assert (datenum ([2008 2009], [1 2], 1), [datenum(2008,1,1) datenum(2009,2,1)]) +%!assert (datenum ([2008 2009], 1, [1 2]), [datenum(2008,1,1) datenum(2009,1,2)]) +%!assert (datenum (2008, [1 2], [1 2]), [datenum(2008,1,1) datenum(2008,2,2)]) ## Test string and cellstr inputs %!assert (datenum ("5/19/2001"), 730990) %!assert (datenum ({"5/19/2001"}), 730990)
--- a/scripts/time/datetick.m +++ b/scripts/time/datetick.m @@ -65,7 +65,7 @@ %! plot (yr, pr); %! xlabel ("year"); %! ylabel ("average price"); -%! ax = gca (); +%! ax = gca; %! set (ax, "xtick", datenum (1990:5:2005,1,1)); %! datetick (2, "keepticks"); %! set (ax, "ytick", 12:16);
--- a/scripts/time/datevec.m +++ b/scripts/time/datevec.m @@ -297,7 +297,7 @@ %!assert (datevec ("15:38:21.25", "HH:MM:SS.FFF"), [nowvec(1:3),15,38,21.025]) # Other tests -%!assert (datenum (datevec ([-1e4:1e4])), [-1e4:1e4]') +%!assert (datenum (datevec ([-1e4:1e4])), [-1e4:1e4]'); %!test %! t = linspace (-2e5, 2e5, 10993); %! assert (all (abs (datenum (datevec (t)) - t') < 1e-5));
--- a/scripts/time/eomday.m +++ b/scripts/time/eomday.m @@ -54,7 +54,7 @@ %!assert (eomday ([-800,800],2), [29,29]) %!assert (eomday (2001,1:12), [31,28,31,30,31,30,31,31,30,31,30,31]) %!assert (eomday (1:3,1:3), [31,28,31]) -%!assert (eomday (1:2000,2)', datevec(datenum(1:2000,3,0))(:,3)) +%!assert (eomday (1:2000,2)', datevec (datenum (1:2000,3,0))(:,3)) %!assert ([1900:1999](find(eomday(1900:1999,2*ones(1,100))==29)), [1904,1908,1912,1916,1920,1924,1928,1932,1936,1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,1980,1984,1988,1992,1996]) %!assert (eomday ([2004;2005], [2;2]), [29;28])
--- a/scripts/time/etime.m +++ b/scripts/time/etime.m @@ -51,14 +51,14 @@ endfunction -%!assert (etime ([1900,12,31,23,59,59],[1901,1,1,0,0,0]),-1) -%!assert (etime ([1900,2,28,23,59,59],[1900,3,1,0,0,0]),-1) -%!assert (etime ([2000,2,28,23,59,59],[2000,3,1,0,0,0]),-86401) -%!assert (etime ([1996,2,28,23,59,59],[1996,3,1,0,0,0]),-86401) +%!assert (etime ([1900,12,31,23,59,59], [1901,1,1,0,0,0]), -1) +%!assert (etime ([1900,2,28,23,59,59], [1900,3,1,0,0,0]), -1) +%!assert (etime ([2000,2,28,23,59,59], [2000,3,1,0,0,0]), -86401) +%!assert (etime ([1996,2,28,23,59,59], [1996,3,1,0,0,0]), -86401) %!test %! t1 = [1900,12,31,23,59,59; 1900,2,28,23,59,59]; %! t2 = [1901,1,1,0,0,0; 1900,3,1,0,0,0]; -%! assert(etime(t2, t1), [1;1]); +%! assert (etime (t2, t1), [1;1]); %!test %! t1 = [1993, 8, 20, 4, 56, 1];
--- a/scripts/time/is_leap_year.m +++ b/scripts/time/is_leap_year.m @@ -26,7 +26,7 @@ ## @example ## @group ## is_leap_year (2000) -## @result{} 1 +## @result{} 1 ## @end group ## @end example ## @seealso{weekday, eomday, calendar} @@ -56,5 +56,5 @@ %!assert (is_leap_year (1800), false) %!assert (is_leap_year (1600), true) -%!error is_leap_year (1, 2); +%!error is_leap_year (1, 2)
--- a/scripts/time/now.m +++ b/scripts/time/now.m @@ -54,8 +54,9 @@ endfunction -%!assert (isnumeric (now ())); -%!assert (now () > 0); -%!assert (now () <= now ()); +%!assert (isnumeric (now ())) +%!assert (now () > 0) +%!assert (now () <= now ()) -%!error now (1); +%!error now (1) +
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc +++ b/src/DLD-FUNCTIONS/__delaunayn__.cc @@ -49,6 +49,7 @@ #include "defun-dld.h" #include "error.h" #include "oct-obj.h" +#include "unwind-prot.h" #if defined (HAVE_QHULL) # include "oct-qhull.h" @@ -57,6 +58,12 @@ # endif #endif +static void +close_fcn (FILE *f) +{ + gnulib::fclose (f); +} + DEFUN_DLD (__delaunayn__, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{T} =} __delaunayn__ (@var{pts})\n\ @@ -121,10 +128,24 @@ sprintf (flags, "qhull d %s", options.c_str ()); - // Replace the 0 pointer with stdout for debugging information - FILE *outfile = 0; + unwind_protect frame; + + // Replace the outfile pointer with stdout for debugging information. +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) + FILE *outfile = gnulib::fopen ("NUL", "w"); +#else + FILE *outfile = gnulib::fopen ("/dev/null", "w"); +#endif FILE *errfile = stderr; - + + if (outfile) + frame.add_fcn (close_fcn, outfile); + else + { + error ("__delaunayn__: unable to create temporary file for output"); + return retval; + } + int exitcode = qh_new_qhull (dim, n, pt_array, ismalloc, flags, outfile, errfile); if (! exitcode)
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc @@ -1168,12 +1168,12 @@ pos(2) = ww; pos(3) = hh - status_h - menu_h; - fp.set_position (pos); + fp.set_boundingbox (pos, true); } void draw (void) { - Matrix pos = fp.get_position ().matrix_value (); + Matrix pos = fp.get_boundingbox (true); Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h); return Fl_Window::draw (); @@ -1296,12 +1296,12 @@ dynamic_cast<axes::properties&> (ax_obj.get_properties ()); double x0, y0, x1, y1; - Matrix pos = fp.get_position ().matrix_value (); + Matrix pos = fp.get_boundingbox (true); pixel2pos (ax_obj, pos_x, pos_y, x0, y0); pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), x1, y1); if (gui_mode == pan_zoom) - ap.translate_view (x0 - x1, y0 - y1); + ap.translate_view (x0, x1, y0, y1); else if (gui_mode == rotate_zoom) { double daz, del; @@ -2055,6 +2055,7 @@ @deftypefnx {Built-in Function} {} gui_mode (@var{mode})\n\ Query or set the GUI mode for the current graphics toolkit.\n\ The @var{mode} argument can be one of the following strings:\n\ +\n\ @table @asis\n\ @item '2d'\n\ Allows panning and zooming of current axes.\n\
--- a/src/DLD-FUNCTIONS/__voronoi__.cc +++ b/src/DLD-FUNCTIONS/__voronoi__.cc @@ -44,6 +44,7 @@ #include "defun-dld.h" #include "error.h" #include "oct-obj.h" +#include "unwind-prot.h" #if defined (HAVE_QHULL) # include "oct-qhull.h" @@ -52,6 +53,12 @@ # endif #endif +static void +close_fcn (FILE *f) +{ + gnulib::fclose (f); +} + DEFUN_DLD (__voronoi__, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts})\n\ @@ -115,10 +122,24 @@ boolT ismalloc = false; - // Replace the 0 pointer with stdout for debugging information - FILE *outfile = 0; + unwind_protect frame; + + // Replace the outfile pointer with stdout for debugging information. +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) + FILE *outfile = gnulib::fopen ("NUL", "w"); +#else + FILE *outfile = gnulib::fopen ("/dev/null", "w"); +#endif FILE *errfile = stderr; + if (outfile) + frame.add_fcn (close_fcn, outfile); + else + { + error ("__voronoi__: unable to create temporary file for output"); + return retval; + } + // qh_new_qhull command and points arguments are not const... std::string cmd = "qhull v" + options;
--- a/src/DLD-FUNCTIONS/besselj.cc +++ b/src/DLD-FUNCTIONS/besselj.cc @@ -531,10 +531,10 @@ @group\n\ K Function Scale factor (if 'opt' is supplied)\n\ --- -------- ---------------------------------------\n\ - 0 Ai (Z) exp ((2/3) * Z * sqrt (Z))\n\ - 1 dAi(Z)/dZ exp ((2/3) * Z * sqrt (Z))\n\ - 2 Bi (Z) exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\ - 3 dBi(Z)/dZ exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\ + 0 Ai (Z) exp (2/3 * Z * sqrt (Z))\n\ + 1 dAi(Z)/dZ exp (2/3 * Z * sqrt (Z))\n\ + 2 Bi (Z) exp (-abs (real (2/3 * Z *sqrt (Z))))\n\ + 3 dBi(Z)/dZ exp (-abs (real (2/3 * Z *sqrt (Z))))\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/betainc.cc +++ b/src/DLD-FUNCTIONS/betainc.cc @@ -50,8 +50,8 @@ x\n\ 1 /\n\ betainc (x, a, b) = ----------- | t^(a-1) (1-t)^(b-1) dt.\n\ - beta (a, b) /\n\ - t=0\n\ + beta (a, b) /\n\ + t=0\n\ @end group\n\ @end smallexample\n\ \n\
--- a/src/DLD-FUNCTIONS/cellfun.cc +++ b/src/DLD-FUNCTIONS/cellfun.cc @@ -257,8 +257,8 @@ @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{C})\n\ @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{C}, @var{D})\n\ @deftypefnx {Loadable Function} {[@var{a}, @dots{}] =} cellfun (@dots{})\n\ -@deftypefnx {Loadable Function} {} cellfun (@dots{}, 'ErrorHandler', @var{errfunc})\n\ -@deftypefnx {Loadable Function} {} cellfun (@dots{}, 'UniformOutput', @var{val})\n\ +@deftypefnx {Loadable Function} {} cellfun (@dots{}, \"ErrorHandler\", @var{errfunc})\n\ +@deftypefnx {Loadable Function} {} cellfun (@dots{}, \"UniformOutput\", @var{val})\n\ \n\ Evaluate the function named @var{name} on the elements of the cell array\n\ @var{C}. Elements in @var{C} are passed on to the named function\n\ @@ -303,7 +303,7 @@ @example\n\ @group\n\ cellfun (\"atan2\", @{1, 0@}, @{0, 1@})\n\ - @result{}ans = [1.57080 0.00000]\n\ + @result{} [ 1.57080 0.00000 ]\n\ @end group\n\ @end example\n\ \n\ @@ -330,21 +330,21 @@ the input arguments. Input arguments that are singleton (1x1) cells will be\n\ automatically expanded to the size of the other arguments.\n\ \n\ -If the parameter 'UniformOutput' is set to true (the default), then the\n\ +If the parameter \"UniformOutput\" is set to true (the default), then the\n\ function must return scalars which will be concatenated into the return\n\ -array(s). If 'UniformOutput' is false, the outputs are concatenated into a\n\ +array(s). If \"UniformOutput\" is false, the outputs are concatenated into a\n\ cell array (or cell arrays). For example:\n\ \n\ @example\n\ @group\n\ cellfun (\"tolower\", @{\"Foo\", \"Bar\", \"FooBar\"@},\n\ - \"UniformOutput\",false)\n\ -@result{} ans = @{\"foo\", \"bar\", \"foobar\"@}\n\ + \"UniformOutput\", false)\n\ +@result{} @{\"foo\", \"bar\", \"foobar\"@}\n\ @end group\n\ @end example\n\ \n\ -Given the parameter 'ErrorHandler', then @var{errfunc} defines a function to\n\ -call in case @var{func} generates an error. The form of the function is\n\ +Given the parameter \"ErrorHandler\", then @var{errfunc} defines a function\n\ +to call in case @var{func} generates an error. The form of the function is\n\ \n\ @example\n\ function [@dots{}] = errfunc (@var{s}, @dots{})\n\ @@ -360,8 +360,8 @@ @example\n\ @group\n\ function y = foo (s, x), y = NaN; endfunction\n\ -cellfun (\"factorial\", @{-1,2@}, 'ErrorHandler', @@foo)\n\ -@result{} ans = [NaN 2]\n\ +cellfun (\"factorial\", @{-1,2@}, \"ErrorHandler\", @@foo)\n\ +@result{} [NaN 2]\n\ @end group\n\ @end example\n\ \n\ @@ -1042,7 +1042,7 @@ @example\n\ @group\n\ arrayfun (@@atan2, [1, 0], [0, 1])\n\ -@result{} ans = [1.5708 0.0000]\n\ + @result{} [ 1.5708 0.0000 ]\n\ @end group\n\ @end example\n\ \n\ @@ -1056,12 +1056,12 @@ @example\n\ @group\n\ arrayfun (@@(x,y) x:y, \"abc\", \"def\", \"UniformOutput\", false)\n\ -@result{} ans =\n\ - @{\n\ - [1,1] = abcd\n\ - [1,2] = bcde\n\ - [1,3] = cdef\n\ - @}\n\ +@result{}\n\ + @{\n\ + [1,1] = abcd\n\ + [1,2] = bcde\n\ + [1,3] = cdef\n\ + @}\n\ @end group\n\ @end example\n\ \n\ @@ -1075,18 +1075,18 @@ @result{}\n\ A =\n\ @{\n\ - [1,1] = 1\n\ - [2,1] = [](0x0)\n\ + [1,1] = 1\n\ + [2,1] = [](0x0)\n\ @}\n\ B =\n\ @{\n\ - [1,1] = 1\n\ - [2,1] = [](0x0)\n\ + [1,1] = 1\n\ + [2,1] = [](0x0)\n\ @}\n\ C =\n\ @{\n\ - [1,1] = 10\n\ - [2,1] = [](0x0)\n\ + [1,1] = 10\n\ + [2,1] = [](0x0)\n\ @}\n\ @end group\n\ @end example\n\ @@ -1115,11 +1115,11 @@ @group\n\ function y = ferr (s, x), y = \"MyString\"; endfunction\n\ arrayfun (@@str2num, [1234],\n\ - \"UniformOutput\", false, \"ErrorHandler\", @@ferr)\n\ -@result{} ans =\n\ - @{\n\ + \"UniformOutput\", false, \"ErrorHandler\", @@ferr)\n\ +@result{}\n\ + @{\n\ [1,1] = MyString\n\ - @}\n\ + @}\n\ @end group\n\ @end example\n\ \n\ @@ -1810,24 +1810,24 @@ \n\ @example\n\ @group\n\ -num2cell([1,2;3,4])\n\ - @result{} ans =\n\ - @{\n\ - [1,1] = 1\n\ - [2,1] = 3\n\ - [1,2] = 2\n\ - [2,2] = 4\n\ - @}\n\ -num2cell([1,2;3,4],1)\n\ - @result{} ans =\n\ - @{\n\ - [1,1] =\n\ - 1\n\ - 3\n\ - [1,2] =\n\ - 2\n\ - 4\n\ - @}\n\ +num2cell ([1,2;3,4])\n\ + @result{}\n\ + @{\n\ + [1,1] = 1\n\ + [2,1] = 3\n\ + [1,2] = 2\n\ + [2,2] = 4\n\ + @}\n\ +num2cell ([1,2;3,4],1)\n\ + @result{}\n\ + @{\n\ + [1,1] =\n\ + 1\n\ + 3\n\ + [1,2] =\n\ + 2\n\ + 4\n\ + @}\n\ @end group\n\ @end example\n\ \n\ @@ -2149,25 +2149,26 @@ An example of the use of mat2cell is\n\ \n\ @example\n\ -mat2cell (reshape(1:16,4,4),[3,1],[3,1])\n\ -@result{} @{\n\ - [1,1] =\n\ +mat2cell (reshape (1:16,4,4), [3,1], [3,1])\n\ +@result{}\n\ +@{\n\ + [1,1] =\n\ \n\ - 1 5 9\n\ - 2 6 10\n\ - 3 7 11\n\ -\n\ - [2,1] =\n\ + 1 5 9\n\ + 2 6 10\n\ + 3 7 11\n\ \n\ - 4 8 12\n\ + [2,1] =\n\ \n\ - [1,2] =\n\ + 4 8 12\n\ +\n\ + [1,2] =\n\ \n\ - 13\n\ - 14\n\ - 15\n\ + 13\n\ + 14\n\ + 15\n\ \n\ - [2,2] = 16\n\ + [2,2] = 16\n\ @}\n\ @end example\n\ @seealso{num2cell, cell2mat}\n\ @@ -2430,10 +2431,10 @@ \n\ @example\n\ @group\n\ - Y = cell (size (X));\n\ - for i = 1:numel (X)\n\ - Y@{i@} = X@{i@}(varargin@{:@});\n\ - endfor\n\ +Y = cell (size (X));\n\ +for i = 1:numel (X)\n\ + Y@{i@} = X@{i@}(varargin@{:@});\n\ +endfor\n\ @end group\n\ @end example\n\ @seealso{cellslices, cellfun}\n\
--- a/src/DLD-FUNCTIONS/chol.cc +++ b/src/DLD-FUNCTIONS/chol.cc @@ -65,9 +65,9 @@ @deftypefn {Loadable Function} {@var{R} =} chol (@var{A})\n\ @deftypefnx {Loadable Function} {[@var{R}, @var{p}] =} chol (@var{A})\n\ @deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S})\n\ -@deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S}, 'vector')\n\ -@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, 'lower')\n\ -@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, 'upper')\n\ +@deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S}, \"vector\")\n\ +@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"lower\")\n\ +@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"upper\")\n\ @cindex Cholesky factorization\n\ Compute the Cholesky@tie{}factor, @var{R}, of the symmetric positive definite\n\ matrix @var{A}, where\n\ @@ -103,7 +103,7 @@ @end ifnottex\n\ \n\ The sparsity preserving permutation is generally returned as a matrix.\n\ -However, given the flag 'vector', @var{Q} will be returned as a vector\n\ +However, given the flag \"vector\", @var{Q} will be returned as a vector\n\ such that\n\ @tex\n\ $ R^T R = A (Q, Q)$.\n\ @@ -116,7 +116,7 @@ \n\ @end ifnottex\n\ \n\ -Called with either a sparse or full matrix and using the 'lower' flag,\n\ +Called with either a sparse or full matrix and using the \"lower\" flag,\n\ @code{chol} returns the lower triangular factorization such that\n\ @tex\n\ $ L L^T = A $.\n\ @@ -129,7 +129,7 @@ \n\ @end ifnottex\n\ \n\ -For full matrices, if the 'lower' flag is set only the lower triangular part\n\ +For full matrices, if the \"lower\" flag is set only the lower triangular part\n\ of the matrix is used for the factorization, otherwise the upper triangular\n\ part is used.\n\ \n\
--- a/src/DLD-FUNCTIONS/colamd.cc +++ b/src/DLD-FUNCTIONS/colamd.cc @@ -651,7 +651,7 @@ is assumed to be symmetric and the symmetric elimination tree is\n\ returned. The argument @var{typ} controls whether a symmetric or\n\ column elimination tree is returned. Valid values of @var{typ} are\n\ -'sym' or 'col', for symmetric or column elimination tree respectively\n\ +\"sym\" or \"col\", for symmetric or column elimination tree respectively\n\ \n\ Called with a second argument, @code{etree} also returns the postorder\n\ permutations on the tree.\n\
--- a/src/DLD-FUNCTIONS/config-module.awk +++ b/src/DLD-FUNCTIONS/config-module.awk @@ -71,7 +71,7 @@ } printf ("DLD_FUNCTIONS_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS)\n", basename, ldflags[i]); - printf ("DLD_FUNCTIONS_%s_la_LIBADD = liboctinterp.la ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n", + printf ("DLD_FUNCTIONS_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n", basename, libraries[i]); } }
--- a/src/DLD-FUNCTIONS/convhulln.cc +++ b/src/DLD-FUNCTIONS/convhulln.cc @@ -40,6 +40,7 @@ #include "error.h" #include "oct-obj.h" #include "parse.h" +#include "unwind-prot.h" #if defined (HAVE_QHULL) # include "oct-qhull.h" @@ -48,6 +49,12 @@ # endif #endif +static void +close_fcn (FILE *f) +{ + gnulib::fclose (f); +} + DEFUN_DLD (convhulln, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{h} =} convhulln (@var{pts})\n\ @@ -128,10 +135,24 @@ boolT ismalloc = false; - // Replace the 0 pointer with stdout for debugging information. - FILE *outfile = 0; + unwind_protect frame; + + // Replace the outfile pointer with stdout for debugging information. +#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) + FILE *outfile = gnulib::fopen ("NUL", "w"); +#else + FILE *outfile = gnulib::fopen ("/dev/null", "w"); +#endif FILE *errfile = stderr; - + + if (outfile) + frame.add_fcn (close_fcn, outfile); + else + { + error ("convhulln: unable to create temporary file for output"); + return retval; + } + // qh_new_qhull command and points arguments are not const... std::string cmd = "qhull" + options; @@ -268,11 +289,16 @@ /* %!testif HAVE_QHULL %! cube = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1]; -%! [h, v] = convhulln (cube); -%! assert (size (h), [6 4]); -%! h = sortrows (sort (h, 2), [1:4]); -%! assert (h, [1 2 3 4; 1 2 5 6; 1 4 5 8; 2 3 6 7; 3 4 7 8; 5 6 7 8]); +%! [h, v] = convhulln (cube, "Qt"); +%! assert (size (h), [12 3]); +%! h = sortrows (sort (h, 2), [1:3]); +%! assert (h, [1 2 4; 1 2 6; 1 4 8; 1 5 6; 1 5 8; 2 3 4; 2 3 7; 2 6 7; 3 4 7; 4 7 8; 5 6 7; 5 7 8]); %! assert (v, 1, 10*eps); +%! [h2, v2] = convhulln (cube); % Test defaut option = "Qt" +%! assert (size (h2), size (h)) +%! h2 = sortrows (sort (h2, 2), [1:3]); +%! assert (h2, h); +%! assert (v2, v, 10*eps); %!testif HAVE_QHULL %! cube = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
--- a/src/DLD-FUNCTIONS/dlmread.cc +++ b/src/DLD-FUNCTIONS/dlmread.cc @@ -173,7 +173,7 @@ The @var{range} parameter may be a 4-element vector containing the upper\n\ left and lower right corner @code{[@var{R0},@var{C0},@var{R1},@var{C1}]}\n\ where the lowest index value is zero. Alternatively, a spreadsheet style\n\ -range such as 'A2..Q15' or 'T1:AA5' can be used. The lowest alphabetical\n\ +range such as \"A2..Q15\" or \"T1:AA5\" can be used. The lowest alphabetical\n\ index 'A' refers to the first column. The lowest row index is 1.\n\ \n\ @var{file} should be a file name or file id given by @code{fopen}. In the\n\
--- a/src/DLD-FUNCTIONS/dot.cc +++ b/src/DLD-FUNCTIONS/dot.cc @@ -262,9 +262,9 @@ \n\ @example\n\ @group\n\ - for i = 1:prod (size (@var{A})(3:end))\n\ - @var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)\n\ - endfor\n\ +for i = 1:prod (size (@var{A})(3:end))\n\ + @var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)\n\ +endfor\n\ @end group\n\ @end example\n\ @end deftypefn")
--- a/src/DLD-FUNCTIONS/eigs.cc +++ b/src/DLD-FUNCTIONS/eigs.cc @@ -184,32 +184,32 @@ @var{sigma} is a string, it must have one of the following values.\n\ \n\ @table @asis\n\ -@item 'lm'\n\ +@item \"lm\"\n\ Largest Magnitude (default).\n\ \n\ -@item 'sm'\n\ +@item \"sm\"\n\ Smallest Magnitude.\n\ \n\ -@item 'la'\n\ +@item \"la\"\n\ Largest Algebraic (valid only for real symmetric problems).\n\ \n\ -@item 'sa'\n\ +@item \"sa\"\n\ Smallest Algebraic (valid only for real symmetric problems).\n\ \n\ -@item 'be'\n\ +@item \"be\"\n\ Both Ends, with one more from the high-end if @var{k} is odd (valid only for\n\ real symmetric problems).\n\ \n\ -@item 'lr'\n\ +@item \"lr\"\n\ Largest Real part (valid only for complex or unsymmetric problems).\n\ \n\ -@item 'sr'\n\ +@item \"sr\"\n\ Smallest Real part (valid only for complex or unsymmetric problems).\n\ \n\ -@item 'li'\n\ +@item \"li\"\n\ Largest Imaginary part (valid only for complex or unsymmetric problems).\n\ \n\ -@item 'si'\n\ +@item \"si\"\n\ Smallest Imaginary part (valid only for complex or unsymmetric problems).\n\ @end table\n\ \n\ @@ -270,10 +270,10 @@ \n\ @table @code\n\ @item A * x\n\ -if @var{sigma} is not given or is a string other than 'sm'.\n\ +if @var{sigma} is not given or is a string other than \"sm\".\n\ \n\ @item A \\ x\n\ -if @var{sigma} is 0 or 'sm'.\n\ +if @var{sigma} is 0 or \"sm\".\n\ \n\ @item (A - sigma * I) \\ x\n\ for the standard eigenvalue problem, where @code{I} is the identity matrix of\n\
--- a/src/DLD-FUNCTIONS/fftw.cc +++ b/src/DLD-FUNCTIONS/fftw.cc @@ -34,10 +34,10 @@ DEFUN_DLD (fftw, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {@var{method} =} fftw ('planner')\n\ -@deftypefnx {Loadable Function} {} fftw ('planner', @var{method})\n\ -@deftypefnx {Loadable Function} {@var{wisdom} =} fftw ('dwisdom')\n\ -@deftypefnx {Loadable Function} {} fftw ('dwisdom', @var{wisdom})\n\ +@deftypefn {Loadable Function} {@var{method} =} fftw (\"planner\")\n\ +@deftypefnx {Loadable Function} {} fftw (\"planner\", @var{method})\n\ +@deftypefnx {Loadable Function} {@var{wisdom} =} fftw (\"dwisdom\")\n\ +@deftypefnx {Loadable Function} {} fftw (\"dwisdom\", @var{wisdom})\n\ \n\ Manage @sc{fftw} wisdom data. Wisdom data can be used to significantly\n\ accelerate the calculation of the FFTs, but implies an initial cost\n\ @@ -47,7 +47,7 @@ the @code{fftw} function can be used to import wisdom. For example,\n\ \n\ @example\n\ -@var{wisdom} = fftw ('dwisdom')\n\ +@var{wisdom} = fftw (\"dwisdom\")\n\ @end example\n\ \n\ @noindent\n\ @@ -57,7 +57,7 @@ reimported as follows\n\ \n\ @example\n\ -fftw ('dwisdom', @var{wisdom})\n\ +fftw (\"dwisdom\", @var{wisdom})\n\ @end example\n\ \n\ If @var{wisdom} is an empty matrix, then the wisdom used is cleared.\n\ @@ -68,42 +68,42 @@ wisdom can be treated:\n\ \n\ @table @asis\n\ -@item 'estimate'\n\ +@item \"estimate\"\n\ Specifies that no run-time measurement of the optimal means of\n\ calculating a particular is performed, and a simple heuristic is used\n\ to pick a (probably sub-optimal) plan. The advantage of this method is\n\ that there is little or no overhead in the generation of the plan, which\n\ is appropriate for a Fourier transform that will be calculated once.\n\ \n\ -@item 'measure'\n\ +@item \"measure\"\n\ In this case a range of algorithms to perform the transform is considered\n\ and the best is selected based on their execution time.\n\ \n\ -@item 'patient'\n\ -Similar to 'measure', but a wider range of algorithms is considered.\n\ +@item \"patient\"\n\ +Similar to \"measure\", but a wider range of algorithms is considered.\n\ \n\ -@item 'exhaustive'\n\ -Like 'measure', but all possible algorithms that may be used to\n\ +@item \"exhaustive\"\n\ +Like \"measure\", but all possible algorithms that may be used to\n\ treat the transform are considered.\n\ \n\ -@item 'hybrid'\n\ +@item \"hybrid\"\n\ As run-time measurement of the algorithm can be expensive, this is a\n\ -compromise where 'measure' is used for transforms up to the size of 8192\n\ -and beyond that the 'estimate' method is used.\n\ +compromise where \"measure\" is used for transforms up to the size of 8192\n\ +and beyond that the \"estimate\" method is used.\n\ @end table\n\ \n\ -The default method is 'estimate'. The current method can\n\ +The default method is \"estimate\". The current method can\n\ be queried with\n\ \n\ @example\n\ -@var{method} = fftw ('planner')\n\ +@var{method} = fftw (\"planner\")\n\ @end example\n\ \n\ @noindent\n\ or set by using\n\ \n\ @example\n\ -fftw ('planner', @var{method})\n\ +fftw (\"planner\", @var{method})\n\ @end example\n\ \n\ Note that calculated wisdom will be lost when restarting Octave. However,\n\
--- a/src/DLD-FUNCTIONS/filter.cc +++ b/src/DLD-FUNCTIONS/filter.cc @@ -304,9 +304,9 @@ \n\ @smallexample\n\ @group\n\ - N M\n\ - SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x)\n\ - k=0 k=0\n\ + N M\n\ +SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x)\n\ +k=0 k=0\n\ @end group\n\ @end smallexample\n\ \n\ @@ -333,9 +333,9 @@ \n\ @smallexample\n\ @group\n\ - N M\n\ - y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x)\n\ - k=1 k=0\n\ + N M\n\ +y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x)\n\ + k=1 k=0\n\ @end group\n\ @end smallexample\n\ \n\ @@ -370,13 +370,13 @@ \n\ @example\n\ @group\n\ - M\n\ - SUM d(k+1) z^(-k)\n\ - k=0\n\ - H(z) = ----------------------\n\ - N\n\ - 1 + SUM c(k+1) z^(-k)\n\ - k=1\n\ + M\n\ + SUM d(k+1) z^(-k)\n\ + k=0\n\ +H(z) = ---------------------\n\ + N\n\ + 1 + SUM c(k+1) z^(-k)\n\ + k=1\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/find.cc +++ b/src/DLD-FUNCTIONS/find.cc @@ -347,7 +347,7 @@ @example\n\ @group\n\ find (eye (2))\n\ - @result{} [ 1; 4 ]\n\ + @result{} [ 1; 4 ]\n\ @end group\n\ @end example\n\ \n\ @@ -357,8 +357,8 @@ @example\n\ @group\n\ [i, j] = find (2 * eye (2))\n\ - @result{} i = [ 1; 2 ]\n\ - @result{} j = [ 1; 2 ]\n\ + @result{} i = [ 1; 2 ]\n\ + @result{} j = [ 1; 2 ]\n\ @end group\n\ @end example\n\ \n\ @@ -368,9 +368,9 @@ @example\n\ @group\n\ [i, j, v] = find (3 * eye (2))\n\ - @result{} i = [ 1; 2 ]\n\ - @result{} j = [ 1; 2 ]\n\ - @result{} v = [ 3; 3 ]\n\ + @result{} i = [ 1; 2 ]\n\ + @result{} j = [ 1; 2 ]\n\ + @result{} v = [ 3; 3 ]\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/gammainc.cc +++ b/src/DLD-FUNCTIONS/gammainc.cc @@ -50,8 +50,8 @@ x\n\ 1 /\n\ gammainc (x, a) = --------- | exp (-t) t^(a-1) dt\n\ - gamma (a) /\n\ - t=0\n\ + gamma (a) /\n\ + t=0\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/gcd.cc +++ b/src/DLD-FUNCTIONS/gcd.cc @@ -443,15 +443,14 @@ individually. All elements must be ordinary or Gaussian (complex)\n\ integers. Note that for Gaussian integers, the gcd is not unique up to\n\ units (multiplication by 1, -1, @var{i} or -@var{i}), so an arbitrary\n\ -greatest common divisor amongst four possible is returned. For example,\n\ +greatest common divisor amongst four possible is returned.\n\ \n\ -@noindent\n\ -and\n\ +Example code:\n\ \n\ @example\n\ @group\n\ gcd ([15, 9], [20, 18])\n\ - @result{} 5 9\n\ + @result{} 5 9\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/givens.cc +++ b/src/DLD-FUNCTIONS/givens.cc @@ -56,8 +56,8 @@ @example\n\ @group\n\ givens (1, 1)\n\ - @result{} 0.70711 0.70711\n\ - -0.70711 0.70711\n\ + @result{} 0.70711 0.70711\n\ + -0.70711 0.70711\n\ @end group\n\ @end example\n\ @end deftypefn")
--- a/src/DLD-FUNCTIONS/hex2num.cc +++ b/src/DLD-FUNCTIONS/hex2num.cc @@ -44,8 +44,8 @@ \n\ @example\n\ @group\n\ -hex2num ([\"4005bf0a8b145769\";\"4024000000000000\"])\n\ -@result{} [2.7183; 10.000]\n\ +hex2num ([\"4005bf0a8b145769\"; \"4024000000000000\"])\n\ + @result{} [2.7183; 10.000]\n\ @end group\n\ @end example\n\ @seealso{num2hex, hex2dec, dec2hex}\n\ @@ -130,7 +130,7 @@ \n\ @example\n\ @group\n\ -num2hex ([-1, 1, e, Inf, NaN, NA]);\n\ +num2hex ([-1, 1, e, Inf, NaN, NA])\n\ @result{} \"bff0000000000000\n\ 3ff0000000000000\n\ 4005bf0a8b145769\n\
--- a/src/DLD-FUNCTIONS/kron.cc +++ b/src/DLD-FUNCTIONS/kron.cc @@ -245,7 +245,7 @@ block as\n\ \n\ @example\n\ -x = [a(i, j) b]\n\ +x = [ a(i,j)*b ]\n\ @end example\n\ \n\ For example:\n\ @@ -253,9 +253,9 @@ @example\n\ @group\n\ kron (1:4, ones (3, 1))\n\ - @result{} 1 2 3 4\n\ - 1 2 3 4\n\ - 1 2 3 4\n\ + @result{} 1 2 3 4\n\ + 1 2 3 4\n\ + 1 2 3 4\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/lu.cc +++ b/src/DLD-FUNCTIONS/lu.cc @@ -69,7 +69,7 @@ @deftypefnx {Loadable Function} {[@var{L}, @var{U}, @var{P}, @var{Q}, @var{R}] =} lu (@var{S})\n\ @deftypefnx {Loadable Function} {[@dots{}] =} lu (@var{S}, @var{thres})\n\ @deftypefnx {Loadable Function} {@var{y} =} lu (@dots{})\n\ -@deftypefnx {Loadable Function} {[@dots{}] =} lu (@dots{}, 'vector')\n\ +@deftypefnx {Loadable Function} {[@dots{}] =} lu (@dots{}, \"vector\")\n\ @cindex LU decomposition\n\ Compute the LU@tie{}decomposition of @var{A}. If @var{A} is full\n\ subroutines from\n\ @@ -125,7 +125,7 @@ pivoting strategy and the second for the symmetric strategy. By default,\n\ the values defined by @code{spparms} are used ([0.1, 0.001]).\n\ \n\ -Given the string argument 'vector', @code{lu} returns the values of @var{P}\n\ +Given the string argument \"vector\", @code{lu} returns the values of @var{P}\n\ and @var{Q} as vector values, such that for full matrix, @code{@var{A}\n\ (@var{P},:) = @var{L} * @var{U}}, and @code{@var{R}(@var{P},:) * @var{A}\n\ (:, @var{Q}) = @var{L} * @var{U}}.\n\ @@ -612,7 +612,7 @@ as obtained by @code{lu}:\n\ \n\ @example\n\ - [@var{L}, @var{U}, @var{P}] = lu (@var{A});\n\ +[@var{L}, @var{U}, @var{P}] = lu (@var{A});\n\ @end example\n\ \n\ @noindent\n\ @@ -620,14 +620,14 @@ either as\n\ \n\ @example\n\ - [@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})\n\ +[@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})\n\ @end example\n\ \n\ @noindent\n\ or\n\ \n\ @example\n\ - [@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\ +[@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\ @end example\n\ \n\ The first form uses the unpivoted algorithm, which is faster, but less\n\
--- a/src/DLD-FUNCTIONS/luinc.cc +++ b/src/DLD-FUNCTIONS/luinc.cc @@ -91,7 +91,7 @@ All other fields in @var{opts} are ignored. The outputs from @code{luinc}\n\ are the same as for @code{lu}.\n\ \n\ -Given the string argument 'vector', @code{luinc} returns the values of\n\ +Given the string argument \"vector\", @code{luinc} returns the values of\n\ @var{p} @var{q} as vector values.\n\ @seealso{sparse, lu}\n\ @end deftypefn")
--- a/src/DLD-FUNCTIONS/matrix_type.cc +++ b/src/DLD-FUNCTIONS/matrix_type.cc @@ -39,59 +39,59 @@ DEFUN_DLD (matrix_type, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{type} =} matrix_type (@var{A})\n\ -@deftypefnx {Loadable Function} {@var{type} =} matrix_type (@var{A}, 'nocompute')\n\ +@deftypefnx {Loadable Function} {@var{type} =} matrix_type (@var{A}, \"nocompute\")\n\ @deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, @var{type})\n\ -@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'upper', @var{perm})\n\ -@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'lower', @var{perm})\n\ -@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'banded', @var{nl}, @var{nu})\n\ +@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"upper\", @var{perm})\n\ +@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"lower\", @var{perm})\n\ +@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"banded\", @var{nl}, @var{nu})\n\ Identify the matrix type or mark a matrix as a particular type. This allows\n\ more rapid solutions of linear equations involving @var{A} to be performed.\n\ Called with a single argument, @code{matrix_type} returns the type of the\n\ matrix and caches it for future use. Called with more than one argument,\n\ @code{matrix_type} allows the type of the matrix to be defined.\n\ \n\ -If the option 'nocompute' is given, the function will not attempt to guess\n\ +If the option \"nocompute\" is given, the function will not attempt to guess\n\ the type if it is still unknown. This is useful for debugging purposes.\n\ \n\ The possible matrix types depend on whether the matrix is full or sparse, and\n\ can be one of the following\n\ \n\ @table @asis\n\ -@item 'unknown'\n\ +@item \"unknown\"\n\ Remove any previously cached matrix type, and mark type as unknown.\n\ \n\ -@item 'full'\n\ +@item \"full\"\n\ Mark the matrix as full.\n\ \n\ -@item 'positive definite'\n\ +@item \"positive definite\"\n\ Probable full positive definite matrix.\n\ \n\ -@item 'diagonal'\n\ +@item \"diagonal\"\n\ Diagonal matrix. (Sparse matrices only)\n\ \n\ -@item 'permuted diagonal'\n\ +@item \"permuted diagonal\"\n\ Permuted Diagonal matrix. The permutation does not need to be specifically\n\ indicated, as the structure of the matrix explicitly gives this. (Sparse\n\ matrices only)\n\ \n\ -@item 'upper'\n\ +@item \"upper\"\n\ Upper triangular. If the optional third argument @var{perm} is given, the\n\ matrix is assumed to be a permuted upper triangular with the permutations\n\ defined by the vector @var{perm}.\n\ \n\ -@item 'lower'\n\ +@item \"lower\"\n\ Lower triangular. If the optional third argument @var{perm} is given, the\n\ matrix is assumed to be a permuted lower triangular with the permutations\n\ defined by the vector @var{perm}.\n\ \n\ -@item 'banded'\n\ -@itemx 'banded positive definite'\n\ +@item \"banded\"\n\ +@itemx \"banded positive definite\"\n\ Banded matrix with the band size of @var{nl} below the diagonal and @var{nu}\n\ above it. If @var{nl} and @var{nu} are 1, then the matrix is tridiagonal and\n\ treated with specialized code. In addition the matrix can be marked as\n\ probably a positive definite. (Sparse matrices only)\n\ \n\ -@item 'singular'\n\ +@item \"singular\"\n\ The matrix is assumed to be singular and will be treated with a minimum norm\n\ solution.\n\ \n\
--- a/src/DLD-FUNCTIONS/max.cc +++ b/src/DLD-FUNCTIONS/max.cc @@ -576,7 +576,7 @@ @example\n\ @group\n\ cummin ([5 4 6 2 3 1])\n\ - @result{} 5 4 4 2 2 1\n\ + @result{} 5 4 4 2 2 1\n\ @end group\n\ @end example\n\ \n\ @@ -618,7 +618,7 @@ @example\n\ @group\n\ cummax ([1 3 2 6 4 5])\n\ - @result{} 1 3 3 6 6 6\n\ + @result{} 1 3 3 6 6 6\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/nproc.cc +++ b/src/DLD-FUNCTIONS/nproc.cc @@ -35,6 +35,7 @@ \n\ If called with the optional argument @var{query}, modify how processors\n\ are counted as follows:\n\ +\n\ @table @code\n\ @item all\n\ total number of processors.\n\
--- a/src/DLD-FUNCTIONS/oct-qhull.h +++ b/src/DLD-FUNCTIONS/oct-qhull.h @@ -27,7 +27,13 @@ extern "C" { -#if defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) +#if defined (HAVE_LIBQHULL_LIBQHULL_H) +# include <libqhull/libqhull.h> +# include <libqhull/qset.h> +# include <libqhull/geom.h> +# include <libqhull/poly.h> +# include <libqhull/io.h> +#elif defined (HAVE_QHULL_LIBQHULL_H) || defined (HAVE_QHULL_QHULL_H) # if defined (HAVE_QHULL_LIBQHULL_H) # include <qhull/libqhull.h> # else
--- a/src/DLD-FUNCTIONS/qr.cc +++ b/src/DLD-FUNCTIONS/qr.cc @@ -113,7 +113,7 @@ @ifnottex\n\ \n\ @example\n\ -@code{min norm(A x - b)}\n\ +min norm(A x - b)\n\ @end example\n\ \n\ @end ifnottex\n\
--- a/src/DLD-FUNCTIONS/quadcc.cc +++ b/src/DLD-FUNCTIONS/quadcc.cc @@ -1485,7 +1485,7 @@ values if given a vector of input values. For example,\n\ \n\ @example\n\ - f = @@(x) x .* sin (1./x) .* sqrt (abs (1 - x));\n\ +f = @@(x) x .* sin (1./x) .* sqrt (abs (1 - x));\n\ @end example\n\ \n\ @noindent\n\ @@ -1505,7 +1505,7 @@ @code{quadcc} would be as follows\n\ \n\ @example\n\ - int = quadcc (f, a, b, 1.0e-6, [ 1 ]);\n\ +int = quadcc (f, a, b, 1.0e-6, [ 1 ]);\n\ @end example\n\ \n\ The result of the integration is returned in @var{q}.\n\
--- a/src/DLD-FUNCTIONS/qz.cc +++ b/src/DLD-FUNCTIONS/qz.cc @@ -322,9 +322,9 @@ @example\n\ @group\n\ \n\ - A * V = B * V * diag (@var{lambda})\n\ - W' * A = diag (@var{lambda}) * W' * B\n\ - AA = Q * A * Z, BB = Q * B * Z\n\ +A * V = B * V * diag (@var{lambda})\n\ +W' * A = diag (@var{lambda}) * W' * B\n\ +AA = Q * A * Z, BB = Q * B * Z\n\ \n\ @end group\n\ @end example\n\ @@ -344,6 +344,7 @@ @item opt\n\ for ordering eigenvalues of the GEP pencil. The leading block\n\ of the revised pencil contains all eigenvalues that satisfy:\n\ +\n\ @table @asis\n\ @item \"N\"\n\ = unordered (default)\n\
--- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -457,6 +457,7 @@ \n\ @item * + ? @{@}\n\ Repetition operators, representing\n\ +\n\ @table @code\n\ @item *\n\ Match zero or more times\n\ @@ -1078,7 +1079,7 @@ for the ith set of parentheses in the match string. For example,\n\ \n\ @example\n\ -regexprep(\"Bill Dunn\",'(\\w+) (\\w+)','$2, $1')\n\ +regexprep (\"Bill Dunn\", '(\\w+) (\\w+)', '$2, $1')\n\ @end example\n\ \n\ @noindent\n\
--- a/src/DLD-FUNCTIONS/spparms.cc +++ b/src/DLD-FUNCTIONS/spparms.cc @@ -40,8 +40,8 @@ @deftypefnx {Loadable Function} {[@var{keys}, @var{vals}] =} spparms ()\n\ @deftypefnx {Loadable Function} {@var{val} =} spparms (@var{key})\n\ @deftypefnx {Loadable Function} { } spparms (@var{vals})\n\ -@deftypefnx {Loadable Function} { } spparms ('defaults')\n\ -@deftypefnx {Loadable Function} { } spparms ('tight')\n\ +@deftypefnx {Loadable Function} { } spparms (\"defaults\")\n\ +@deftypefnx {Loadable Function} { } spparms (\"tight\")\n\ @deftypefnx {Loadable Function} { } spparms (@var{key}, @var{val})\n\ Query or set the parameters used by the sparse solvers and factorization\n\ functions. The first four calls above get information about the current\n\ @@ -97,9 +97,9 @@ The value of individual keys can be set with\n\ @code{spparms (@var{key}, @var{val})}.\n\ The default values can be restored with the special keyword\n\ -'defaults'. The special keyword 'tight' can be used to set the mmd solvers\n\ -to attempt a sparser solution at the potential cost of longer running\n\ -time.\n\ +\"defaults\". The special keyword \"tight\" can be used to set the mmd\n\ +solvers to attempt a sparser solution at the potential cost of longer\n\ +running time.\n\ @end deftypefn") { octave_value_list retval;
--- a/src/DLD-FUNCTIONS/strfind.cc +++ b/src/DLD-FUNCTIONS/strfind.cc @@ -164,7 +164,7 @@ @result{} [1, 3, 5]\n\ \n\ strfind (@{\"abababa\", \"bebebe\", \"ab\"@}, \"aba\")\n\ - @result{} ans =\n\ + @result{}\n\ @{\n\ [1,1] =\n\ \n\ @@ -331,7 +331,7 @@ @example\n\ @group\n\ strrep (\"This is a test string\", \"is\", \"&%$\")\n\ - @result{} \"Th&%$ &%$ a test string\"\n\ + @result{} \"Th&%$ &%$ a test string\"\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/sub2ind.cc +++ b/src/DLD-FUNCTIONS/sub2ind.cc @@ -182,8 +182,8 @@ @example\n\ @group\n\ [r, c] = ind2sub ([3, 3], 8)\n\ -@result{} r = 2\n\ - c = 3\n\ + @result{} r = 2\n\ + @result{} c = 3\n\ @end group\n\ @end example\n\ @seealso{sub2ind}\n\
--- a/src/DLD-FUNCTIONS/syl.cc +++ b/src/DLD-FUNCTIONS/syl.cc @@ -53,7 +53,7 @@ @example\n\ @group\n\ syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12])\n\ - @result{} [ -0.50000, -0.66667; -0.66667, -0.50000 ]\n\ + @result{} [ -0.50000, -0.66667; -0.66667, -0.50000 ]\n\ @end group\n\ @end example\n\ @end deftypefn")
--- a/src/DLD-FUNCTIONS/symrcm.cc +++ b/src/DLD-FUNCTIONS/symrcm.cc @@ -422,7 +422,7 @@ @var{p} is a permutation vector such that\n\ @code{@var{S}(@var{p}, @var{p})} tends to have its diagonal elements\n\ closer to the diagonal than @var{S}. This is a good preordering for LU\n\ -or Cholesky@tie{}factorization of matrices that come from 'long, skinny'\n\ +or Cholesky@tie{}factorization of matrices that come from ``long, skinny''\n\ problems. It works for both symmetric and asymmetric @var{S}.\n\ \n\ The algorithm represents a heuristic approach to the NP-complete\n\
--- a/src/DLD-FUNCTIONS/time.cc +++ b/src/DLD-FUNCTIONS/time.cc @@ -149,7 +149,7 @@ yday = 47\n\ isdst = 0\n\ zone = CST\n\ - @}\n\ + @}\n\ @end group\n\ @end example\n\ @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ @@ -213,7 +213,7 @@ yday = 47\n\ isdst = 0\n\ zone = CST\n\ - @}\n\ + @}\n\ @end group\n\ @end example\n\ @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ @@ -329,7 +329,7 @@ @example\n\ @group\n\ strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ()))\n\ - @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\ + @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/typecast.cc +++ b/src/DLD-FUNCTIONS/typecast.cc @@ -95,20 +95,20 @@ \n\ @example\n\ @group\n\ - \"logical\"\n\ - \"char\"\n\ - \"int8\"\n\ - \"int16\"\n\ - \"int32\"\n\ - \"int64\"\n\ - \"uint8\"\n\ - \"uint16\"\n\ - \"uint32\"\n\ - \"uint64\"\n\ - \"double\"\n\ - \"single\"\n\ - \"double complex\"\n\ - \"single complex\"\n\ +\"logical\"\n\ +\"char\"\n\ +\"int8\"\n\ +\"int16\"\n\ +\"int32\"\n\ +\"int64\"\n\ +\"uint8\"\n\ +\"uint16\"\n\ +\"uint32\"\n\ +\"uint64\"\n\ +\"double\"\n\ +\"single\"\n\ +\"double complex\"\n\ +\"single complex\"\n\ @end group\n\ @end example\n\ \n\ @@ -129,8 +129,8 @@ @example\n\ @group\n\ @var{x} = uint16 ([1, 65535]);\n\ -typecast (@var{x}, 'uint8')\n\ -@result{} [ 0, 1, 255, 255]\n\ +typecast (@var{x}, \"uint8\")\n\ + @result{} [ 0, 1, 255, 255]\n\ @end group\n\ @end example\n\ @seealso{cast, bitunpack, bitpack, swapbytes}\n\ @@ -280,17 +280,17 @@ \n\ @example\n\ @group\n\ - \"char\"\n\ - \"int8\"\n\ - \"int16\"\n\ - \"int32\"\n\ - \"int64\"\n\ - \"uint8\"\n\ - \"uint16\"\n\ - \"uint32\"\n\ - \"uint64\"\n\ - \"double\"\n\ - \"single\"\n\ +\"char\"\n\ +\"int8\"\n\ +\"int16\"\n\ +\"int32\"\n\ +\"int64\"\n\ +\"uint8\"\n\ +\"uint16\"\n\ +\"uint32\"\n\ +\"uint64\"\n\ +\"double\"\n\ +\"single\"\n\ @end group\n\ @end example\n\ \n\ @@ -388,17 +388,17 @@ \n\ @example\n\ @group\n\ - \"char\"\n\ - \"int8\"\n\ - \"int16\"\n\ - \"int32\"\n\ - \"int64\"\n\ - \"uint8\"\n\ - \"uint16\"\n\ - \"uint32\"\n\ - \"uint64\"\n\ - \"double\"\n\ - \"single\"\n\ +\"char\"\n\ +\"int8\"\n\ +\"int16\"\n\ +\"int32\"\n\ +\"int64\"\n\ +\"uint8\"\n\ +\"uint16\"\n\ +\"uint32\"\n\ +\"uint64\"\n\ +\"double\"\n\ +\"single\"\n\ @end group\n\ @end example\n\ \n\
--- a/src/DLD-FUNCTIONS/urlwrite.cc +++ b/src/DLD-FUNCTIONS/urlwrite.cc @@ -876,7 +876,7 @@ @example\n\ @group\n\ s = urlread (\"http://www.google.com/search\", \"get\",\n\ - @{\"query\", \"octave\"@});\n\ + @{\"query\", \"octave\"@});\n\ @end group\n\ @end example\n\ @seealso{urlwrite}\n\
--- a/src/Makefile.am +++ b/src/Makefile.am @@ -284,6 +284,7 @@ ops.h \ pager.h \ parse.h \ + parse-private.h \ pr-output.h \ procstream.h \ profiler.h \ @@ -484,9 +485,11 @@ if AMCOND_ENABLE_DYNAMIC_LINKING OCT_FILES = $(DLD_FUNCTIONS_LIBS:.la=.oct) OCT_STAMP_FILES = $(subst DLD-FUNCTIONS/,DLD-FUNCTIONS/$(am__leading_dot),$(DLD_FUNCTIONS_LIBS:.la=.oct-stamp)) + DLD_LIBOCTINTERP_LIBADD = liboctinterp.la else OCT_FILES = OCT_STAMP_FILES = + DLD_LIBOCTINTERP_LIBADD = endif liboctinterp_la_SOURCES = \
--- a/src/data.cc +++ b/src/data.cc @@ -119,7 +119,7 @@ @example\n\ @group\n\ all ([2, 3; 1, 0]))\n\ - @result{} [ 1, 0 ]\n\ + @result{} [ 1, 0 ]\n\ @end group\n\ @end example\n\ \n\ @@ -168,7 +168,7 @@ @example\n\ @group\n\ any (eye (2, 4))\n\ - @result{} [ 1, 1, 0, 0 ]\n\ + @result{} [ 1, 1, 0, 0 ]\n\ @end group\n\ @end example\n\ \n\ @@ -178,7 +178,7 @@ @example\n\ @group\n\ any (eye (2, 4), 2)\n\ - @result{} [ 1; 1 ]\n\ + @result{} [ 1; 1 ]\n\ @end group\n\ @end example\n\ @seealso{all}\n\ @@ -365,8 +365,8 @@ \n\ @example\n\ @group\n\ - hypot (hypot (@var{x}, @var{y}), @var{z})\n\ - hypot (hypot (hypot (@var{x}, @var{y}), @var{z}), @var{w}), etc.\n\ +hypot (hypot (@var{x}, @var{y}), @var{z})\n\ +hypot (hypot (hypot (@var{x}, @var{y}), @var{z}), @var{w}), etc.\n\ @end group\n\ @end example\n\ @end deftypefn") @@ -1093,14 +1093,14 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} cumsum (@var{x})\n\ @deftypefnx {Built-in Function} {} cumsum (@var{x}, @var{dim})\n\ -@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'native')\n\ -@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'double')\n\ -@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'extra')\n\ +@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"native\")\n\ +@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"double\")\n\ +@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"extra\")\n\ Cumulative sum of elements along dimension @var{dim}. If @var{dim}\n\ is omitted, it defaults to the first non-singleton dimension.\n\ \n\ -See @code{sum} for an explanation of the optional parameters 'native',\n\ -'double', and 'extra'.\n\ +See @code{sum} for an explanation of the optional parameters \"native\",\n\ +\"double\", and \"extra\".\n\ @seealso{sum, cumprod}\n\ @end deftypefn") { @@ -1256,10 +1256,10 @@ @example\n\ @group\n\ diag ([1, 2, 3], 1)\n\ - @result{} 0 1 0 0\n\ - 0 0 2 0\n\ - 0 0 0 3\n\ - 0 0 0 0\n\ + @result{} 0 1 0 0\n\ + 0 0 2 0\n\ + 0 0 0 3\n\ + 0 0 0 0\n\ @end group\n\ @end example\n\ \n\ @@ -1866,7 +1866,7 @@ new matrices. For example:\n\ \n\ @example\n\ -@var{hcat} = [ @var{array1}, @var{array2}, @dots{} ];\n\ +@var{hcat} = [ @var{array1}, @var{array2}, @dots{} ]\n\ @end example\n\ @seealso{cat, vertcat}\n\ @end deftypefn") @@ -2075,7 +2075,7 @@ new matrices. For example:\n\ \n\ @example\n\ -@var{vcat} = [ @var{array1}; @var{array2}; @dots{} ];\n\ +@var{vcat} = [ @var{array1}; @var{array2}; @dots{} ]\n\ @end example\n\ @seealso{cat, horzcat}\n\ @end deftypefn") @@ -2100,17 +2100,17 @@ A = ones (2, 2);\n\ B = zeros (2, 2);\n\ cat (2, A, B)\n\ - @result{} 1 1 0 0\n\ - 1 1 0 0\n\ + @result{} 1 1 0 0\n\ + 1 1 0 0\n\ @end group\n\ @end example\n\ \n\ Alternatively, we can concatenate @var{A} and @var{B} along the\n\ -second dimension the following way:\n\ +second dimension in the following way:\n\ \n\ @example\n\ @group\n\ -[A, B].\n\ +[A, B]\n\ @end group\n\ @end example\n\ \n\ @@ -2121,16 +2121,15 @@ @example\n\ @group\n\ cat (4, ones (2, 2), zeros (2, 2))\n\ - @result{} ans =\n\ -\n\ - ans(:,:,1,1) =\n\ -\n\ - 1 1\n\ - 1 1\n\ -\n\ - ans(:,:,1,2) =\n\ - 0 0\n\ - 0 0\n\ + @result{} ans(:,:,1,1) =\n\ +\n\ + 1 1\n\ + 1 1\n\ +\n\ + ans(:,:,1,2) =\n\ +\n\ + 0 0\n\ + 0 0\n\ @end group\n\ @end example\n\ @seealso{horzcat, vertcat}\n\ @@ -2386,8 +2385,8 @@ \n\ @example\n\ @group\n\ - ndims (ones (4, 1, 2, 1))\n\ - @result{} 3\n\ +ndims (ones (4, 1, 2, 1))\n\ + @result{} 3\n\ @end group\n\ @end example\n\ @end deftypefn") @@ -2411,16 +2410,16 @@ return the number of elements that would result from the indexing\n\ \n\ @example\n\ - @var{a}(@var{idx1}, @var{idx2}, @dots{})\n\ +@var{a}(@var{idx1}, @var{idx2}, @dots{})\n\ @end example\n\ \n\ Note that the indices do not have to be numerical. For example,\n\ \n\ @example\n\ @group\n\ - @var{a} = 1;\n\ - @var{b} = ones (2, 3);\n\ - numel (@var{a}, @var{b});\n\ +@var{a} = 1;\n\ +@var{b} = ones (2, 3);\n\ +numel (@var{a}, @var{b})\n\ @end group\n\ @end example\n\ \n\ @@ -2463,11 +2462,11 @@ @example\n\ @group\n\ size ([1, 2; 3, 4; 5, 6])\n\ - @result{} [ 3, 2 ]\n\ + @result{} [ 3, 2 ]\n\ \n\ [nr, nc] = size ([1, 2; 3, 4; 5, 6])\n\ - @result{} nr = 3\n\ - @result{} nc = 2\n\ + @result{} nr = 3\n\ + @result{} nc = 2\n\ @end group\n\ @end example\n\ \n\ @@ -2477,7 +2476,7 @@ @example\n\ @group\n\ size ([1, 2; 3, 4; 5, 6], 2)\n\ - @result{} 2\n\ + @result{} 2\n\ @end group\n\ @end example\n\ \n\ @@ -2650,31 +2649,32 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} sum (@var{x})\n\ @deftypefnx {Built-in Function} {} sum (@var{x}, @var{dim})\n\ -@deftypefnx {Built-in Function} {} sum (@dots{}, 'native')\n\ -@deftypefnx {Built-in Function} {} sum (@dots{}, 'double')\n\ -@deftypefnx {Built-in Function} {} sum (@dots{}, 'extra')\n\ +@deftypefnx {Built-in Function} {} sum (@dots{}, \"native\")\n\ +@deftypefnx {Built-in Function} {} sum (@dots{}, \"double\")\n\ +@deftypefnx {Built-in Function} {} sum (@dots{}, \"extra\")\n\ Sum of elements along dimension @var{dim}. If @var{dim} is\n\ omitted, it defaults to the first non-singleton dimension.\n\ \n\ -If the optional argument 'native' is given, then the sum is performed\n\ +If the optional argument \"native\" is given, then the sum is performed\n\ in the same type as the original argument, rather than in the default\n\ double type. For example:\n\ \n\ @example\n\ @group\n\ sum ([true, true])\n\ - @result{} 2\n\ -sum ([true, true], 'native')\n\ - @result{} true\n\ + @result{} 2\n\ +sum ([true, true], \"native\")\n\ + @result{} true\n\ @end group\n\ @end example\n\ \n\ -On the contrary, if 'double' is given, the sum is performed in double\n\ +On the contrary, if \"double\" is given, the sum is performed in double\n\ precision even for single precision inputs.\n\ \n\ -For double precision inputs, 'extra' indicates that a more accurate algorithm\n\ -than straightforward summation is to be used. For single precision inputs,\n\ -'extra' is the same as 'double'. Otherwise, 'extra' has no effect.\n\ +For double precision inputs, \"extra\" indicates that a more accurate\n\ +algorithm than straightforward summation is to be used. For single precision\n\ +inputs, \"extra\" is the same as \"double\". Otherwise, \"extra\" has no\n\ +effect.\n\ @seealso{cumsum, sumsq, prod}\n\ @end deftypefn") { @@ -3010,8 +3010,7 @@ @example\n\ @group\n\ complex ([1, 2], [3, 4])\n\ -@result{}\n\ - 1 + 3i 2 + 4i\n\ + @result{} [ 1 + 3i 2 + 4i ]\n\ @end group\n\ @end example\n\ @seealso{real, imag, iscomplex}\n\ @@ -3944,9 +3943,8 @@ \n\ @example\n\ @group\n\ -[1/0 e^800]\n\ -@result{}\n\ -Inf Inf\n\ +[ 1/0 e^800 ]\n\ +@result{} Inf Inf\n\ @end group\n\ @end example\n\ \n\ @@ -4539,9 +4537,9 @@ @example\n\ @group\n\ eye (3)\n\ - @result{} 1 0 0\n\ - 0 1 0\n\ - 0 0 1\n\ + @result{} 1 0 0\n\ + 0 1 0\n\ + 0 0 1\n\ @end group\n\ @end example\n\ \n\ @@ -4783,7 +4781,7 @@ In other words, the statement\n\ \n\ @example\n\ - y = resize (x, dv);\n\ +y = resize (x, dv)\n\ @end example\n\ \n\ @noindent\n\ @@ -4791,10 +4789,12 @@ \n\ @example\n\ @group\n\ - y = zeros (dv, class (x));\n\ - sz = min (dv, size (x));\n\ - for i = 1:length (sz), idx@{i@} = 1:sz(i); endfor\n\ - y(idx@{:@}) = x(idx@{:@});\n\ +y = zeros (dv, class (x));\n\ +sz = min (dv, size (x));\n\ +for i = 1:length (sz)\n\ + idx@{i@} = 1:sz(i);\n\ +endfor\n\ +y(idx@{:@}) = x(idx@{:@});\n\ @end group\n\ @end example\n\ \n\ @@ -4873,8 +4873,8 @@ @example\n\ @group\n\ reshape ([1, 2, 3, 4], 2, 2)\n\ - @result{} 1 3\n\ - 2 4\n\ + @result{} 1 3\n\ + 2 4\n\ @end group\n\ @end example\n\ \n\ @@ -5436,7 +5436,7 @@ cumulatively from left to right:\n\ \n\ @example\n\ - (@dots{}((x1 + x2) + x3) + @dots{})\n\ +(@dots{}((x1 + x2) + x3) + @dots{})\n\ @end example\n\ \n\ At least one argument is required.\n\ @@ -5467,7 +5467,7 @@ cumulatively from left to right:\n\ \n\ @example\n\ - (@dots{}((x1 * x2) * x3) * @dots{})\n\ +(@dots{}((x1 * x2) * x3) * @dots{})\n\ @end example\n\ \n\ At least one argument is required.\n\ @@ -5579,7 +5579,7 @@ cumulatively from left to right:\n\ \n\ @example\n\ - (@dots{}((x1 .* x2) .* x3) .* @dots{})\n\ +(@dots{}((x1 .* x2) .* x3) .* @dots{})\n\ @end example\n\ \n\ At least one argument is required.\n\ @@ -5638,7 +5638,7 @@ cumulatively from left to right:\n\ \n\ @example\n\ - (@dots{}((x1 & x2) & x3) & @dots{})\n\ +(@dots{}((x1 & x2) & x3) & @dots{})\n\ @end example\n\ \n\ At least one argument is required.\n\ @@ -5659,7 +5659,7 @@ cumulatively from left to right:\n\ \n\ @example\n\ - (@dots{}((x1 | x2) | x3) | @dots{})\n\ +(@dots{}((x1 | x2) | x3) | @dots{})\n\ @end example\n\ \n\ At least one argument is required.\n\ @@ -5698,7 +5698,7 @@ @example\n\ @group\n\ t = tic; sleep (5); (double (tic ()) - double (t)) * 1e-6\n\ - @result{} 5\n\ + @result{} 5\n\ @end group\n\ @end example\n\ \n\ @@ -5860,16 +5860,16 @@ @example\n\ @group\n\ sort ([1, 2; 2, 3; 3, 1])\n\ - @result{} 1 1\n\ - 2 2\n\ - 3 3\n\ + @result{} 1 1\n\ + 2 2\n\ + 3 3\n\ @end group\n\ @end example\n\ \n\ If the optional argument @var{dim} is given, then the matrix is sorted\n\ along the dimension defined by @var{dim}. The optional argument @code{mode}\n\ defines the order in which the values will be sorted. Valid values of\n\ -@code{mode} are `ascend' or `descend'.\n\ +@code{mode} are \"ascend\" or \"descend\".\n\ \n\ The @code{sort} function may also be used to produce a matrix\n\ containing the original row indices of the elements in the sorted\n\ @@ -5878,12 +5878,12 @@ @example\n\ @group\n\ [s, i] = sort ([1, 2; 2, 3; 3, 1])\n\ - @result{} s = 1 1\n\ - 2 2\n\ - 3 3\n\ - @result{} i = 1 3\n\ - 2 1\n\ - 3 2\n\ + @result{} s = 1 1\n\ + 2 2\n\ + 3 3\n\ + @result{} i = 1 3\n\ + 2 1\n\ + 3 2\n\ @end group\n\ @end example\n\ \n\ @@ -5896,9 +5896,9 @@ @example\n\ @group\n\ sort ([1+i; 1; 1-i])\n\ - @result{} 1 + 0i\n\ - 1 - 1i\n\ - 1 + 1i\n\ + @result{} 1 + 0i\n\ + 1 - 1i\n\ + 1 + 1i\n\ @end group\n\ @end example\n\ \n\
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -554,6 +554,7 @@ them, or an empty cell array if no patterns match. The pattern strings are\n\ interpreted as filename globbing patterns (as they are used by Unix shells).\n\ Within a pattern\n\ +\n\ @table @code\n\ @itemx *\n\ matches any string, including the null string,\n\ @@ -570,25 +571,25 @@ \n\ @example\n\ ls\n\ - @result{}\n\ - file1 file2 file3 myfile1 myfile1b\n\ + @result{}\n\ + file1 file2 file3 myfile1 myfile1b\n\ glob (\"*file1\")\n\ - @result{}\n\ - @{\n\ - [1,1] = file1\n\ - [2,1] = myfile1\n\ - @}\n\ + @result{}\n\ + @{\n\ + [1,1] = file1\n\ + [2,1] = myfile1\n\ + @}\n\ glob (\"myfile?\")\n\ - @result{}\n\ - @{\n\ - [1,1] = myfile1\n\ - @}\n\ + @result{}\n\ + @{\n\ + [1,1] = myfile1\n\ + @}\n\ glob (\"file[12]\")\n\ - @result{}\n\ - @{\n\ - [1,1] = file1\n\ - [2,1] = file2\n\ - @}\n\ + @result{}\n\ + @{\n\ + [1,1] = file1\n\ + [2,1] = file2\n\ + @}\n\ @end example\n\ @seealso{ls, dir, readdir}\n\ @end deftypefn") @@ -687,10 +688,10 @@ DEFUN (filesep, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} filesep ()\n\ -@deftypefnx {Built-in Function} {} filesep ('all')\n\ +@deftypefnx {Built-in Function} {} filesep (\"all\")\n\ Return the system-dependent character used to separate directory names.\n\ \n\ -If 'all' is given, the function returns all valid file separators in\n\ +If \"all\" is given, the function returns all valid file separators in\n\ the form of a string. The list of file separators is system-dependent.\n\ It is @samp{/} (forward slash) under UNIX or @w{Mac OS X}, @samp{/} and\n\ @samp{\\} (forward and backward slashes) under Windows.\n\
--- a/src/error.cc +++ b/src/error.cc @@ -1487,7 +1487,7 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{lasterr} =} lasterror ()\n\ @deftypefnx {Built-in Function} {} lasterror (@var{err})\n\ -@deftypefnx {Built-in Function} {} lasterror ('reset')\n\ +@deftypefnx {Built-in Function} {} lasterror (\"reset\")\n\ Query or set the last error message structure. When called without\n\ arguments, return a structure containing the last error message and other\n\ information related to this error. The elements of the structure are:\n\ @@ -1523,7 +1523,7 @@ as input. Any fields of @var{err} that match those above are set while any\n\ unspecified fields are initialized with default values.\n\ \n\ -If @code{lasterror} is called with the argument 'reset', all fields are\n\ +If @code{lasterror} is called with the argument \"reset\", all fields are\n\ set to their default values.\n\ @seealso{lasterr}\n\ @end deftypefn")
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -1072,7 +1072,7 @@ DEFUN (fscanf, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\ -+@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} fscanf (@var{fid}, @var{template}, @var{locale})\n\ +@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} fscanf (@var{fid}, @var{template}, @var{locale})\n\ In the first form, read from @var{fid} according to @var{template},\n\ returning the result in the matrix @var{val}.\n\ \n\ @@ -1111,9 +1111,9 @@ with each conversion specifier in @var{template} corresponding to a\n\ single scalar return value. This form is more `C-like', and also\n\ compatible with previous versions of Octave. The number of successful\n\ -conversions is returned in @var{count}. It permits to explicitly\n\ -specify a locale to take into account langage specific features, \n\ -such as decimal separator. This operation restores the previous locales\n\ +conversions is returned in @var{count}. It permits to explicitly\n\ +specify a locale to take into account language specific features, \n\ +such as decimal separator. This operation restores the previous locales\n\ setting at the end of the conversion.\n\ @ifclear OCTAVE_MANUAL\n\ \n\ @@ -1339,7 +1339,7 @@ DEFUN (scanf, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\ -@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}]] =} scanf (@var{template}, @var{locale}))\n\ +@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} scanf (@var{template}, @var{locale})\n\ This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\ \n\ It is currently not useful to call @code{scanf} in interactive\n\ @@ -1853,9 +1853,10 @@ while (ischar (s = fgets (fid)))\n\ fputs (stdout, s);\n\ endwhile\n\ - @print{} drwxr-xr-x 33 root root 3072 Feb 15 13:28 etc\n\ - @print{} drwxr-xr-x 3 root root 1024 Feb 15 13:28 lib\n\ - @print{} drwxrwxrwt 15 root root 2048 Feb 17 14:53 tmp\n\ +\n\ + @print{} drwxr-xr-x 33 root root 3072 Feb 15 13:28 etc\n\ + @print{} drwxr-xr-x 3 root root 1024 Feb 15 13:28 lib\n\ + @print{} drwxrwxrwt 15 root root 2048 Feb 17 14:53 tmp\n\ @end group\n\ @end example\n\ @end deftypefn") @@ -2226,6 +2227,7 @@ @deftypefnx {Built-in Function} {} SEEK_END ()\n\ Return the numerical value to pass to @code{fseek} to perform\n\ one of the following actions:\n\ +\n\ @table @code\n\ @item SEEK_SET\n\ Position file relative to the beginning.\n\
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -3029,6 +3029,8 @@ else if (xunits.compare ("normalized")) { ss = Matrix (1, 4, 1.0); + ss(0) = 0; + ss(1) = 0; } else if (xunits.compare ("points")) { @@ -3041,6 +3043,33 @@ set_screensize (ss); } +Matrix +root_figure::properties::get_boundingbox (bool internal, const Matrix&) const +{ + Matrix screen_size = screen_size_pixels (); + Matrix pos = Matrix (1, 4, 0); + pos(2) = screen_size(0); + pos(3) = screen_size(1); + return pos; +} + +/* +%!test +%! set (0, "units", "pixels") +%! sz = get (0, "screensize") - [1, 1, 0, 0]; +%! dpi = get (0, "screenpixelsperinch"); +%! set (0, "units", "inches") +%! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi) +%! set (0, "units", "centimeters") +%! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54) +%! set (0, "units", "points") +%! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72) +%! set (0, "units", "normalized") +%! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]) +%! set (0, "units", "pixels") +%! assert (get (0, "screensize"), sz + [1, 1, 0, 0]) +*/ + void root_figure::properties::remove_child (const graphics_handle& gh) { @@ -3225,10 +3254,11 @@ if (! error_state) { Matrix old_bb, new_bb; - - old_bb = get_boundingbox (); - position.set (v, true, do_notify_toolkit); - new_bb = get_boundingbox (); + bool modified = false; + + old_bb = get_boundingbox (true); + modified = position.set (v, false, do_notify_toolkit); + new_bb = get_boundingbox (true); if (old_bb != new_bb) { @@ -3239,7 +3269,11 @@ } } - mark_modified (); + if (modified) + { + position.run_listeners (POSTSET); + mark_modified (); + } } } @@ -3465,11 +3499,12 @@ Matrix pos = get_paperposition ().matrix_value (); Matrix sz = get_papersize ().matrix_value (); - pos (0) = pos (0) / sz(0); - pos (1) = pos (1) / sz(1); - pos (2) = pos (2) / sz(0); - pos (3) = pos (3) / sz(1); - + pos(0) /= sz(0); + pos(1) /= sz(1); + pos(2) /= sz(0); + pos(3) /= sz(1); + + std::string porient = get_paperorientation (); caseless_str punits = get_paperunits (); caseless_str typ = get_papertype (); @@ -3477,33 +3512,37 @@ { if (old_paperunits.compare ("centimeters")) { - sz (0) = sz (0) / 2.54; - sz (1) = sz (1) / 2.54; + sz(0) /= 2.54; + sz(1) /= 2.54; } else if (old_paperunits.compare ("points")) { - sz (0) = sz (0) / 72.0; - sz (1) = sz (1) / 72.0; + sz(0) /= 72.0; + sz(1) /= 72.0; } if (punits.compare ("centimeters")) { - sz(0) = sz(0) * 2.54; - sz(1) = sz(1) * 2.54; - } - else if (old_paperunits.compare ("points")) - { - sz (0) = sz (0) * 72.0; - sz (1) = sz (1) * 72.0; + sz(0) *= 2.54; + sz(1) *= 2.54; + } + else if (punits.compare ("points")) + { + sz(0) *= 72.0; + sz(1) *= 72.0; } } else - sz = papersize_from_type (punits, typ); - - pos (0) = pos (0) * sz(0); - pos (1) = pos (1) * sz(1); - pos (2) = pos (2) * sz(0); - pos (3) = pos (3) * sz(1); + { + sz = papersize_from_type (punits, typ); + if (porient == "landscape") + std::swap (sz(0), sz(1)); + } + + pos(0) *= sz(0); + pos(1) *= sz(1); + pos(2) *= sz(0); + pos(3) *= sz(1); papersize.set (octave_value (sz)); paperposition.set (octave_value (pos)); @@ -3513,18 +3552,152 @@ figure::properties::update_papertype (void) { caseless_str typ = get_papertype (); - if (! typ.compare ("<custom>")) - // Call papersize.set rather than set_papersize to avoid loops between - // update_papersize and update_papertype - papersize.set (octave_value (papersize_from_type (get_paperunits (), typ))); + { + Matrix sz = papersize_from_type (get_paperunits (), typ); + if (get_paperorientation () == "landscape") + std::swap (sz(0), sz(1)); + // Call papersize.set rather than set_papersize to avoid loops + // between update_papersize and update_papertype + papersize.set (octave_value (sz)); + } } void figure::properties::update_papersize (void) { - papertype.set ("<custom>"); -} + Matrix sz = get_papersize ().matrix_value (); + if (sz(0) > sz(1)) + { + std::swap (sz(0), sz(1)); + papersize.set (octave_value (sz)); + paperorientation.set (octave_value ("landscape")); + } + else + { + paperorientation.set ("portrait"); + } + std::string punits = get_paperunits (); + if (punits == "centimeters") + { + sz(0) /= 2.54; + sz(1) /= 2.54; + } + else if (punits == "points") + { + sz(0) = 72.0; + sz(1) = 72.0; + } + if (punits == "normalized") + { + caseless_str typ = get_papertype (); + if (get_papertype () == "<custom>") + error ("set: can't set the papertype to <custom> when the paperunits is normalized"); + } + else + { + // TODO - the papersizes info is also in papersize_from_type(). + // Both should be rewritten to avoid the duplication. + std::string typ = "<custom>"; + const double mm2in = 1.0 / 25.4; + const double tol = 0.01; + + if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol) + typ = "usletter"; + else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol) + typ = "uslegal"; + else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol) + typ = "tabloid"; + else if (std::abs (sz(0) - 841.0 * mm2in) + std::abs (sz(1) - 1198.0 * mm2in) < tol) + typ = "a0"; + else if (std::abs (sz(0) - 594.0 * mm2in) + std::abs (sz(1) - 841.0 * mm2in) < tol) + typ = "a1"; + else if (std::abs (sz(0) - 420.0 * mm2in) + std::abs (sz(1) - 594.0 * mm2in) < tol) + typ = "a2"; + else if (std::abs (sz(0) - 297.0 * mm2in) + std::abs (sz(1) - 420.0 * mm2in) < tol) + typ = "a3"; + else if (std::abs (sz(0) - 210.0 * mm2in) + std::abs (sz(1) - 297.0 * mm2in) < tol) + typ = "a4"; + else if (std::abs (sz(0) - 148.0 * mm2in) + std::abs (sz(1) - 210.0 * mm2in) < tol) + typ = "a5"; + else if (std::abs (sz(0) - 1029.0 * mm2in) + std::abs (sz(1) - 1456.0 * mm2in) < tol) + typ = "b0"; + else if (std::abs (sz(0) - 728.0 * mm2in) + std::abs (sz(1) - 1028.0 * mm2in) < tol) + typ = "b1"; + else if (std::abs (sz(0) - 514.0 * mm2in) + std::abs (sz(1) - 728.0 * mm2in) < tol) + typ = "b2"; + else if (std::abs (sz(0) - 364.0 * mm2in) + std::abs (sz(1) - 514.0 * mm2in) < tol) + typ = "b3"; + else if (std::abs (sz(0) - 257.0 * mm2in) + std::abs (sz(1) - 364.0 * mm2in) < tol) + typ = "b4"; + else if (std::abs (sz(0) - 182.0 * mm2in) + std::abs (sz(1) - 257.0 * mm2in) < tol) + typ = "b5"; + else if (std::abs (sz(0) - 9.0) + std::abs (sz(1) - 12.0) < tol) + typ = "arch-a"; + else if (std::abs (sz(0) - 12.0) + std::abs (sz(1) - 18.0) < tol) + typ = "arch-b"; + else if (std::abs (sz(0) - 18.0) + std::abs (sz(1) - 24.0) < tol) + typ = "arch-c"; + else if (std::abs (sz(0) - 24.0) + std::abs (sz(1) - 36.0) < tol) + typ = "arch-d"; + else if (std::abs (sz(0) - 36.0) + std::abs (sz(1) - 48.0) < tol) + typ = "arch-e"; + else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol) + typ = "a"; + else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol) + typ = "b"; + else if (std::abs (sz(0) - 17.0) + std::abs (sz(1) - 22.0) < tol) + typ = "c"; + else if (std::abs (sz(0) - 22.0) + std::abs (sz(1) - 34.0) < tol) + typ = "d"; + else if (std::abs (sz(0) - 34.0) + std::abs (sz(1) - 43.0) < tol) + typ = "e"; + // Call papertype.set rather than set_papertype to avoid loops between + // update_papersize and update_papertype + papertype.set (typ); + } +} + +void +figure::properties::update_paperorientation (void) +{ + std::string porient = get_paperorientation (); + Matrix sz = get_papersize ().matrix_value (); + Matrix pos = get_paperposition ().matrix_value (); + if ((sz(0) > sz(1) && porient == "portrait") + || (sz(0) < sz(1) && porient == "landscape")) + { + std::swap (sz(0), sz(1)); + std::swap (pos(0), pos(1)); + std::swap (pos(2), pos(3)); + // Call papertype.set rather than set_papertype to avoid loops + // between update_papersize and update_papertype + papersize.set (octave_value (sz)); + paperposition.set (octave_value (pos)); + } +} + +/* +%!test +%! figure (1, "visible", false); +%! tol = 100 * eps (); +%! set (gcf (), "paperorientation", "PORTRAIT") +%! set (gcf (), "paperunits", "inches") +%! set (gcf (), "papertype", "USletter") +%! assert (get (gcf (), "papersize"), [8.5, 11.0], tol) +%! set (gcf (), "paperorientation", "Landscape") +%! assert (get (gcf (), "papersize"), [11.0, 8.5], tol) +%! set (gcf (), "paperunits", "centimeters") +%! assert (get (gcf (), "papersize"), [11.0, 8.5] * 2.54, tol) +%! set (gcf (), "papertype", "a4"); +%! assert (get (gcf (), "papersize"), [29.7, 21.0], tol) +%! set (gcf (), "paperunits", "inches", "papersize", [8.5, 11.0]) +%! assert (get (gcf (), "papertype"), "usletter") +%! assert (get (gcf (), "paperorientation"), "portrait") +%! set (gcf (), "papersize", [11.0, 8.5]) +%! assert (get (gcf (), "papertype"), "usletter") +%! assert (get (gcf (), "paperorientation"), "landscape") +*/ void figure::properties::set_units (const octave_value& v) @@ -3543,9 +3716,20 @@ void figure::properties::update_units (const caseless_str& old_units) { - set_position (convert_position (get_position ().matrix_value (), old_units, - get_units (), screen_size_pixels ())); -} + position.set (convert_position (get_position ().matrix_value (), old_units, + get_units (), screen_size_pixels ()), false); +} + +/* +%!test +%! figure (1, "visible", false) +%! set (0, "units", "pixels") +%! rsz = get (0, "screensize"); +%! set (gcf (), "units", "pixels") +%! fsz = get (gcf (), "position"); +%! set (gcf (), "units", "normalized") +%! assert (get (gcf (), "position"), (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4])) +*/ std::string figure::properties::get_title (void) const @@ -5808,12 +5992,6 @@ } lims = tmp_lims; } - else - { - // adjust min and max tics if they are out of limits - i1 = static_cast<int> (std::ceil (lo / tick_sep)); - i2 = static_cast<int> (gnulib::floor (hi / tick_sep)); - } Matrix tmp_ticks (1, i2-i1+1); for (int i = 0; i <= i2-i1; i++) @@ -5832,7 +6010,7 @@ ticks = tmp_ticks; - int n = is_logscale ? 9 : 4; + int n = is_logscale ? 8 : 4; Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1)); for (int i = 0; i < tmp_ticks.numel ()-1; i++) @@ -6395,6 +6573,58 @@ { return x; } } +static Matrix +do_zoom (double val, double factor, const Matrix& lims, bool is_logscale) +{ + Matrix new_lims = lims; + + double lo = lims(0); + double hi = lims(1); + + bool is_negative = lo < 0 && hi < 0; + + if (is_logscale) + { + if (is_negative) + { + double tmp = hi; + hi = std::log10 (-lo); + lo = std::log10 (-tmp); + val = std::log10 (-val); + } + else + { + hi = std::log10 (hi); + lo = std::log10 (lo); + val = std::log10 (val); + } + } + + // Perform the zooming + lo = val + factor * (lo - val); + hi = val + factor * (hi - val); + + if (is_logscale) + { + if (is_negative) + { + double tmp = -std::pow (10.0, hi); + hi = -std::pow (10.0, lo); + lo = tmp; + } + else + { + lo = std::pow (10.0, lo); + hi = std::pow (10.0, hi); + } + } + + new_lims(0) = lo; + new_lims(1) = hi; + + return new_lims; +} + void axes::properties::zoom_about_point (double x, double y, double factor, bool push_to_zoom_stack) @@ -6417,11 +6647,8 @@ double max_neg_y = -octave_Inf; get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y'); - // Perform the zooming - xlims (0) = x + factor * (xlims (0) - x); - xlims (1) = x + factor * (xlims (1) - x); - ylims (0) = y + factor * (ylims (0) - y); - ylims (1) = y + factor * (ylims (1) - y); + xlims = do_zoom (x, factor, xlims, xscale_is ("log")); + ylims = do_zoom (y, factor, ylims, yscale_is ("log")); zoom (xlims, ylims, push_to_zoom_stack); } @@ -6447,8 +6674,68 @@ update_ylim (false); } -void -axes::properties::translate_view (double delta_x, double delta_y) +static Matrix +do_translate (double x0, double x1, const Matrix& lims, bool is_logscale) +{ + Matrix new_lims = lims; + + double lo = lims(0); + double hi = lims(1); + + bool is_negative = lo < 0 && hi < 0; + + double delta; + + if (is_logscale) + { + if (is_negative) + { + double tmp = hi; + hi = std::log10 (-lo); + lo = std::log10 (-tmp); + x0 = -x0; + x1 = -x1; + } + else + { + hi = std::log10 (hi); + lo = std::log10 (lo); + } + + delta = std::log10 (x0) - std::log10 (x1); + } + else + { + delta = x0 - x1; + } + + // Perform the translation + lo += delta; + hi += delta; + + if (is_logscale) + { + if (is_negative) + { + double tmp = -std::pow (10.0, hi); + hi = -std::pow (10.0, lo); + lo = tmp; + } + else + { + lo = std::pow (10.0, lo); + hi = std::pow (10.0, hi); + } + } + + new_lims(0) = lo; + new_lims(1) = hi; + + return new_lims; +} + +void +axes::properties::translate_view (double x0, double x1, double y0, double y1) { // FIXME: Do we need error checking here? Matrix xlims = get_xlim ().matrix_value (); @@ -6468,10 +6755,8 @@ double max_neg_y = -octave_Inf; get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y'); - xlims (0) += delta_x; - xlims (1) += delta_x; - ylims (0) += delta_y; - ylims (1) += delta_y; + xlims = do_translate (x0, x1, xlims, xscale_is ("log")); + ylims = do_translate (y0, y1, ylims, yscale_is ("log")); zoom (xlims, ylims, false); }
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -222,10 +222,7 @@ { Matrix retval (m.rows (), m.cols ()); - if (m.any_element_is_positive ()) - do_scale (m.data (), retval.fortran_vec (), m.numel ()); - else - do_neg_scale (m.data (), retval.fortran_vec (), m.numel ()); + do_scale (m.data (), retval.fortran_vec (), m.numel ()); return retval; } @@ -234,10 +231,7 @@ { NDArray retval (m.dims ()); - if (m.any_element_is_positive ()) - do_scale (m.data (), retval.fortran_vec (), m.numel ()); - else - do_neg_scale (m.data (), retval.fortran_vec (), m.numel ()); + do_scale (m.data (), retval.fortran_vec (), m.numel ()); return retval; } @@ -255,13 +249,47 @@ void do_scale (const double *src, double *dest, int n) const { for (int i = 0; i < n; i++) - dest[i] = log10(src[i]); + dest[i] = log10 (src[i]); + } +}; + +class neg_log_scaler : public base_scaler +{ +public: + neg_log_scaler (void) { } + + Matrix scale (const Matrix& m) const + { + Matrix retval (m.rows (), m.cols ()); + + do_scale (m.data (), retval.fortran_vec (), m.numel ()); + + return retval; } - void do_neg_scale (const double *src, double *dest, int n) const + NDArray scale (const NDArray& m) const + { + NDArray retval (m.dims ()); + + do_scale (m.data (), retval.fortran_vec (), m.numel ()); + + return retval; + } + + double scale (double d) const + { return -log10 (-d); } + + double unscale (double d) const + { return -pow (10.0, -d); } + + base_scaler* clone (void) const + { return new neg_log_scaler (); } + +private: + void do_scale (const double *src, double *dest, int n) const { for (int i = 0; i < n; i++) - dest[i] = -log10(-src[i]); + dest[i] = -log10 (-src[i]); } }; @@ -275,7 +303,8 @@ scaler (const std::string& s) : rep (s == "log" ? new log_scaler () - : (s == "linear" ? new lin_scaler () : new base_scaler ())) + : (s == "neglog" ? new neg_log_scaler () + : (s == "linear" ? new lin_scaler () : new base_scaler ()))) { } ~scaler (void) { delete rep; } @@ -318,6 +347,8 @@ if (s == "log") rep = new log_scaler (); + else if (s == "neglog") + rep = new neg_log_scaler (); else if (s == "linear") rep = new lin_scaler (); else @@ -2310,7 +2341,7 @@ ~gtk_manager (void) { } - static void create_instance (void); + OCTINTERP_API static void create_instance (void); static bool instance_ok (void) { @@ -2331,7 +2362,7 @@ static void cleanup_instance (void) { delete instance; instance = 0; } - static gtk_manager *instance; + OCTINTERP_API static gtk_manager *instance; // The name of the default toolkit. std::string dtk; @@ -3123,6 +3154,9 @@ public: void remove_child (const graphics_handle& h); + Matrix get_boundingbox (bool internal = false, + const Matrix& parent_pix_size = Matrix ()) const; + // See the genprops.awk script for an explanation of the // properties declarations. @@ -3340,7 +3374,7 @@ callback_property closerequestfcn , "closereq" handle_property currentaxes S , graphics_handle () array_property colormap , jet_colormap () - radio_property paperorientation , "{portrait}|landscape|rotated" + radio_property paperorientation U , "{portrait}|landscape|rotated" color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) array_property alphamap , Matrix (64, 1, 1) string_property currentcharacter r , "" @@ -3663,7 +3697,7 @@ void zoom_about_point (double x, double y, double factor, bool push_to_zoom_stack = true); void zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack = true); - void translate_view (double delta_x, double delta_y); + void translate_view (double x0, double x1, double y0, double y1); void rotate_view (double delta_az, double delta_el); void unzoom (void); void clear_zoom_stack (void); @@ -3814,9 +3848,32 @@ void init (void); private: - void update_xscale (void) { sx = get_xscale (); } - void update_yscale (void) { sy = get_yscale (); } - void update_zscale (void) { sz = get_zscale (); } + + std::string + get_scale (const std::string& scale, const Matrix& lims) + { + std::string retval = scale; + + if (scale == "log" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0) + retval = "neglog"; + + return retval; + } + + void update_xscale (void) + { + sx = get_scale (get_xscale (), xlim.get ().matrix_value ()); + } + + void update_yscale (void) + { + sy = get_scale (get_yscale (), ylim.get ().matrix_value ()); + } + + void update_zscale (void) + { + sz = get_scale (get_zscale (), zlim.get ().matrix_value ()); + } void update_view (void) { sync_positions (); } void update_dataaspectratio (void) { sync_positions (); } @@ -3968,6 +4025,8 @@ fix_limits (xlim); + update_xscale (); + if (do_clr_zoom) zoom_stack.clear (); @@ -3983,6 +4042,8 @@ fix_limits (ylim); + update_yscale (); + if (do_clr_zoom) zoom_stack.clear (); @@ -3998,6 +4059,8 @@ fix_limits (zlim); + update_zscale (); + zoom_stack.clear (); update_axes_layout ();
--- a/src/help.cc +++ b/src/help.cc @@ -587,7 +587,7 @@ @example\n\ @group\n\ global @var{x};\n\ -if isempty (@var{x})\n\ +if (isempty (@var{x}))\n\ x = 1;\n\ endif\n\ @end group\n\
--- a/src/lex.ll +++ b/src/lex.ll @@ -68,6 +68,7 @@ #include "lex.h" #include "ov.h" #include "parse.h" +#include "parse-private.h" #include "pt-all.h" #include "symtab.h" #include "token.h" @@ -1113,8 +1114,7 @@ parser_end_of_input = false; - while (! symtab_context.empty ()) - symtab_context.pop (); + parser_symtab_context.clear (); // We do want a prompt by default. promptflag = 1; @@ -1497,10 +1497,26 @@ lexer_flags.at_beginning_of_statement = true; break; + case static_kw: + if ((reading_fcn_file || reading_script_file + || reading_classdef_file) + && ! curr_fcn_file_full_name.empty ()) + warning_with_id ("Octave:deprecated-keyword", + "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d of file `%s'", + input_line_number, + curr_fcn_file_full_name.c_str ()); + else + warning_with_id ("Octave:deprecated-keyword", + "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d", + input_line_number); + // fall through ... + + case persistent_kw: + break; + case case_kw: case elseif_kw: case global_kw: - case static_kw: case until_kw: break; @@ -3451,7 +3467,14 @@ bool is_keyword (const std::string& s) { - return octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0; + // Parsing function names like "set.property_name" inside + // classdef-style class definitions is simplified by handling the + // "set" and "get" portions of the names using the same mechanism as + // is used for keywords. However, they are not really keywords in + // the language, so omit them from the list of possible keywords. + + return (octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0 + && ! (s == "set" || s == "get")); } DEFUN (iskeyword, args, , @@ -3474,10 +3497,22 @@ if (argc == 1) { + // Neither set and get are keywords. See the note in the + // is_keyword function for additional details. + string_vector lst (TOTAL_KEYWORDS); + int j = 0; + for (int i = 0; i < TOTAL_KEYWORDS; i++) - lst[i] = wordlist[i].name; + { + std::string tmp = wordlist[i].name; + + if (! (tmp == "set" || tmp == "get")) + lst[j++] = tmp; + } + + lst.resize (j); retval = Cell (lst.sort ()); } @@ -3675,7 +3710,7 @@ case TRY: std::cerr << "TRY\n"; break; case CATCH: std::cerr << "CATCH\n"; break; case GLOBAL: std::cerr << "GLOBAL\n"; break; - case STATIC: std::cerr << "STATIC\n"; break; + case PERSISTENT: std::cerr << "PERSISTENT\n"; break; case FCN_HANDLE: std::cerr << "FCN_HANDLE\n"; break; case END_OF_INPUT: std::cerr << "END_OF_INPUT\n\n"; break; case LEXICAL_ERROR: std::cerr << "LEXICAL_ERROR\n\n"; break;
--- a/src/load-path.cc +++ b/src/load-path.cc @@ -519,13 +519,40 @@ else xpath = sys_path; - do_set (xpath, false); + do_set (xpath, false, true); } void -load_path::do_clear (void) +load_path::do_clear (std::set<std::string>& new_elts) { - dir_info_list.clear (); + bool warn_default_path_clobbered = false; + for (dir_info_list_iterator i = dir_info_list.begin(); + i != dir_info_list.end(); + /* conditionally advance iterator in loop body */) + { + //Don't remove it if it's gonna be added again, but remove it from + //list of items to add, to avoid duplicates later on + std::set<std::string>::iterator j = new_elts.find(i->dir_name); + if (j != new_elts.end()) + { + new_elts.erase(j); + i++; + } + else + { + //Warn if removing a default directory and not immediately adding + //it back again + if(i->is_init) + warn_default_path_clobbered = true; + i = dir_info_list.erase(i); + } + } + + if (warn_default_path_clobbered) + warning_with_id ("Octave:remove-init-dir", + "default load path altered. Some built-in functions may " + "not be found. Try restoredefaultpath() to recover it."); + fcn_map.clear (); private_fcn_map.clear (); method_map.clear (); @@ -565,9 +592,10 @@ } void -load_path::do_set (const std::string& p, bool warn) +load_path::do_set (const std::string& p, bool warn, bool is_init) { - std::list<std::string> elts = split_path (p); + std::list<std::string> elts_l = split_path (p); + std::set<std::string> elts(elts_l.begin(), elts_l.end()); // Temporarily disable add hook. @@ -576,12 +604,12 @@ add_hook = 0; - do_clear (); - - for (std::list<std::string>::const_iterator i = elts.begin (); + do_clear (elts); + + for (std::set<std::string>::const_iterator i = elts.begin (); i != elts.end (); i++) - do_append (*i, warn); + do_append (*i, warn, is_init); // Restore add hook and execute for all newly added directories. frame.run_top (); @@ -599,10 +627,10 @@ } void -load_path::do_append (const std::string& dir, bool warn) +load_path::do_append (const std::string& dir, bool warn, bool is_init) { if (! dir.empty ()) - do_add (dir, true, warn); + do_add (dir, true, warn, is_init); } void @@ -631,7 +659,8 @@ } void -load_path::do_add (const std::string& dir_arg, bool at_end, bool warn) +load_path::do_add (const std::string& dir_arg, bool at_end, bool warn, + bool is_init) { size_t len = dir_arg.length (); @@ -656,6 +685,7 @@ if (fs.is_dir ()) { dir_info di (dir); + di.is_init = is_init; if (! error_state) { @@ -2137,7 +2167,7 @@ directory names separated by @code{pathsep} are also accepted. For example:\n\ \n\ @example\n\ -addpath (\"dir1:/dir2:~/dir3\");\n\ +addpath (\"dir1:/dir2:~/dir3\")\n\ @end example\n\ @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ @end deftypefn") @@ -2248,7 +2278,7 @@ directory names separated by @code{pathsep} are also accepted. For example:\n\ \n\ @example\n\ -rmpath (\"dir1:/dir2:~/dir3\");\n\ +rmpath (\"dir1:/dir2:~/dir3\")\n\ @end example\n\ @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ @end deftypefn")
--- a/src/load-path.h +++ b/src/load-path.h @@ -56,7 +56,10 @@ static void clear (void) { if (instance_ok ()) - instance->do_clear (); + { + std::set<std::string> no_new_elts; + instance->do_clear (no_new_elts); + } } static void set (const std::string& p, bool warn = false) @@ -294,14 +297,14 @@ // constructor for any other purpose. dir_info (void) : dir_name (), abs_dir_name (), is_relative (false), - dir_mtime (), dir_time_last_checked (), all_files (), - fcn_files (), private_file_map (), method_file_map () + is_init(false), dir_mtime (), dir_time_last_checked (), + all_files (), fcn_files (), private_file_map (), method_file_map () { } dir_info (const std::string& d) : dir_name (d), abs_dir_name (), is_relative (false), - dir_mtime (), dir_time_last_checked (), all_files (), - fcn_files (), private_file_map (), method_file_map () + is_init(false), dir_mtime (), dir_time_last_checked (), + all_files (), fcn_files (), private_file_map (), method_file_map () { initialize (); } @@ -309,6 +312,7 @@ dir_info (const dir_info& di) : dir_name (di.dir_name), abs_dir_name (di.abs_dir_name), is_relative (di.is_relative), + is_init (di.is_init), dir_mtime (di.dir_mtime), dir_time_last_checked (di.dir_time_last_checked), all_files (di.all_files), fcn_files (di.fcn_files), @@ -324,6 +328,7 @@ dir_name = di.dir_name; abs_dir_name = di.abs_dir_name; is_relative = di.is_relative; + is_init = di.is_init; dir_mtime = di.dir_mtime; dir_time_last_checked = di.dir_time_last_checked; all_files = di.all_files; @@ -340,6 +345,7 @@ std::string dir_name; std::string abs_dir_name; bool is_relative; + bool is_init; //Was this directory set by init? Warn when clearing it. octave_time dir_mtime; octave_time dir_time_last_checked; string_vector all_files; @@ -471,15 +477,16 @@ void do_initialize (bool set_initial_path); - void do_clear (void); + void do_clear (std::set<std::string>& new_elts); - void do_set (const std::string& p, bool warn); + void do_set (const std::string& p, bool warn, bool is_init=false); - void do_append (const std::string& dir, bool warn); + void do_append (const std::string& dir, bool warn, bool is_init=false); void do_prepend (const std::string& dir, bool warn); - void do_add (const std::string& dir, bool at_end, bool warn); + void do_add (const std::string& dir, bool at_end, bool warn, + bool is_init=false); void remove_fcn_map (const std::string& dir, const string_vector& fcn_files);
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -649,7 +649,7 @@ std::string orig_fname = ""; // Function called with Matlab-style ["filename", options] syntax - if (argc > 1 && argv[1].at(0) != '-') + if (argc > 1 && ! argv[1].empty () && argv[1].at(0) != '-') { orig_fname = argv[1]; i++; @@ -1532,6 +1532,7 @@ \n\ The list of variables to save may use wildcard patterns containing\n\ the following special characters:\n\ +\n\ @table @code\n\ @item ?\n\ Match any single character.\n\
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -386,7 +386,7 @@ @example\n\ @group\n\ ceil ([-2.7, 2.7])\n\ - @result{} -2 3\n\ + @result{} -2 3\n\ @end group\n\ @end example\n\ @seealso{floor, round, fix}\n\ @@ -542,8 +542,8 @@ z\n\ /\n\ erf (z) = (2/sqrt (pi)) | e^(-t^2) dt\n\ - /\n\ - t=0\n\ + /\n\ + t=0\n\ @end group\n\ @end example\n\ \n\ @@ -595,7 +595,7 @@ Compute the inverse error function, i.e., @var{y} such that\n\ \n\ @example\n\ - erf (@var{y}) == @var{x}\n\ +erf (@var{y}) == @var{x}\n\ @end example\n\ @seealso{erf, erfc, erfcx}\n\ @end deftypefn") @@ -812,7 +812,7 @@ @example\n\ @group\n\ fix ([-2.7, 2.7])\n\ - @result{} -2 2\n\ + @result{} -2 2\n\ @end group\n\ @end example\n\ @seealso{ceil, floor, round}\n\ @@ -847,7 +847,7 @@ @example\n\ @group\n\ floor ([-2.7, 2.7])\n\ - @result{} -3 2\n\ + @result{} -3 2\n\ @end group\n\ @end example\n\ @seealso{ceil, round, fix}\n\ @@ -889,8 +889,8 @@ infinity\n\ /\n\ gamma (z) = | t^(z-1) exp (-t) dt.\n\ - /\n\ - t=0\n\ + /\n\ + t=0\n\ @end group\n\ @end example\n\ \n\ @@ -1122,7 +1122,7 @@ @example\n\ @group\n\ isinf ([13, Inf, NA, NaN])\n\ - @result{} [ 0, 1, 0, 0 ]\n\ + @result{} [ 0, 1, 0, 0 ]\n\ @end group\n\ @end example\n\ @seealso{isfinite, isnan, isna}\n\ @@ -1263,7 +1263,7 @@ @example\n\ @group\n\ isnan ([13, Inf, NA, NaN])\n\ - @result{} [ 0, 0, 1, 1 ]\n\ + @result{} [ 0, 0, 1, 1 ]\n\ @end group\n\ @end example\n\ @seealso{isna, isinf, isfinite}\n\ @@ -1619,7 +1619,7 @@ @example\n\ @group\n\ round ([-2.7, 2.7])\n\ - @result{} -3 3\n\ + @result{} -3 3\n\ @end group\n\ @end example\n\ @seealso{ceil, floor, fix, roundb}\n\ @@ -1956,7 +1956,7 @@ @example\n\ @group\n\ tolower (\"MiXeD cAsE 123\")\n\ - @result{} \"mixed case 123\"\n\ + @result{} \"mixed case 123\"\n\ @end group\n\ @end example\n\ @seealso{toupper}\n\ @@ -2007,7 +2007,7 @@ @example\n\ @group\n\ toupper (\"MiXeD cAsE 123\")\n\ - @result{} \"MIXED CASE 123\"\n\ + @result{} \"MIXED CASE 123\"\n\ @end group\n\ @end example\n\ @seealso{tolower}\n\
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -68,6 +68,7 @@ #include "toplev.h" #include "pager.h" #include "parse.h" +#include "parse-private.h" #include "pt-all.h" #include "pt-eval.h" #include "symtab.h" @@ -126,7 +127,7 @@ static bool endfunction_found = false; // Keep track of symbol table information when parsing functions. -std::stack<symbol_table::scope_id> symtab_context; +symtab_context parser_symtab_context; // Name of the current class when we are parsing class methods or // constructors. @@ -365,11 +366,8 @@ { \ global_command = 0; \ yyerrok; \ - if (! symtab_context.empty ()) \ - { \ - symbol_table::set_scope (symtab_context.top ()); \ - symtab_context.pop (); \ - } \ + if (! parser_symtab_context.empty ()) \ + parser_symtab_context.pop (); \ if (interactive || forced_interactive) \ YYACCEPT; \ else \ @@ -446,7 +444,7 @@ %token <tok_val> BREAK CONTINUE FUNC_RET %token <tok_val> UNWIND CLEANUP %token <tok_val> TRY CATCH -%token <tok_val> GLOBAL STATIC +%token <tok_val> GLOBAL PERSISTENT %token <tok_val> FCN_HANDLE %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION %token <tok_val> METAQUERY @@ -997,9 +995,9 @@ $$ = make_decl_command (GLOBAL, $1, $3); lexer_flags.looking_at_decl_list = false; } - | STATIC parsing_decl_list decl1 + | PERSISTENT parsing_decl_list decl1 { - $$ = make_decl_command (STATIC, $1, $3); + $$ = make_decl_command (PERSISTENT, $1, $3); lexer_flags.looking_at_decl_list = false; } ; @@ -1224,7 +1222,8 @@ if (max_function_depth < current_function_depth) max_function_depth = current_function_depth; - symtab_context.push (symbol_table::current_scope ()); + parser_symtab_context.push (); + symbol_table::set_scope (symbol_table::alloc_scope ()); if (! reading_script_file && current_function_depth == 1 @@ -1246,7 +1245,7 @@ if (lexer_flags.looking_at_function_handle) { - symtab_context.push (symbol_table::current_scope ()); + parser_symtab_context.push (); symbol_table::set_scope (symbol_table::alloc_scope ()); lexer_flags.looking_at_function_handle--; lexer_flags.looking_at_anon_fcn_args = true; @@ -1395,11 +1394,13 @@ } | GET '.' identifier { + lexer_flags.parsed_function_name.top () = true; lexer_flags.maybe_classdef_get_set_method = false; $$ = $3; } | SET '.' identifier { + lexer_flags.parsed_function_name.top () = true; lexer_flags.maybe_classdef_get_set_method = false; $$ = $3; } @@ -2122,12 +2123,10 @@ symbol_table::scope_id fcn_scope = symbol_table::current_scope (); - if (symtab_context.empty ()) + if (parser_symtab_context.empty ()) panic_impossible (); - symbol_table::set_scope (symtab_context.top ()); - - symtab_context.pop (); + parser_symtab_context.pop (); stmt->set_print_flag (false); @@ -2970,11 +2969,10 @@ static void recover_from_parsing_function (void) { - if (symtab_context.empty ()) + if (parser_symtab_context.empty ()) panic_impossible (); - symbol_table::set_scope (symtab_context.top ()); - symtab_context.pop (); + parser_symtab_context.pop (); if (reading_fcn_file && current_function_depth == 1 && ! parsing_subfunctions) @@ -3089,9 +3087,9 @@ retval = new tree_global_command (lst, l, c); break; - case STATIC: + case PERSISTENT: if (current_function_depth > 0) - retval = new tree_static_command (lst, l, c); + retval = new tree_persistent_command (lst, l, c); else { if (reading_script_file) @@ -3515,7 +3513,11 @@ reading_classdef_file = true; reading_fcn_file = false; - reading_script_file = false; + // FIXME -- Should classdef files be handled as + // scripts or separately? Currently, without setting up + // for reading script files, parsing classdef files + // fails. + reading_script_file = true; } else { @@ -4217,9 +4219,9 @@ @group\n\ @var{f} = @@exp;\n\ feval (@var{f}, 1)\n\ - @result{} 2.7183\n\ + @result{} 2.7183\n\ @var{f} (1)\n\ - @result{} 2.7183\n\ + @result{} 2.7183\n\ @end group\n\ @end example\n\ \n\ @@ -4457,7 +4459,7 @@ value 3.1416 available.\n\ \n\ @example\n\ -eval(\"a = acos(-1);\");\n\ +eval (\"a = acos(-1);\");\n\ @end example\n\ \n\ If an error occurs during the evaluation of @var{try} the @var{catch}\n\
--- a/src/octave.gperf +++ b/src/octave.gperf @@ -60,6 +60,7 @@ methods_kw, otherwise_kw, parfor_kw, + persistent_kw, properties_kw, return_kw, set_kw, @@ -106,11 +107,11 @@ methods, METHODS, methods_kw otherwise, OTHERWISE, otherwise_kw parfor, PARFOR, parfor_kw -persistent, STATIC, static_kw +persistent, PERSISTENT, persistent_kw properties, PROPERTIES, properties_kw return, FUNC_RET, return_kw set, SET, set_kw -static, STATIC, static_kw +static, PERSISTENT, static_kw switch, SWITCH, switch_kw try, TRY, try_kw until, UNTIL, until_kw
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -1538,11 +1538,11 @@ @example\n\ @group\n\ s = speye (3);\n\ -sparse_auto_mutate (false)\n\ +sparse_auto_mutate (false);\n\ s(:, 1) = 1;\n\ typeinfo (s)\n\ @result{} sparse matrix\n\ -sparse_auto_mutate (true)\n\ +sparse_auto_mutate (true);\n\ s(1, :) = 1;\n\ typeinfo (s)\n\ @result{} matrix\n\
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -1395,24 +1395,24 @@ \n\ @example\n\ @group\n\ - s = struct('name', @{'Peter', 'Hannah', 'Robert'@},\n\ - 'age', @{23, 16, 3@});\n\ - c = struct2cell(s)\n\ - @result{} c = @{1x1x3 Cell Array@}\n\ - c(1,1,:)(:)\n\ - @result{} ans =\n\ - @{\n\ - [1,1] = Peter\n\ - [2,1] = Hannah\n\ - [3,1] = Robert\n\ - @}\n\ - c(2,1,:)(:)\n\ - @result{} ans =\n\ - @{\n\ - [1,1] = 23\n\ - [2,1] = 16\n\ - [3,1] = 3\n\ - @}\n\ +s = struct (\"name\", @{\"Peter\", \"Hannah\", \"Robert\"@},\n\ + \"age\", @{23, 16, 3@});\n\ +c = struct2cell (s)\n\ + @result{} c = @{1x1x3 Cell Array@}\n\ +c(1,1,:)(:)\n\ + @result{}\n\ + @{\n\ + [1,1] = Peter\n\ + [2,1] = Hannah\n\ + [3,1] = Robert\n\ + @}\n\ +c(2,1,:)(:)\n\ + @result{}\n\ + @{\n\ + [1,1] = 23\n\ + [2,1] = 16\n\ + [3,1] = 3\n\ + @}\n\ @end group\n\ @end example\n\ \n\
--- a/src/ov-null-mat.cc +++ b/src/ov-null-mat.cc @@ -96,6 +96,7 @@ delete array elements. This function should be used when overloading\n\ indexed assignment for user-defined classes instead of @code{isempty}, to\n\ distinguish the cases:\n\ +\n\ @table @asis\n\ @item @code{A(I) = []}\n\ This should delete elements if @code{I} is nonempty.\n\
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -2033,15 +2033,15 @@ \n\ @example\n\ @group\n\ -A = cell2struct (@{'Peter', 'Hannah', 'Robert';\n\ +A = cell2struct (@{\"Peter\", \"Hannah\", \"Robert\";\n\ 185, 170, 168@},\n\ - @{'Name','Height'@}, 1);\n\ + @{\"Name\",\"Height\"@}, 1);\n\ A(1)\n\ - @result{} ans =\n\ - @{\n\ - Name = Peter\n\ - Height = 185\n\ - @}\n\ + @result{}\n\ + @{\n\ + Name = Peter\n\ + Height = 185\n\ + @}\n\ \n\ @end group\n\ @end example\n\
--- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -387,10 +387,12 @@ // Save old and set current symbol table context, for // eval_undefined_error(). - octave_call_stack::push (this, local_scope, call_depth); + int context = is_anonymous_function () ? 0 : call_depth; + + octave_call_stack::push (this, local_scope, context); frame.add_fcn (octave_call_stack::pop); - if (call_depth > 0) + if (call_depth > 0 && ! is_anonymous_function ()) { symbol_table::push_context (); @@ -700,7 +702,7 @@ Within a function, return the number of values the caller expects to\n\ receive. If called with the optional argument @var{fcn}, a function\n\ name or handle, return the number of declared output values that the\n\ -function can produce. If the final output argument is @var{varargout}\n\ +function can produce. If the final output argument is @var{varargout}\n\ the returned value is negative.\n\ \n\ For example,\n\ @@ -726,12 +728,14 @@ nargout (@@histc) \% or nargout ('histc')\n\ @end example\n\ \n\ +@noindent\n\ will return 2, because @code{histc} has two outputs, whereas\n\ \n\ @example\n\ nargout (@@deal)\n\ @end example\n\ \n\ +@noindent\n\ will return -1, because @code{deal} has a variable number of outputs.\n\ \n\ At the top level, @code{nargout} with no argument is undefined.\n\
--- a/src/ov.cc +++ b/src/ov.cc @@ -2811,12 +2811,12 @@ @example\n\ @group\n\ val = magic(3)\n\ - @result{} val = [ 8 1 6\n\ - 3 5 7\n\ - 4 9 2 ]\n\ + @result{} val = [ 8 1 6\n\ + 3 5 7\n\ + 4 9 2 ]\n\ idx.type = \"()\";\n\ idx.subs = @{\":\", 1:2@};\n\ -subsref(val, idx)\n\ +subsref (val, idx)\n\ @result{} [ 8 1\n\ 3 5\n\ 4 9 ]\n\ @@ -2873,13 +2873,13 @@ \n\ @example\n\ @group\n\ -val = magic(3);\n\ +val = magic (3);\n\ idx.type = \"()\";\n\ idx.subs = @{\":\", 1:2@};\n\ subsasgn (val, idx, 0)\n\ - @result{} [ 0 0 6\n\ - 0 0 7\n\ - 0 0 2 ]\n\ + @result{} [ 0 0 6\n\ + 0 0 7\n\ + 0 0 2 ]\n\ @end group\n\ @end example\n\ \n\
new file mode 100644 --- /dev/null +++ b/src/parse-private.h @@ -0,0 +1,96 @@ +/* + +Copyright (C) 2012 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#if !defined (octave_parse_private_h) +#define octave_parse_private_h 1 + +#include <stack> + +#include "symtab.h" + +// Keep track of symbol table information when parsing functions. +class symtab_context +{ +private: + + class frame + { + public: + frame (symbol_table::scope_id s, symbol_table::scope_id c) + : m_scope (s), m_context (c) { } + + frame (const frame& f) : m_scope (f.m_scope), m_context (f.m_context) { } + + frame& operator = (const frame& f) + { + if (&f != this) + { + m_scope = f.m_scope; + m_context = f.m_context; + } + + return *this; + } + + ~frame (void) { } + + symbol_table::scope_id scope (void) const { return m_scope; } + symbol_table::scope_id context (void) const { return m_context; } + + private: + + symbol_table::scope_id m_scope; + symbol_table::scope_id m_context; + }; + + std::stack<frame> frame_stack; + +public: + symtab_context (void) : frame_stack () { } + + void clear (void) + { + while (! frame_stack.empty ()) + frame_stack.pop (); + } + + bool empty (void) const { return frame_stack.empty (); } + + void pop (void) + { + frame tmp = frame_stack.top (); + + symbol_table::set_scope_and_context (tmp.scope (), tmp.context ()); + + frame_stack.pop (); + } + + void push (void) + { + frame_stack.push (frame (symbol_table::current_scope (), + symbol_table::current_context ())); + } +}; + +extern symtab_context parser_symtab_context; + +#endif
--- a/src/parse.h +++ b/src/parse.h @@ -62,9 +62,6 @@ // TRUE means input is coming from startup file. extern bool input_from_startup_file; -// Keep track of symbol table information when parsing functions. -extern std::stack<symbol_table::scope_id> symtab_context; - // Name of the current class when we are parsing class methods or // constructors. extern std::string current_class_name;
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -3376,8 +3376,8 @@ \n\ @example\n\ @group\n\ - r = rats(hilb(4));\n\ - x = str2num(r)\n\ +r = rats (hilb (4));\n\ +x = str2num (r)\n\ @end group\n\ @end example\n\ \n\
--- a/src/profiler.cc +++ b/src/profiler.cc @@ -385,11 +385,11 @@ profile_data_accumulator::query_time (void) const { octave_time now; - // FIXME -- this should be removed at some point... See bug 34210. -#if defined (__CYGWIN__) || defined (__MINGW32__) - volatile -#endif - double dnow = now.double_value (); + + // FIXME -- is this volatile declaration really needed? + // See bug #34210 for additional details. + volatile double dnow = now.double_value (); + return dnow; }
--- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -111,7 +111,7 @@ } void -tree_breakpoint::visit_static_command (tree_static_command& cmd) +tree_breakpoint::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-bp.h +++ b/src/pt-bp.h @@ -58,7 +58,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-check.cc +++ b/src/pt-check.cc @@ -105,7 +105,7 @@ } void -tree_checker::visit_static_command (tree_static_command& cmd) +tree_checker::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-check.h +++ b/src/pt-check.h @@ -51,7 +51,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-decl.cc +++ b/src/pt-decl.cc @@ -132,16 +132,16 @@ // Static. tree_command * -tree_static_command::dup (symbol_table::scope_id scope, +tree_persistent_command::dup (symbol_table::scope_id scope, symbol_table::context_id context) const { return - new tree_static_command (init_list ? init_list->dup (scope, context) : 0, - line (), column ()); + new tree_persistent_command (init_list ? init_list->dup (scope, context) : 0, + line (), column ()); } void -tree_static_command::accept (tree_walker& tw) +tree_persistent_command::accept (tree_walker& tw) { - tw.visit_static_command (*this); + tw.visit_persistent_command (*this); }
--- a/src/pt-decl.h +++ b/src/pt-decl.h @@ -207,20 +207,20 @@ tree_global_command& operator = (const tree_global_command&); }; -// Static. +// Persistent. class -tree_static_command : public tree_decl_command +tree_persistent_command : public tree_decl_command { public: - tree_static_command (int l = -1, int c = -1) - : tree_decl_command ("static", l, c) { } + tree_persistent_command (int l = -1, int c = -1) + : tree_decl_command ("persistent", l, c) { } - tree_static_command (tree_decl_init_list *t, int l = -1, int c = -1) - : tree_decl_command ("static", t, l, c) { } + tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) + : tree_decl_command ("persistent", t, l, c) { } - ~tree_static_command (void) { } + ~tree_persistent_command (void) { } tree_command *dup (symbol_table::scope_id scope, symbol_table::context_id context) const; @@ -233,9 +233,9 @@ // No copying! - tree_static_command (const tree_static_command&); + tree_persistent_command (const tree_persistent_command&); - tree_static_command& operator = (const tree_static_command&); + tree_persistent_command& operator = (const tree_persistent_command&); }; #endif
--- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -215,7 +215,7 @@ } void -tree_evaluator::visit_static_command (tree_static_command& cmd) +tree_evaluator::visit_persistent_command (tree_persistent_command& cmd) { if (debug_mode) do_breakpoint (cmd.is_breakpoint ());
--- a/src/pt-eval.h +++ b/src/pt-eval.h @@ -60,7 +60,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-idx.cc +++ b/src/pt-idx.cc @@ -177,13 +177,13 @@ static inline octave_value_list make_value_list (tree_argument_list *args, const string_vector& arg_nm, - const octave_value *object) + const octave_value *object, bool rvalue = true) { octave_value_list retval; if (args) { - if (object && args->has_magic_end () && object->is_undefined ()) + if (rvalue && object && args->has_magic_end () && object->is_undefined ()) gripe_invalid_inquiry_subscript (); else retval = args->convert_to_const_vector (object); @@ -476,7 +476,7 @@ case '(': { octave_value_list tidx - = make_value_list (*p_args, *p_arg_nm, &tmp); + = make_value_list (*p_args, *p_arg_nm, &tmp, false); idx.push_back (tidx); @@ -496,7 +496,7 @@ case '{': { octave_value_list tidx - = make_value_list (*p_args, *p_arg_nm, &tmp); + = make_value_list (*p_args, *p_arg_nm, &tmp, false); if (tmp.is_undefined ()) { @@ -601,6 +601,18 @@ /* %!test +%! clear x +%! clear y +%! y = 3; +%! x(y(end)) = 1; +%! assert (x, [0, 0, 1]); +%! clear x +%! clear y +%! y = {3}; +%! x(y{end}) = 1; +%! assert (x, [0, 0, 1]); + +%!test %! x = {1, 2, 3}; %! [x{:}] = deal (4, 5, 6); %! assert (x, {4, 5, 6});
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -1400,9 +1400,9 @@ @group\n\ string_fill_char (\"X\");\n\ [ \"these\"; \"are\"; \"strings\" ]\n\ - @result{} \"theseXX\"\n\ - \"areXXXX\"\n\ - \"strings\"\n\ + @result{} \"theseXX\"\n\ + \"areXXXX\"\n\ + \"strings\"\n\ @end group\n\ @end example\n\ \n\
--- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -165,7 +165,7 @@ } void -tree_print_code::visit_static_command (tree_static_command& cmd) +tree_print_code::visit_persistent_command (tree_persistent_command& cmd) { do_decl_command (cmd); }
--- a/src/pt-pr-code.h +++ b/src/pt-pr-code.h @@ -67,7 +67,7 @@ void visit_global_command (tree_global_command&); - void visit_static_command (tree_static_command&); + void visit_persistent_command (tree_persistent_command&); void visit_decl_elt (tree_decl_elt&);
--- a/src/pt-walk.h +++ b/src/pt-walk.h @@ -30,7 +30,7 @@ class tree_colon_expression; class tree_continue_command; class tree_global_command; -class tree_static_command; +class tree_persistent_command; class tree_decl_elt; class tree_decl_init_list; class tree_simple_for_command; @@ -92,7 +92,7 @@ visit_global_command (tree_global_command&) = 0; virtual void - visit_static_command (tree_static_command&) = 0; + visit_persistent_command (tree_persistent_command&) = 0; virtual void visit_decl_elt (tree_decl_elt&) = 0;
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -79,13 +79,25 @@ #define BADSIG (void (*)(int))-1 #endif +// The following is a workaround for an apparent bug in GCC 4.1.2 and +// possibly earlier versions. See Octave bug report #30685 for details. +#if defined (__GNUC__) +# if ! (__GNUC__ > 4 \ + || (__GNUC__ == 4 && (__GNUC_MINOR__ > 1 \ + || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 2)))) +# undef GNULIB_NAMESPACE +# define GNULIB_NAMESPACE +# warning "disabling GNULIB_NAMESPACE for signal functions -- consider upgrading to a current version of GCC" +# endif +#endif + #define BLOCK_SIGNAL(sig, nvar, ovar) \ do \ { \ - gnulib::sigemptyset (&nvar); \ - gnulib::sigaddset (&nvar, sig); \ - gnulib::sigemptyset (&ovar); \ - gnulib::sigprocmask (SIG_BLOCK, &nvar, &ovar); \ + GNULIB_NAMESPACE::sigemptyset (&nvar); \ + GNULIB_NAMESPACE::sigaddset (&nvar, sig); \ + GNULIB_NAMESPACE::sigemptyset (&ovar); \ + GNULIB_NAMESPACE::sigprocmask (SIG_BLOCK, &nvar, &ovar); \ } \ while (0) @@ -94,7 +106,7 @@ #endif #define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar) -#define UNBLOCK_CHILD(ovar) gnulib::sigprocmask (SIG_SETMASK, &ovar, 0) +#define UNBLOCK_CHILD(ovar) GNULIB_NAMESPACE::sigprocmask (SIG_SETMASK, &ovar, 0) // Called from octave_quit () to actually do something about the signals // we have caught. @@ -185,7 +197,7 @@ { octave_set_signal_handler (sig_number, SIG_DFL); - gnulib::raise (sig_number); + GNULIB_NAMESPACE::raise (sig_number); } } } @@ -216,10 +228,10 @@ act.sa_flags |= SA_RESTART; #endif - gnulib::sigemptyset (&act.sa_mask); - gnulib::sigemptyset (&oact.sa_mask); + GNULIB_NAMESPACE::sigemptyset (&act.sa_mask); + GNULIB_NAMESPACE::sigemptyset (&oact.sa_mask); - gnulib::sigaction (sig, &act, &oact); + GNULIB_NAMESPACE::sigaction (sig, &act, &oact); return oact.sa_handler; }
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -64,13 +64,13 @@ @example\n\ @group\n\ char ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\ - @result{} [\"abc \"\n\ - \" \"\n\ - \"98 \"\n\ - \"99 \"\n\ - \"d \"\n\ - \"str1 \"\n\ - \"half \"]\n\ + @result{} [\"abc \"\n\ + \" \"\n\ + \"98 \"\n\ + \"99 \"\n\ + \"d \"\n\ + \"str1 \"\n\ + \"half \"]\n\ @end group\n\ @end example\n\ @seealso{strvcat, cellstr}\n\ @@ -195,12 +195,12 @@ @example\n\ @group\n\ strvcat ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\ - @result{} [\"abc \"\n\ - \"98 \"\n\ - \"99 \"\n\ - \"d \"\n\ - \"str1 \"\n\ - \"half \"]\n\ + @result{} [\"abc \"\n\ + \"98 \"\n\ + \"99 \"\n\ + \"d \"\n\ + \"str1 \"\n\ + \"half \"]\n\ @end group\n\ @end example\n\ @seealso{char, strcat, cstrcat}\n\ @@ -665,7 +665,7 @@ @example\n\ @group\n\ strncmp (\"abce\", \"abcd\", 3)\n\ - @result{} 1\n\ + @result{} 1\n\ @end group\n\ @end example\n\ \n\ @@ -867,9 +867,9 @@ @smallexample\n\ @group\n\ list_in_columns (@{\"abc\", \"def\", \"ghijkl\", \"mnop\", \"qrs\", \"tuv\"@}, 20)\n\ - @result{} ans = abc mnop\n\ - def qrs\n\ - ghijkl tuv\n\ + @result{} abc mnop\n\ + def qrs\n\ + ghijkl tuv\n\ \n\ whos ans\n\ @result{}\n\
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -269,10 +269,11 @@ until (done)\n\ fclose (out);\n\ waitpid (pid);\n\ - @print{} these\n\ - @print{} strings\n\ - @print{} some\n\ - @print{} are\n\ +\n\ + @print{} these\n\ + @print{} strings\n\ + @print{} some\n\ + @print{} are\n\ @end example\n\ \n\ Note that @code{popen2}, unlike @code{popen}, will not \"reap\" the\n\ @@ -949,25 +950,25 @@ \n\ @example\n\ [s, err, msg] = stat (\"/vmlinuz\")\n\ - @result{} s =\n\ - @{\n\ - atime = 855399756\n\ - rdev = 0\n\ - ctime = 847219094\n\ - uid = 0\n\ - size = 389218\n\ - blksize = 4096\n\ - mtime = 847219094\n\ - gid = 6\n\ - nlink = 1\n\ - blocks = 768\n\ - mode = -rw-r--r--\n\ - modestr = -rw-r--r--\n\ - ino = 9316\n\ - dev = 2049\n\ - @}\n\ - @result{} err = 0\n\ - @result{} msg =\n\ + @result{} s =\n\ + @{\n\ + atime = 855399756\n\ + rdev = 0\n\ + ctime = 847219094\n\ + uid = 0\n\ + size = 389218\n\ + blksize = 4096\n\ + mtime = 847219094\n\ + gid = 6\n\ + nlink = 1\n\ + blocks = 768\n\ + mode = -rw-r--r--\n\ + modestr = -rw-r--r--\n\ + ino = 9316\n\ + dev = 2049\n\ + @}\n\ + @result{} err = 0\n\ + @result{} msg =\n\ @end example\n\ @end deftypefn") { @@ -1203,13 +1204,13 @@ @example\n\ @group\n\ uname ()\n\ - @result{} @{\n\ - sysname = x86_64\n\ - nodename = segfault\n\ - release = 2.6.15-1-amd64-k8-smp\n\ - version = Linux\n\ - machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ - @}\n\ + @result{} @{\n\ + sysname = x86_64\n\ + nodename = segfault\n\ + release = 2.6.15-1-amd64-k8-smp\n\ + version = Linux\n\ + machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ + @}\n\ @end group\n\ @end example\n\ \n\
--- a/src/variables.cc +++ b/src/variables.cc @@ -361,7 +361,7 @@ @group\n\ global x\n\ isglobal (\"x\")\n\ - @result{} 1\n\ + @result{} 1\n\ @end group\n\ @end example\n\ @seealso{isvarname, exist}\n\ @@ -1798,6 +1798,7 @@ @table @asis\n\ @item Attr\n\ Attributes of the listed variable. Possible attributes are:\n\ +\n\ @table @asis\n\ @item blank\n\ Variable in local scope\n\ @@ -2298,6 +2299,7 @@ clear the function definition.\n\ \n\ The following options are available in both long and short form\n\ +\n\ @table @code\n\ @item -all, -a\n\ Clears all local and global user-defined variables and all functions\n\
--- a/test/Makefile.am +++ b/test/Makefile.am @@ -23,6 +23,7 @@ FCN_FILES = \ fntests.m \ test_args.m \ + test_bug_31371.m \ test_diag_perm.m \ test_error.m \ test_eval-catch.m \ @@ -49,6 +50,7 @@ test_unwind.m \ test_while.m +include bug-35448/module.mk include classes/module.mk include class-concat/module.mk include ctor-vs-method/module.mk
new file mode 100644 --- /dev/null +++ b/test/bug-35448/fA.m @@ -0,0 +1,10 @@ +# fA.m +function y = fA (x, f) + global gfun + if nargin < 2 + y = fA (x, gfun); + else + w = feval (f, x); + y = feval (@fB, w); + endif +endfunction
new file mode 100644 --- /dev/null +++ b/test/bug-35448/fB.m @@ -0,0 +1,4 @@ +# fB.m +function y = fB (x) + y = x; +endfunction
new file mode 100644 --- /dev/null +++ b/test/bug-35448/fC.m @@ -0,0 +1,4 @@ +# fC.m +function y = fC (x) + y = x; +endfunction
new file mode 100644 --- /dev/null +++ b/test/bug-35448/module.mk @@ -0,0 +1,7 @@ +bug_35448_FCN_FILES = \ + bug-35448/fA.m \ + bug-35448/fB.m \ + bug-35448/fC.m \ + class-concat/test_bug_35448.m + +FCN_FILES += $(bug_35448_FCN_FILES)
new file mode 100644 --- /dev/null +++ b/test/bug-35448/test_bug_35448.m @@ -0,0 +1,11 @@ +%!test +%! global gfun +%! gfun = @fB; +%! y = fA (e); +%! assert (y, e); + +%!test +%! global gfun +%! gfun = @fC; +%! y = fA (e); +%! assert (y, e);
--- a/test/fntests.m +++ b/test/fntests.m @@ -265,26 +265,30 @@ dxf += xf; dsk += sk; endfor - printf ("\nSummary:\n\n PASS %6d\n", dp); + puts ("\nSummary:\n\n"); nfail = dn - dp; - printf (" FAIL %6d\n", nfail); + printf (" PASS %6d\n", dp); + printf (" FAIL %6d\n", nfail); if (dxf > 0) - if (dxf > 1) - t1 = "were"; - t2 = "failures"; - else - t1 = "was"; - t2 = "failure"; - endif - printf ("\nThere %s %d expected %s (see fntests.log for details).\n", - t1, dxf, t2); - puts ("\nExpected failures are known bugs. Please help improve Octave\n"); - puts ("by contributing fixes for them.\n"); + printf (" XFAIL %6d\n", dxf); endif if (dsk > 0) - printf ("\nThere were %d skipped tests (see fntests.log for details).\n", dsk); - puts ("Skipped tests are features that are disabled in this version of Octave\n"); - puts ("because the needed libraries were not present when Octave was built.\n"); + printf (" SKIPPED %6d\n", dsk); + endif + puts ("\n"); + puts ("See the file test/fntests.log for additional details.\n"); + if (dxf > 0) + puts ("\n"); + puts ("Expected failures (listed as XFAIL above) are known bugs.\n"); + puts ("Please help improve Octave by contributing fixes for them.\n"); + endif + if (dsk > 0) + puts ("\n"); + puts ("Tests are most often skipped because the features they require\n"); + puts ("have been disabled. Features are most often disabled because\n"); + puts ("they require dependencies that were not present when Octave\n"); + puts ("was built. The configure script should have printed a summary\n"); + puts ("at the end of its run indicating which dependencies were not found.\n"); endif ## Weed out deprecated and private functions
new file mode 100644 --- /dev/null +++ b/test/test_bug_31371.m @@ -0,0 +1,41 @@ +%!test +%! % Work around MATLAB bug where f(x)(y) is invalid syntax +%! % (This bug does not apply to Octave) +%! +%! C = @(fcn,x) fcn(x); +%! C2 = @(fcn,x,y) fcn(x,y); +%! +%! % Church Booleans +%! T = @(t,f) t; +%! F = @(t,f) f; +%! +%! % Church Numerals +%! Zero = @(fcn,x) x; +%! One = @(fcn,x) fcn(x); +%! Two = @(fcn,x) fcn(fcn(x)); +%! Three = @(fcn,x) fcn(fcn(fcn(x))); +%! Four = @(fcn,x) fcn(fcn(fcn(fcn(x)))); +%! +%! % Arithmetic Operations +%! Inc = @(a) @(f,x) f(a(f,x)); % Increment +%! Add = @(a,b) @(f,x) a(f,b(f,x)); +%! Mult = @(a,b) @(f,x) a(@(x) b(f,x),x); +%! Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement +%! Sub = @(a,b) b(Dec, a); +%! +%! % Renderer - Convert church numeral to "real" number +%! Render = @(n) n(@(n) n+1,0); +%! +%! % Predicates +%! Iszero = @(n) n(@(x) F, T); +%! +%! % Y combinator implements recursion +%! Ycomb = @(f) C(@(g) f(@(x) C(g(g), x)), ... +%! @(g) f(@(x) C(g(g), x))); +%! +%! Factorial = Ycomb(@(f) @(n) C(C2(Iszero(n), ... +%! @(d) One, @(d) Mult(n, f(Dec(n)))),0)); +%! +%! assert (Render (Factorial (Two)), 2) +%! assert (Render (Factorial (Three)), 6) +%! assert (Render (Factorial (Four)), 24)
--- a/test/test_io.m +++ b/test/test_io.m @@ -227,6 +227,8 @@ %! %! delete matrix.ascii; +%!error <unable to find file> load ("") + %% FIXME: This test is disabled as it writes to stdout and there is no easy %% way to recover output. Need to spawn new octave process and pipe stdout %% somewhere to treat this case.