Mercurial > octave
changeset 25146:a01a899e47c0
remove m-file functions deprecated in version 4.2
* bitmax.m, mahalanobis.m, md5sum.m, octave_config_info.m,
onenormest.m, sleep.m, usleep.m, wavread.m, wavwrite.m: Delete.
* condest.m (condest_legacy): Delete function and associated tests.
(condest): Delete special cases for calling condest_legacy.
* module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Apr 2018 10:35:20 -0400 |
parents | dfc6ccc2a3e8 |
children | 5960fd1b56f1 |
files | scripts/deprecated/mahalanobis.m scripts/deprecated/md5sum.m scripts/deprecated/module.mk scripts/deprecated/octave_config_info.m scripts/deprecated/onenormest.m scripts/deprecated/sleep.m scripts/deprecated/usleep.m scripts/deprecated/wavread.m scripts/deprecated/wavwrite.m scripts/linear-algebra/condest.m |
diffstat | 10 files changed, 1 insertions(+), 1128 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/deprecated/mahalanobis.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -## Copyright (C) 1996-2018 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} mahalanobis (@var{x}, @var{y}) -## -## @code{mahalanobis} is deprecated and will be removed in Octave version 4.6. -## See the @code{mahal} function in the statistics package from Octave-Forge -## for equivalent functionality. -## -## Return the Mahalanobis' D-square distance between the multivariate -## samples @var{x} and @var{y}. -## -## The data @var{x} and @var{y} must have the same number of components -## (columns), but may have a different number of observations (rows). -## @end deftypefn - -## Author: Friedrich Leisch <leisch@ci.tuwien.ac.at> -## Created: July 1993 -## Adapted-By: jwe - -function retval = mahalanobis (x, y) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "mahalanobis is obsolete and will be removed from a future version of Octave, please use mahal from the statistics package in Octave-Forge instead"); - endif - - if (nargin != 2) - print_usage (); - endif - - if ( ! (isnumeric (x) || islogical (x)) - || ! (isnumeric (y) || islogical (y))) - error ("mahalanobis: X and Y must be numeric matrices or vectors"); - endif - - if (ndims (x) != 2 || ndims (y) != 2) - error ("mahalanobis: X and Y must be 2-D matrices or vectors"); - endif - - [xr, xc] = size (x); - [yr, yc] = size (y); - - if (xc != yc) - error ("mahalanobis: X and Y must have the same number of columns"); - endif - - if (isinteger (x)) - x = double (x); - endif - - xm = mean (x); - ym = mean (y); - - ## Center data by subtracting means - x = bsxfun (@minus, x, xm); - y = bsxfun (@minus, y, ym); - - w = (x' * x + y' * y) / (xr + yr - 2); - - retval = sumsq ((xm - ym) / chol (w)); - -endfunction - -## 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))
--- a/scripts/deprecated/md5sum.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -## Copyright (C) 2007-2018 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} md5sum (@var{file}) -## @deftypefnx {} {} md5sum (@var{str}, @var{opt}) -## -## @code{md5sum} is deprecated and will be removed in Octave version 4.6. -## For equivalent functionality replace calls like @code{md5sum (@var{file})} -## with: -## -## @example -## hash ("md5", fileread (@var{file})) -## @end example -## -## And calls like @code{md5sum (@var{str}, true)} with: -## -## @example -## hash ("md5", fileread (@var{str})) -## @end example -## -## Calculate the MD5 sum of the file @var{file}. -## -## If the second parameter @var{opt} exists and is true, then calculate the MD5 -## sum of the string @var{str}. -## -## @seealso{hash, fileread} -## @end deftypefn - -function r = md5sum (str, opt) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "md5sum is obsolete and will be removed from a future version of Octave, please use hash instead"); - endif - - if (nargin == 1) - r = hash ("md5", fileread (str)); - elseif ((nargin == 2) && isbool (opt) && isscalar (opt) && (opt == true)) - r = hash ("md5", str); - else - print_usage (); - endif - -endfunction - - -%!assert (md5sum ("abc\0", true), "147a664a2ca9410911e61986d3f0d52a") - -%!test -%! tfile = tempname (); -%! fid = fopen (tfile, "wb"); -%! fwrite (fid, "abc\0"); -%! fclose (fid); -%! assert (md5sum (tfile), "147a664a2ca9410911e61986d3f0d52a"); -%! unlink (tfile); - -%!error md5sum ()
--- a/scripts/deprecated/module.mk Sat Apr 07 10:37:13 2018 -0400 +++ b/scripts/deprecated/module.mk Sat Apr 07 10:35:20 2018 -0400 @@ -1,24 +1,15 @@ FCN_FILE_DIRS += scripts/deprecated %canon_reldir%_FCN_FILES = \ - %reldir%/bitmax.m \ %reldir%/chop.m \ %reldir%/comma.m \ %reldir%/desktop.m \ %reldir%/isstr.m \ %reldir%/java2mat.m \ - %reldir%/mahalanobis.m \ - %reldir%/md5sum.m \ - %reldir%/octave_config_info.m \ - %reldir%/onenormest.m \ %reldir%/paren.m \ %reldir%/semicolon.m \ - %reldir%/sleep.m \ %reldir%/tmpnam.m \ - %reldir%/toascii.m \ - %reldir%/usleep.m \ - %reldir%/wavread.m \ - %reldir%/wavwrite.m + %reldir%/toascii.m %canon_reldir%dir = $(fcnfiledir)/deprecated
--- a/scripts/deprecated/octave_config_info.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -## Copyright (C) 2016-2018 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} octave_config_info () -## @deftypefnx {} {} octave_config_info (@var{option}) -## -## @code{octave_config_info} is deprecated and will be removed in -## Octave version 4.6. Use @code{__have_feature__ (@var{option})} or -## @code{__octave_config_info__} as a replacement. -## -## Return a structure containing configuration and installation -## information for Octave. -## -## If @var{option} is a string, return the configuration information for -## the specified option. -## -## @seealso{computer} -## @end deftypefn - -## Deprecated in version 4.2 - -function [retval, build_env_cell] = octave_config_info (option) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "octave_config_info is obsolete and will be removed from a future version of Octave, please use __have_feature__ or __octave_config_info__ instead."); - endif - - if (nargin > 1) - print_usage (); - endif - - if (nargin == 0) - info = __octave_config_info__ (); - ## Structure layout has changed. - - dld = info.dld; - float_format = info.float_format; - words_big_endian = info.words_big_endian; - words_little_endian = info.words_little_endian; - - features = info.build_features; - - env = info.build_environment; - env_fields = fieldnames (env); - env_vals = struct2cell (env); - env_cell = [env_fields, env_vals]'; - - info = rmfield (info, {"dld", "float_format", "words_big_endian", ... - "words_little_endian", "build_features", ... - "build_environment"}); - - other_fields = fieldnames (info); - other_vals = struct2cell (info); - other_cell = [other_fields, other_vals]'; - - retval = struct ("dld", dld, - "float_format", float_format, - "words_big_endian", words_big_endian, - "words_little_endian", words_little_endian, - "features", features, - env_cell{:}, other_cell{:}); - else - if (strcmp (option, "features")) - option = "build_features"; - endif - retval = __octave_config_info__ (option); - endif - -endfunction
--- a/scripts/deprecated/onenormest.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,307 +0,0 @@ -## Copyright (C) 2007-2018 Regents of the University of California -## -## 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {[@var{est}, @var{v}, @var{w}, @var{iter}] =} onenormest (@var{A}, @var{t}) -## @deftypefnx {} {[@var{est}, @var{v}, @var{w}, @var{iter}] =} onenormest (@var{apply}, @var{apply_t}, @var{n}, @var{t}) -## -## @code{onenormest} is deprecated and will be removed in Octave version 4.4. -## Use @code{normest1} for the equivalent functionality. -## -## Apply @nospell{Higham and Tisseur's} randomized block 1-norm estimator to -## matrix @var{A} using @var{t} test vectors. -## -## If @var{t} exceeds 5, then only 5 test vectors are used. -## -## If the matrix is not explicit, e.g., when estimating the norm of -## @code{inv (@var{A})} given an LU@tie{}factorization, @code{onenormest} -## applies @var{A} and its conjugate transpose through a pair of functions -## @var{apply} and @var{apply_t}, respectively, to a dense matrix of size -## @var{n} by @var{t}. The implicit version requires an explicit dimension -## @var{n}. -## -## Returns the norm estimate @var{est}, two vectors @var{v} and @var{w} related -## by norm @code{(@var{w}, 1) = @var{est} * norm (@var{v}, 1)}, and the number -## of iterations @var{iter}. The number of iterations is limited to 10 and is -## at least 2. -## -## References: -## -## @itemize -## @item -## @nospell{N.J. Higham and F. Tisseur}, @cite{A Block Algorithm -## for Matrix 1-Norm Estimation, with an Application to 1-Norm -## Pseudospectra}. SIMAX vol 21, no 4, pp 1185-1201. -## @url{http://dx.doi.org/10.1137/S0895479899356080} -## -## @item -## @nospell{N.J. Higham and F. Tisseur}, @cite{A Block Algorithm -## for Matrix 1-Norm Estimation, with an Application to 1-Norm -## Pseudospectra}. @url{http://citeseer.ist.psu.edu/223007.html} -## @end itemize -## -## @seealso{condest, norm, cond} -## @end deftypefn - -## Code originally licensed under: -## -## Copyright (c) 2007, Regents of the University of California -## All rights reserved. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions -## are met: -## -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above -## copyright notice, this list of conditions and the following -## disclaimer in the documentation and/or other materials provided -## with the distribution. -## -## * Neither the name of the University of California, Berkeley nor -## the names of its contributors may be used to endorse or promote -## products derived from this software without specific prior -## written permission. -## -## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -## PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND -## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -## SUCH DAMAGE. - -## Author: Jason Riedy <ejr@cs.berkeley.edu> -## Keywords: linear-algebra norm estimation -## Version: 0.2 - -function [est, v, w, iter] = onenormest (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "onenormest is obsolete and will be removed from a future version of Octave, please use normest1 instead"); - endif - - - if (nargin < 1 || nargin > 4) - print_usage (); - endif - - default_t = 5; - itmax = 10; - - if (isnumeric (varargin{1})) - [n, nc] = size (varargin{1}); - if (n != nc) - error ("onenormest: matrix must be square"); - endif - apply = @(x) varargin{1} * x; - apply_t = @(x) varargin{1}' * x; - if (nargin > 1) - t = varargin{2}; - else - t = min (n, default_t); - endif - issing = isa (varargin{1}, "single"); - else - if (nargin < 3) - print_usage (); - endif - apply = varargin{1}; - apply_t = varargin{2}; - n = varargin{3}; - if (nargin > 3) - t = varargin{4}; - else - t = default_t; - endif - issing = isa (n, "single"); - endif - - ## Initial test vectors X. - X = rand (n, t); - X ./= ones (n,1) * sum (abs (X), 1); - - ## Track if a vertex has been visited. - been_there = zeros (n, 1); - - ## To check if the estimate has increased. - est_old = 0; - - ## Normalized vector of signs. - S = zeros (n, t); - - if (issing) - myeps = eps ("single"); - X = single (X); - else - myeps = eps; - endif - - for iter = 1 : itmax + 1 - Y = feval (apply, X); - - ## Find the initial estimate as the largest A*x. - [est, ind_best] = max (sum (abs (Y), 1)); - if (est > est_old || iter == 2) - w = Y(:,ind_best); - endif - if (iter >= 2 && est < est_old) - ## No improvement, so stop. - est = est_old; - break; - endif - - est_old = est; - S_old = S; - if (iter > itmax), - ## Gone too far. Stop. - break; - endif - - S = sign (Y); - - ## Test if any of S are approximately parallel to previous S - ## vectors or current S vectors. If everything is parallel, - ## stop. Otherwise, replace any parallel vectors with - ## rand{-1,+1}. - partest = any (abs (S_old' * S - n) < 4*eps*n); - if (all (partest)) - ## All the current vectors are parallel to old vectors. - ## We've hit a cycle, so stop. - break; - endif - if (any (partest)) - ## Some vectors are parallel to old ones and are cycling, - ## but not all of them. Replace the parallel vectors with - ## rand{-1,+1}. - numpar = sum (partest); - replacements = 2*(rand (n,numpar) < 0.5) - 1; - S(:,partest) = replacements; - endif - ## Now test for parallel vectors within S. - partest = any ((S' * S - eye (t)) == n); - if (any (partest)) - numpar = sum (partest); - replacements = 2*(rand (n,numpar) < 0.5) - 1; - S(:,partest) = replacements; - endif - - Z = feval (apply_t, S); - - ## Now find the largest non-previously-visted index per vector. - h = max (abs (Z),2); - [mh, mhi] = max (h); - if (iter >= 2 && mhi == ind_best) - ## Hit a cycle, stop. - break; - endif - [h, ind] = sort (h, 'descend'); - if (t > 1) - firstind = ind(1:t); - if (all (been_there(firstind))) - ## Visited all these before, so stop. - break; - endif - ind = ind(! been_there(ind)); - if (length (ind) < t) - ## There aren't enough new vectors, so we're practically - ## in a cycle. Stop. - break; - endif - endif - - ## Visit the new indices. - X = zeros (n, t); - for zz = 1 : t - X(ind(zz),zz) = 1; - endfor - been_there(ind(1 : t)) = 1; - endfor - - ## The estimate est and vector w are set in the loop above. - ## The vector v selects the ind_best column of A. - v = zeros (n, 1); - v(ind_best) = 1; - -endfunction - - -%!demo -%! N = 100; -%! A = randn (N) + eye (N); -%! [L,U,P] = lu (A); -%! nm1inv = onenormest (@(x) U\(L\(P*x)), @(x) P'*(L'\(U'\x)), N, 30) -%! norm (inv (A), 1) - -%!test -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 10; -%! A = ones (N); -%! [nm1, v1, w1] = onenormest (A); -%! [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); - -%!test -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 10; -%! A = ones (N); -%! [nm1, v1, w1] = onenormest (@(x) A*x, @(x) A'*x, N, 3); -%! [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); - -%!test -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 5; -%! A = hilb (N); -%! [nm1, v1, w1] = onenormest (A); -%! [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); - -## Only likely to be within a factor of 10. -%!test -%! warning ("off", "Octave:deprecated-function", "local"); -%! old_state = rand ("state"); -%! restore_state = onCleanup (@() rand ("state", old_state)); -%! rand ("state", 42); # Initialize to guarantee reproducible results -%! N = 100; -%! A = rand (N); -%! [nm1, v1, w1] = onenormest (A); -%! [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);
--- a/scripts/deprecated/sleep.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -## Copyright (C) 1993-2018 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} sleep (@var{seconds}) -## -## @code{sleep} is deprecated and will be removed in Octave version 4.6. -## Use @code{pause} instead. -## -## Suspend the execution of the program for the given number of seconds. -## -## @seealso{pause} -## @end deftypefn - -function sleep (seconds) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "sleep is obsolete and will be removed from a future version of Octave, please use pause instead"); - endif - - if (nargin == 1) - pause (seconds); - else - print_usage (); - endif - -endfunction - - -%!test -%! sleep (1); - -%!error (sleep ()) -%!error (sleep (1, 2))
--- a/scripts/deprecated/usleep.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -## Copyright (C) 1993-2018 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} usleep (@var{microseconds}) -## -## @code{usleep} is deprecated and will be removed in Octave version 4.6. -## Use @code{pause} instead. -## -## Suspend the execution of the program for the given number of -## microseconds (1e-6 seconds). -## -## @seealso{pause} -## @end deftypefn - -function usleep (microseconds) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "usleep is obsolete and will be removed from a future version of Octave, please use pause instead"); - endif - - if (nargin == 1) - pause (microseconds / 1e6); - else - print_usage (); - endif - -endfunction - - -%!test -%! usleep (1000); - -%!error (usleep ()) -%!error (usleep (1, 2))
--- a/scripts/deprecated/wavread.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -## Copyright (C) 2016-2018 Mike Miller -## Copyright (C) 2005-2018 Michael Zeising -## -## 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {@var{y} =} wavread (@var{filename}) -## @deftypefnx {} {[@var{y}, @var{fs}, @var{nbits}] =} wavread (@var{filename}) -## @deftypefnx {} {[@dots{}] =} wavread (@var{filename}, @var{n}) -## @deftypefnx {} {[@dots{}] =} wavread (@var{filename}, [@var{n1} @var{n2}]) -## @deftypefnx {} {[@dots{}] =} wavread (@dots{}, @var{datatype}) -## @deftypefnx {} {@var{sz} =} wavread (@var{filename}, "size") -## @deftypefnx {} {[@var{n_samp}, @var{n_chan}] =} wavread (@var{filename}, "size") -## -## @code{wavread} is deprecated and will be removed in Octave version 4.6. -## Use @code{audioread} for the equivalent functionality. -## -## Read the audio signal @var{y} from the RIFF/WAVE sound file @var{filename}. -## -## If the file contains multichannel data, then @var{y} is a matrix with the -## channels represented as columns. -## -## If @var{n} is specified, only the first @var{n} samples of the file are -## returned. If [@var{n1} @var{n2}] is specified, only the range of samples -## from @var{n1} to @var{n2} is returned. A value of @code{Inf} can be used -## to represent the total number of samples in the file. -## -## If the option @qcode{"size"} is given, then the size of the audio signal -## is returned instead of the data. The size is returned in a row vector of -## the form [@var{samples} @var{channels}]. If there are two output arguments, -## the number of samples is assigned to the first and the number of channels -## is assigned to the second. -## -## The optional return value @var{fs} is the sample rate of the audio file in -## Hz. The optional return value @var{nbits} is the number of bits per sample -## as encoded in the file. -## -## @seealso{audioread, audiowrite, wavwrite} -## @end deftypefn - -## Deprecated in 4.2 - -function [y, fs, nbits] = wavread (filename, varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "wavread is obsolete and will be removed from a future version of Octave, please use audioread instead"); - endif - - if (nargin < 1 || nargin > 3) - print_usage (); - endif - - if (! ischar (filename)) - error ("wavread: FILENAME must be a character string"); - endif - - datatype = "double"; - samples = [1, Inf]; - do_file_size = false; - - if (nargin == 3) - samples = varargin{1}; - datatype = varargin{2}; - elseif (nargin == 2) - if (strcmp (varargin{1}, "size")) - do_file_size = true; - elseif (ischar (varargin{1})) - datatype = varargin{1}; - else - samples = varargin{1}; - endif - endif - - if (isscalar (samples)) - samples = [1, samples]; - endif - - if (! (isrow (samples) && numel (samples) == 2 && all (samples > 0) - && all (fix (samples) == samples))) - error ("wavread: SAMPLES must be a 1- or 2-element integer row vector"); - endif - - if (! (ischar (datatype) && any (strcmp (datatype, {"double", "native"})))) - error ('wavread: DATATYPE must be either "double" or "native"'); - endif - - info = audioinfo (filename); - - if (do_file_size) - if (nargout > 1) - [y, fs] = deal (info.TotalSamples, info.NumChannels); - else - y = [info.TotalSamples, info.NumChannels]; - endif - else - [y, fs] = audioread (filename, samples, datatype); - nbits = info.BitsPerSample; - endif - -endfunction - - -## Functional tests for wavread/wavwrite pair are in wavwrite.m. - -## Test input validation -%!error wavread () -%!error wavread (1) -%!error wavread ("foo.wav", 2, 3, 4) -%!error wavread ("foo.wav", "foo") -%!error wavread ("foo.wav", -1) -%!error wavread ("foo.wav", [1, Inf], "foo")
--- a/scripts/deprecated/wavwrite.m Sat Apr 07 10:37:13 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -## Copyright (C) 2016-2018 Mike Miller -## Copyright (C) 2005-2018 Michael Zeising -## -## 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 -## <https://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {} wavwrite (@var{y}, @var{filename}) -## @deftypefnx {} {} wavwrite (@var{y}, @var{fs}, @var{filename}) -## @deftypefnx {} {} wavwrite (@var{y}, @var{fs}, @var{nbits}, @var{filename}) -## -## @code{wavwrite} is deprecated and will be removed in Octave version 4.6. -## Use @code{audiowrite} for the equivalent functionality. -## -## Write the audio signal @var{y} to the RIFF/WAVE sound file @var{filename}. -## -## If @var{y} is a matrix, the columns represent multiple audio channels. -## -## The optional argument @var{fs} specifies the sample rate of the audio signal -## in Hz. -## -## The optional argument @var{nbits} specifies the number of bits per sample -## to write to @var{filename}. -## -## The default sample rate is 8000 Hz and the default bit depth is 16 bits -## per sample. -## -## @seealso{audiowrite, audioread, wavread} -## @end deftypefn - -## Deprecated in 4.2 - -function wavwrite (y, varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "wavwrite is obsolete and will be removed from a future version of Octave, please use audiowrite instead"); - endif - - if (nargin < 2 || nargin > 4) - print_usage (); - endif - - ## Defaults. - fs = 8000; - nbits = 16; - - filename = varargin{end}; - if (nargin > 2) - fs = varargin{1}; - if (nargin > 3) - nbits = varargin{2}; - endif - endif - - ## calculate filesize - [n, channels] = size (y); - - ## allow y to be a row vector - if (n == 1) - y = y(:); - n = channels; - channels = 1; - endif - - ## test arguments - if (channels < 1) - error ("wavwrite: Y must have at least one column"); - endif - - if (channels > 0x7FFF) - error ("wavwrite: Y must have no more than 32767 columns"); - endif - - if (! (isscalar (fs) && (fs > 0))) - error ("wavwrite: sample rate FS must be a positive number"); - endif - - if (! isscalar (nbits) || isempty (find (nbits == [8, 16, 24, 32]))) - error ("wavwrite: bit depth NBITS must be 8, 16, 24, or 32"); - endif - - audiowrite (filename, y, fs, "BitsPerSample", nbits); - -endfunction - - -%!shared fname -%! fname = [tempname() ".wav"]; - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1; -1:0.1:1]'; -%! unwind_protect -%! wavwrite (A, fname); -%! [B, samples_per_sec, bits_per_sample] = wavread (fname); -%! assert (B, A, 2^-14); -%! assert (samples_per_sec, 8000); -%! assert (bits_per_sample, 16); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1; -1:0.1:1]'; -%! unwind_protect -%! wavwrite (A, 4000, fname); -%! [B, samples_per_sec, bits_per_sample] = wavread (fname); -%! assert (B, A, 2^-14); -%! assert (samples_per_sec, 4000); -%! assert (bits_per_sample, 16); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1; -1:0.1:1]'; -%! unwind_protect -%! wavwrite (A, 4000, 8, fname); -%! [B, samples_per_sec, bits_per_sample] = wavread (fname); -%! assert (B, A, 2^-6); -%! assert (samples_per_sec, 4000); -%! assert (bits_per_sample, 8); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-2:2]'; -%! unwind_protect -%! wavwrite (A, fname); -%! B = wavread (fname); -%! B *= 32768; -%! assert (B, [-32767 -32767 0 32767 32767]'); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1]; -%! unwind_protect -%! wavwrite (A, fname); -%! [B, samples_per_sec, bits_per_sample] = wavread (fname); -%! assert (B, A', 2^-14); -%! assert (samples_per_sec, 8000); -%! assert (bits_per_sample, 16); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1; -1:0.1:1]'; -%! unwind_protect -%! wavwrite (A, fname); -%! B = wavread (fname, 15); -%! assert (B, A(1:15,:), 2^-14); -%! wavwrite (A, fname); -%! B = wavread (fname, [10, 20]); -%! assert (B, A(10:20,:), 2^-14); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -%!testif HAVE_SNDFILE -%! A = [-1:0.1:1; -1:0.1:1]'; -%! unwind_protect -%! wavwrite (A, fname); -%! [nsamp, nchan] = wavread (fname, "size"); -%! assert (nsamp, 21); -%! assert (nchan, 2); -%! unwind_protect_cleanup -%! unlink (fname); -%! end_unwind_protect - -## Test input validation -%!error wavwrite () -%!error wavwrite (1) -%!error wavwrite (1,2,3,4,5) -%!error wavwrite ([], "foo.wav")
--- a/scripts/linear-algebra/condest.m Sat Apr 07 10:37:13 2018 -0400 +++ b/scripts/linear-algebra/condest.m Sat Apr 07 10:35:20 2018 -0400 @@ -146,18 +146,6 @@ print_usage (); endif - if ((nargin == 3 && is_function_handle (varargin{3})) - || (nargin == 4 && is_function_handle (varargin{3}) - && isnumeric (varargin{4}))) - ## onenormest syntax, deprecated in 4.2 - [cest, v] = condest_legacy (varargin{:}); - return; - elseif ((nargin >= 5) && is_function_handle (varargin{4})) - ## onenormest syntax, deprecated in 4.2 - [cest, v] = condest_legacy (varargin{:}); - return; - endif - have_A = false; have_t = false; have_apply_normest1 = false; @@ -254,97 +242,6 @@ endswitch endfunction -## FIXME: remove after 4.4 -function [cest, v] = condest_legacy (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "condest: this syntax is deprecated, call condest (A, SOLVEFUN, T, P1, P2, ...) instead."); - endif - - default_t = 5; - - have_A = false; - have_t = false; - have_solve = false; - if (isnumeric (varargin{1})) - A = varargin{1}; - if (! issquare (A)) - error ("condest: matrix must be square"); - endif - n = rows (A); - have_A = true; - - if (nargin > 1) - if (! is_function_handle (varargin{2})) - t = varargin{2}; - have_t = true; - elseif (nargin > 2) - solve = varargin{2}; - solve_t = varargin{3}; - have_solve = true; - if (nargin > 3) - t = varargin{4}; - have_t = true; - endif - else - error ("condest: must supply both SOLVE and SOLVE_T"); - endif - endif - elseif (nargin > 4) - apply = varargin{1}; - apply_t = varargin{2}; - solve = varargin{3}; - solve_t = varargin{4}; - have_solve = true; - n = varargin{5}; - if (! isscalar (n)) - error ("condest: dimension argument of implicit form must be scalar"); - endif - if (nargin > 5) - t = varargin{6}; - have_t = true; - endif - else - error ("condest: implicit form of condest requires at least 5 arguments"); - endif - - if (! have_t) - t = min (n, default_t); - endif - - if (! have_solve) - if (issparse (A)) - [L, U, P, Pc] = lu (A); - solve = @(x) Pc' * (U \ (L \ (P * x))); - solve_t = @(x) P' * (L' \ (U' \ (Pc * x))); - else - [L, U, P] = lu (A); - solve = @(x) U \ (L \ (P*x)); - solve_t = @(x) P' * (L' \ (U' \ x)); - endif - endif - - ## We already warned about this usage being deprecated. - ## Don't warn again about onenormest. - warning ("off", "Octave:deprecated-function", "local"); - - if (have_A) - Anorm = norm (A, 1); - else - Anorm = onenormest (apply, apply_t, n, t); - endif - - [Ainv_norm, v, w] = onenormest (solve, solve_t, n, t); - - cest = Anorm * Ainv_norm; - v = w / norm (w, 1); - -endfunction - - ## Note: These test bounds are very loose. There is enough randomization to ## trigger odd cases with hilb(). @@ -386,35 +283,6 @@ %! cA_test = norm (inv (A), 1) * norm (A, 1); %! assert (cA, cA_test, -2^-8); -%!test # to be removed after 4.4 -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 6; -%! A = hilb (N); -%! solve = @(x) A\x; solve_t = @(x) A'\x; -%! cA = condest (A, solve, solve_t); -%! cA_test = norm (inv (A), 1) * norm (A, 1); -%! assert (cA, cA_test, -2^-8); - -%!test # to be removed after 4.4 -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 6; -%! A = hilb (N); -%! apply = @(x) A*x; apply_t = @(x) A'*x; -%! solve = @(x) A\x; solve_t = @(x) A'\x; -%! cA = condest (apply, apply_t, solve, solve_t, N); -%! cA_test = norm (inv (A), 1) * norm (A, 1); -%! assert (cA, cA_test, -2^-6); - -%!test # to be removed after 4.4 -%! warning ("off", "Octave:deprecated-function", "local"); -%! N = 6; -%! A = hilb (N); -%! apply = @(x) A*x; apply_t = @(x) A'*x; -%! solve = @(x) A\x; solve_t = @(x) A'\x; -%! cA = condest (apply, apply_t, solve, solve_t, N, 2); -%! cA_test = norm (inv (A), 1) * norm (A, 1); -%! assert (cA, cA_test, -2^-6); - %!test %! warning ("off", "Octave:nearly-singular-matrix", "local"); %! N = 12;