# HG changeset patch # User Rik # Date 1324489486 28800 # Node ID 4e8f23ccadcecf3a26188b26272a2466e8411e5f # Parent 5aba9fa234cf5e4a311013cc51fe1e3482f408b2 test: Use internal prefix "__" for %!functions to avoid polluting workspace symbol table until bug #34497 has been resolved. * cellfun.cc, dassl.cc, lsode.cc, qr.cc, quad.cc, data.cc, ov-fcn-handle.cc, pt-fcn-handle.cc: Use internal prefix "__" for %!functions to avoid polluting workspace symbol table until bug #34497 has been resolved. diff -r 5aba9fa234cf -r 4e8f23ccadce src/DLD-FUNCTIONS/cellfun.cc --- a/src/DLD-FUNCTIONS/cellfun.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/DLD-FUNCTIONS/cellfun.cc Wed Dec 21 09:44:46 2011 -0800 @@ -696,34 +696,34 @@ /* -%!function r = f11 (x) +%!function r = __f11 (x) %! global __cellfun_test_num_outputs__ %! __cellfun_test_num_outputs__ = nargout; %! r = x; -%! endfunction +%!endfunction -%!function f01 (x) +%!function __f01 (x) %! global __cellfun_test_num_outputs__ %! __cellfun_test_num_outputs__ = nargout; -%! endfunction +%!endfunction %!test %! global __cellfun_test_num_outputs__ -%! cellfun (@f11, {1}); +%! cellfun (@__f11, {1}); %! assert (__cellfun_test_num_outputs__, 0) -%! x = cellfun (@f11, {1}); +%! x = cellfun (@__f11, {1}); %! assert (__cellfun_test_num_outputs__, 1) %!test %! global __cellfun_test_num_outputs__ -%! cellfun (@f01, {1}); +%! cellfun (@__f01, {1}); %! assert (__cellfun_test_num_outputs__, 0) -%!error x = cellfun (@f01, {1, 2}); +%!error x = cellfun (@__f01, {1, 2}); %!test -%! assert (cellfun (@f11, {1, 2}), [1, 2]) -%! assert (cellfun (@f11, {1, 2}, 'uniformoutput', false), {1, 2}) +%! assert (cellfun (@__f11, {1, 2}), [1, 2]) +%! assert (cellfun (@__f11, {1, 2}, 'uniformoutput', false), {1, 2}) %!test %! [a,b] = cellfun (@(x) x, cell (2, 0)); @@ -736,9 +736,9 @@ %! assert (b, cell (2, 0)); %% Test function to check the "Errorhandler" option -%!function [z] = cellfunerror (S, varargin) -%! z = S; -%! endfunction +%!function [z] = __cellfunerror (S, varargin) +%! z = S; +%!endfunction %% First input argument can be a string, an inline function, %% a function_handle or an anonymous function @@ -815,7 +815,7 @@ %! assert (isequal (C, {true, []; [], true})); %!test %! A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \ -%! "ErrorHandler", @cellfunerror); +%! "ErrorHandler", @__cellfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -823,7 +823,7 @@ %! assert (A.index, 1); %!test %% Overwriting setting of "UniformOutput" true %! A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \ -%! "UniformOutput", true, "ErrorHandler", @cellfunerror); +%! "UniformOutput", true, "ErrorHandler", @__cellfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -849,7 +849,7 @@ %! assert (isequal (C, {10, 11; [], 12})); %!test %! A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \ -%! "ErrorHandler", @cellfunerror); +%! "ErrorHandler", @__cellfunerror); %! B = isfield (A(1), "message") && isfield (A(1), "index"); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); @@ -858,7 +858,7 @@ %! assert ([A(1).index, A(2).index], [1, 2]); %!test %% Overwriting setting of "UniformOutput" true %! A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \ -%! "UniformOutput", true, "ErrorHandler", @cellfunerror); +%! "UniformOutput", true, "ErrorHandler", @__cellfunerror); %! B = isfield (A(1), "message") && isfield (A(1), "index"); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); @@ -877,7 +877,7 @@ %! assert (A, {"abc", "def"}); %!test %! A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \ -%! "ErrorHandler", @cellfunerror); +%! "ErrorHandler", @__cellfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); @@ -885,7 +885,7 @@ %! assert ([A(1).index, A(2).index], [1, 2]); %!test %% Overwriting setting of "UniformOutput" true %! A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \ -%! "UniformOutput", true, "ErrorHandler", @cellfunerror); +%! "UniformOutput", true, "ErrorHandler", @__cellfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); @@ -911,7 +911,7 @@ %! assert (A, {true, false}); %!test %! A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \ -%! "ErrorHandler", @cellfunerror); +%! "ErrorHandler", @__cellfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); @@ -919,7 +919,7 @@ %! assert ([A(1).index, A(2).index], [1, 2]); %!test %% Overwriting setting of "UniformOutput" true %! A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \ -%! "UniformOutput", true, "ErrorHandler", @cellfunerror); +%! "UniformOutput", true, "ErrorHandler", @__cellfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); @@ -944,7 +944,7 @@ %!test %! a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3); %! A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \ -%! "ErrorHandler", @cellfunerror); +%! "ErrorHandler", @__cellfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -953,7 +953,7 @@ %!test %% Overwriting setting of "UniformOutput" true %! a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3); %! A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \ -%! "UniformOutput", true, "ErrorHandler", @cellfunerror); +%! "UniformOutput", true, "ErrorHandler", @__cellfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -1420,43 +1420,43 @@ } /* -%!function r = f11 (x) +%!function r = __f11 (x) %! global __arrayfun_test_num_outputs__ %! __arrayfun_test_num_outputs__ = nargout; %! r = x; -%! endfunction +%!endfunction -%!function f01 (x) +%!function __f01 (x) %! global __arrayfun_test_num_outputs__ %! __arrayfun_test_num_outputs__ = nargout; -%! endfunction +%!endfunction %!test %! global __arrayfun_test_num_outputs__ -%! arrayfun (@f11, {1}); +%! arrayfun (@__f11, {1}); %! assert (__arrayfun_test_num_outputs__, 0) -%! x = arrayfun (@f11, {1}); +%! x = arrayfun (@__f11, {1}); %! assert (__arrayfun_test_num_outputs__, 1) %!test %! global __arrayfun_test_num_outputs__ -%! arrayfun (@f01, {1}); +%! arrayfun (@__f01, {1}); %! assert (__arrayfun_test_num_outputs__, 0) -%!error x = arrayfun (@f01, [1, 2]); +%!error x = arrayfun (@__f01, [1, 2]); %!test -%! assert (arrayfun (@f11, [1, 2]), [1, 2]) -%! assert (arrayfun (@f11, [1, 2], 'uniformoutput', false), {1, 2}); -%! assert (arrayfun (@f11, {1, 2}), {1, 2}) -%! assert (arrayfun (@f11, {1, 2}, 'uniformoutput', false), {{1}, {2}}); +%! assert (arrayfun (@__f11, [1, 2]), [1, 2]) +%! assert (arrayfun (@__f11, [1, 2], 'uniformoutput', false), {1, 2}); +%! assert (arrayfun (@__f11, {1, 2}), {1, 2}) +%! assert (arrayfun (@__f11, {1, 2}, 'uniformoutput', false), {{1}, {2}}); %!assert (arrayfun (@ones, 1, [2,3], 'uniformoutput', false), {[1,1], [1,1,1]}); %% Test function to check the "Errorhandler" option -%!function [z] = arrayfunerror (S, varargin) +%!function [z] = __arrayfunerror (S, varargin) %! z = S; -%! endfunction +%!endfunction %% First input argument can be a string, an inline function, a %% function_handle or an anonymous function %!test @@ -1511,7 +1511,7 @@ %! assert (isequal (B, {true, []; [], true})); %! assert (isequal (C, {true, []; [], true})); %!test -%! A = arrayfun (@(x,y) array2str (x,y), true, true, "ErrorHandler", @arrayfunerror); +%! A = arrayfun (@(x,y) array2str (x,y), true, true, "ErrorHandler", @__arrayfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -1519,7 +1519,7 @@ %! assert (A.index, 1); %!test %% Overwriting setting of "UniformOutput" true %! A = arrayfun (@(x,y) array2str (x,y), true, true, \ -%! "UniformOutput", true, "ErrorHandler", @arrayfunerror); +%! "UniformOutput", true, "ErrorHandler", @__arrayfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -1543,7 +1543,7 @@ %! assert (isequal (B, {true, true; [], true})); %! assert (isequal (C, {10, 11; [], 12})); %!test -%! A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, "ErrorHandler", @arrayfunerror); +%! A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, "ErrorHandler", @__arrayfunerror); %! B = isfield (A(1), "message") && isfield (A(1), "index"); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); @@ -1552,7 +1552,7 @@ %! assert ([A(1).index, A(2).index], [1, 2]); %!test %% Overwriting setting of "UniformOutput" true %! A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, \ -%! "UniformOutput", true, "ErrorHandler", @arrayfunerror); +%! "UniformOutput", true, "ErrorHandler", @__arrayfunerror); %! B = isfield (A(1), "message") && isfield (A(1), "index"); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); @@ -1571,7 +1571,7 @@ %! A = arrayfun (@(x,y) x:y, ["a", "d"], ["c", "f"], "UniformOutput", false); %! assert (A, {"abc", "def"}); %! %#!test -%! A = arrayfun (@(x,y) cell2str(x,y), ["a", "d"], ["c", "f"], "ErrorHandler", @arrayfunerror); +%! A = arrayfun (@(x,y) cell2str(x,y), ["a", "d"], ["c", "f"], "ErrorHandler", @__arrayfunerror); %! B = isfield (A(1), "identifier") && isfield (A(1), "message") && isfield (A(1), "index"); %! assert (B, true); @@ -1589,7 +1589,7 @@ %! A = arrayfun (@(x,y) x.a:y.a, a, b, "UniformOutput", false); %! assert (isequal (A, {[1.1, 2.1, 3.1]})); %!test -%! A = arrayfun (@(x) mat2str(x), "a", "ErrorHandler", @arrayfunerror); +%! A = arrayfun (@(x) mat2str(x), "a", "ErrorHandler", @__arrayfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -1597,7 +1597,7 @@ %! assert (A.index, 1); %!test %% Overwriting setting of "UniformOutput" true %! A = arrayfun (@(x) mat2str(x), "a", "UniformOutput", true, \ -%! "ErrorHandler", @arrayfunerror); +%! "ErrorHandler", @__arrayfunerror); %! assert (isfield (A, "identifier"), true); %! assert (isfield (A, "message"), true); %! assert (isfield (A, "index"), true); @@ -1615,7 +1615,7 @@ %! A = arrayfun (@(x,y) x{1} < y{1}, {1.1, 4.2}, {3.1, 2}, "UniformOutput", false); %! assert (A, {true, false}); %!test -%! A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, "ErrorHandler", @arrayfunerror); +%! A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, "ErrorHandler", @__arrayfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); @@ -1623,7 +1623,7 @@ %! assert ([A(1).index, A(2).index], [1, 2]); %!test %! A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, \ -%! "UniformOutput", true, "ErrorHandler", @arrayfunerror); +%! "UniformOutput", true, "ErrorHandler", @__arrayfunerror); %! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]); %! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]); %! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]); diff -r 5aba9fa234cf -r 4e8f23ccadce src/DLD-FUNCTIONS/dassl.cc --- a/src/DLD-FUNCTIONS/dassl.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/DLD-FUNCTIONS/dassl.cc Wed Dec 21 09:44:46 2011 -0800 @@ -500,8 +500,11 @@ %% %% y1(t) = cos(t) %% y2(t) = sin(t) -%!function res = f (x, xdot, t) + +%!function res = __f (x, xdot, t) %! res = [xdot(1)+x(2); xdot(2)-x(1)]; +%!endfunction + %!test %! %! x0 = [1; 0]; @@ -511,7 +514,7 @@ %! tol = 100 * dassl_options ("relative tolerance"); %! %! -%! [x, xdot] = dassl ("f", x0, xdot0, t); +%! [x, xdot] = dassl ("__f", x0, xdot0, t); %! %! y = [cos(t), sin(t)]; %! @@ -537,8 +540,11 @@ %% %% x1(t) = exp(-10*t) %% x2(t) = 1 - x(1) -%!function res = f (x, xdot, t) + +%!function res = __f (x, xdot, t) %! res = [xdot(1)+10*x(1); x(1)+x(2)-1]; +%!endfunction + %!test %! %! x0 = [1; 0]; @@ -548,7 +554,7 @@ %! tol = 500 * dassl_options ("relative tolerance"); %! %! -%! [x, xdot] = dassl ("f", x0, xdot0, t); +%! [x, xdot] = dassl ("__f", x0, xdot0, t); %! %! y = [exp(-10*t), 1-exp(-10*t)]; %! diff -r 5aba9fa234cf -r 4e8f23ccadce src/DLD-FUNCTIONS/lsode.cc --- a/src/DLD-FUNCTIONS/lsode.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/DLD-FUNCTIONS/lsode.cc Wed Dec 21 09:44:46 2011 -0800 @@ -492,7 +492,7 @@ %% %% y1(t) = cos(t) %% y2(t) = sin(t) -%!function xdot = f (x, t) +%!function xdot = __f (x, t) %! xdot = [-x(2); x(1)]; %!test %! @@ -503,13 +503,13 @@ %! tol = 500 * lsode_options ("relative tolerance"); %! %! -%! x = lsode ("f", x0, t); +%! x = lsode ("__f", x0, t); %! %! y = [cos(t), sin(t)]; %! %! assert(all (all (abs (x - y) < tol))); -%!function xdotdot = f (x, t) +%!function xdotdot = __f (x, t) %! xdotdot = [x(2); -x(1)]; %!test %! @@ -517,13 +517,13 @@ %! t = [0; 2*pi]; %! tol = 100 * dassl_options ("relative tolerance"); %! -%! x = lsode ("f", x0, t); +%! x = lsode ("__f", x0, t); %! %! y = [1, 0; 1, 0]; %! %! assert(all (all (abs (x - y) < tol))); -%!function xdot = f (x, t) +%!function xdot = __f (x, t) %! xdot = x; %!test %! @@ -531,7 +531,7 @@ %! t = [0; 1]; %! tol = 100 * dassl_options ("relative tolerance"); %! -%! x = lsode ("f", x0, t); +%! x = lsode ("__f", x0, t); %! %! y = [1; e]; %! diff -r 5aba9fa234cf -r 4e8f23ccadce src/DLD-FUNCTIONS/qr.cc --- a/src/DLD-FUNCTIONS/qr.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/DLD-FUNCTIONS/qr.cc Wed Dec 21 09:44:46 2011 -0800 @@ -500,7 +500,7 @@ %!error qr (); %!error qr ([1, 2; 3, 4], 0, 2); -%!function retval = testqr (q, r, a, p) +%!function retval = __testqr (q, r, a, p) %! tol = 100*eps (class(q)); %! retval = 0; %! if (nargin == 3) @@ -518,6 +518,8 @@ %! retval = (retval && n2 < tol); %! endif %! endif +%!endfunction + %!test %! %! t = ones (24, 1); @@ -525,41 +527,41 @@ %! %! if false # eliminate big matrix tests %! a = rand(5000,20); -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps; -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! endif %! %! a = [ ones(1,15); sqrt(eps)*eye(15) ]; -%! [q,r]=qr(a); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a'); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a'); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps; -%! [q,r]=qr(a); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a'); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a'); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p); %! %! a = [ ones(1,15); sqrt(eps)*eye(15) ]; -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps; -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = [ %! 611 196 -192 407 -8 -52 -49 29 @@ -625,41 +627,41 @@ %! %! if false # eliminate big matrix tests %! a = rand(5000,20); -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps('single'); -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! endif %! %! a = [ ones(1,15); sqrt(eps('single'))*eye(15) ]; -%! [q,r]=qr(a); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a'); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a'); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps('single'); -%! [q,r]=qr(a); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a'); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a'); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p); %! %! a = [ ones(1,15); sqrt(eps('single'))*eye(15) ]; -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = a+1i*eps('single'); -%! [q,r]=qr(a,0); t(j++) = testqr(q,r,a); -%! [q,r]=qr(a',0); t(j++) = testqr(q,r,a'); -%! [q,r,p]=qr(a,0); t(j++) = testqr(q,r,a,p); -%! [q,r,p]=qr(a',0); t(j++) = testqr(q,r,a',p); +%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a); +%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a'); +%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p); +%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p); %! %! a = [ %! 611 196 -192 407 -8 -52 -49 29 diff -r 5aba9fa234cf -r 4e8f23ccadce src/DLD-FUNCTIONS/quad.cc --- a/src/DLD-FUNCTIONS/quad.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/DLD-FUNCTIONS/quad.cc Wed Dec 21 09:44:46 2011 -0800 @@ -474,29 +474,33 @@ /* -%!function y = f (x) +%!function y = __f (x) %! y = x + 1; +%!endfunction + %!test -%! [v, ier, nfun, err] = quad ("f", 0, 5); +%! [v, ier, nfun, err] = quad ("__f", 0, 5); %! assert(ier == 0 && abs (v - 17.5) < sqrt (eps) && nfun > 0 && %! err < sqrt (eps)) %!test -%! [v, ier, nfun, err] = quad ("f", single(0), single(5)); +%! [v, ier, nfun, err] = quad ("__f", single(0), single(5)); %! assert(ier == 0 && abs (v - 17.5) < sqrt (eps ("single")) && nfun > 0 && %! err < sqrt (eps ("single"))) -%!function y = f (x) +%!function y = __f (x) %! y = x .* sin (1 ./ x) .* sqrt (abs (1 - x)); +%!endfunction + %!test -%! [v, ier, nfun, err] = quad ("f", 0.001, 3); +%! [v, ier, nfun, err] = quad ("__f", 0.001, 3); %! assert((ier == 0 || ier == 1) && abs (v - 1.98194120273598) < sqrt (eps) && nfun > 0); %!test -%! [v, ier, nfun, err] = quad ("f", single(0.001), single(3)); +%! [v, ier, nfun, err] = quad ("__f", single(0.001), single(3)); %! assert((ier == 0 || ier == 1) && abs (v - 1.98194120273598) < sqrt (eps ("single")) && nfun > 0); %!error quad (); -%!error quad ("f", 1, 2, 3, 4, 5); +%!error quad ("__f", 1, 2, 3, 4, 5); %!test %! quad_options ("absolute tolerance", eps); diff -r 5aba9fa234cf -r 4e8f23ccadce src/data.cc --- a/src/data.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/data.cc Wed Dec 21 09:44:46 2011 -0800 @@ -2160,7 +2160,7 @@ /* -%!function ret = testcat (t1, t2, tr, cmplx) +%!function ret = __testcat (t1, t2, tr, cmplx) %! assert (cat (1, cast ([], t1), cast([], t2)), cast ([], tr)); %! %! assert (cat (1, cast (1, t1), cast (2, t2)), cast ([1; 2], tr)); @@ -2237,67 +2237,68 @@ %! assert ([cast([1i, 2], t1), cast([3i, 4], t2)], cast ([1i, 2, 3i, 4], tr)); %! endif %! ret = true; - -%!assert (testcat('double', 'double', 'double')); -%!assert (testcat('single', 'double', 'single')); -%!assert (testcat('double', 'single', 'single')); -%!assert (testcat('single', 'single', 'single')); - -%!assert (testcat('double', 'int8', 'int8', false)); -%!assert (testcat('int8', 'double', 'int8', false)); -%!assert (testcat('single', 'int8', 'int8', false)); -%!assert (testcat('int8', 'single', 'int8', false)); -%!assert (testcat('int8', 'int8', 'int8', false)); -%!assert (testcat('double', 'int16', 'int16', false)); -%!assert (testcat('int16', 'double', 'int16', false)); -%!assert (testcat('single', 'int16', 'int16', false)); -%!assert (testcat('int16', 'single', 'int16', false)); -%!assert (testcat('int16', 'int16', 'int16', false)); -%!assert (testcat('double', 'int32', 'int32', false)); -%!assert (testcat('int32', 'double', 'int32', false)); -%!assert (testcat('single', 'int32', 'int32', false)); -%!assert (testcat('int32', 'single', 'int32', false)); -%!assert (testcat('int32', 'int32', 'int32', false)); -%!assert (testcat('double', 'int64', 'int64', false)); -%!assert (testcat('int64', 'double', 'int64', false)); -%!assert (testcat('single', 'int64', 'int64', false)); -%!assert (testcat('int64', 'single', 'int64', false)); -%!assert (testcat('int64', 'int64', 'int64', false)); - -%!assert (testcat('double', 'uint8', 'uint8', false)); -%!assert (testcat('uint8', 'double', 'uint8', false)); -%!assert (testcat('single', 'uint8', 'uint8', false)); -%!assert (testcat('uint8', 'single', 'uint8', false)); -%!assert (testcat('uint8', 'uint8', 'uint8', false)); -%!assert (testcat('double', 'uint16', 'uint16', false)); -%!assert (testcat('uint16', 'double', 'uint16', false)); -%!assert (testcat('single', 'uint16', 'uint16', false)); -%!assert (testcat('uint16', 'single', 'uint16', false)); -%!assert (testcat('uint16', 'uint16', 'uint16', false)); -%!assert (testcat('double', 'uint32', 'uint32', false)); -%!assert (testcat('uint32', 'double', 'uint32', false)); -%!assert (testcat('single', 'uint32', 'uint32', false)); -%!assert (testcat('uint32', 'single', 'uint32', false)); -%!assert (testcat('uint32', 'uint32', 'uint32', false)); -%!assert (testcat('double', 'uint64', 'uint64', false)); -%!assert (testcat('uint64', 'double', 'uint64', false)); -%!assert (testcat('single', 'uint64', 'uint64', false)); -%!assert (testcat('uint64', 'single', 'uint64', false)); -%!assert (testcat('uint64', 'uint64', 'uint64', false)); - -%!assert (cat (3, [], [1,2;3,4]), [1,2;3,4]); -%!assert (cat (3, [1,2;3,4], []), [1,2;3,4]); -%!assert (cat (3, [], [1,2;3,4], []), [1,2;3,4]); -%!assert (cat (3, [], [], []), zeros (0, 0, 3)); - -%!assert (cat (3, [], [], 1, 2), cat (3, 1, 2)); -%!assert (cat (3, [], [], [1,2;3,4]), [1,2;3,4]); -%!assert (cat (4, [], [], [1,2;3,4]), [1,2;3,4]); -%!error cat (3, cat (3, [], []), [1,2;3,4]); -%!error cat (3, zeros (0, 0, 2), [1,2;3,4]); - -%!assert ([zeros(3,2,2); ones(1,2,2)], repmat([0;0;0;1],[1,2,2]) ); -%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat(zeros(3,2,2), ones(1,2,2)) ); +%!endfunction + +%!assert (__testcat('double', 'double', 'double')) +%!assert (__testcat('single', 'double', 'single')) +%!assert (__testcat('double', 'single', 'single')) +%!assert (__testcat('single', 'single', 'single')) + +%!assert (__testcat('double', 'int8', 'int8', false)) +%!assert (__testcat('int8', 'double', 'int8', false)) +%!assert (__testcat('single', 'int8', 'int8', false)) +%!assert (__testcat('int8', 'single', 'int8', false)) +%!assert (__testcat('int8', 'int8', 'int8', false)) +%!assert (__testcat('double', 'int16', 'int16', false)) +%!assert (__testcat('int16', 'double', 'int16', false)) +%!assert (__testcat('single', 'int16', 'int16', false)) +%!assert (__testcat('int16', 'single', 'int16', false)) +%!assert (__testcat('int16', 'int16', 'int16', false)) +%!assert (__testcat('double', 'int32', 'int32', false)) +%!assert (__testcat('int32', 'double', 'int32', false)) +%!assert (__testcat('single', 'int32', 'int32', false)) +%!assert (__testcat('int32', 'single', 'int32', false)) +%!assert (__testcat('int32', 'int32', 'int32', false)) +%!assert (__testcat('double', 'int64', 'int64', false)) +%!assert (__testcat('int64', 'double', 'int64', false)) +%!assert (__testcat('single', 'int64', 'int64', false)) +%!assert (__testcat('int64', 'single', 'int64', false)) +%!assert (__testcat('int64', 'int64', 'int64', false)) + +%!assert (__testcat('double', 'uint8', 'uint8', false)) +%!assert (__testcat('uint8', 'double', 'uint8', false)) +%!assert (__testcat('single', 'uint8', 'uint8', false)) +%!assert (__testcat('uint8', 'single', 'uint8', false)) +%!assert (__testcat('uint8', 'uint8', 'uint8', false)) +%!assert (__testcat('double', 'uint16', 'uint16', false)) +%!assert (__testcat('uint16', 'double', 'uint16', false)) +%!assert (__testcat('single', 'uint16', 'uint16', false)) +%!assert (__testcat('uint16', 'single', 'uint16', false)) +%!assert (__testcat('uint16', 'uint16', 'uint16', false)) +%!assert (__testcat('double', 'uint32', 'uint32', false)) +%!assert (__testcat('uint32', 'double', 'uint32', false)) +%!assert (__testcat('single', 'uint32', 'uint32', false)) +%!assert (__testcat('uint32', 'single', 'uint32', false)) +%!assert (__testcat('uint32', 'uint32', 'uint32', false)) +%!assert (__testcat('double', 'uint64', 'uint64', false)) +%!assert (__testcat('uint64', 'double', 'uint64', false)) +%!assert (__testcat('single', 'uint64', 'uint64', false)) +%!assert (__testcat('uint64', 'single', 'uint64', false)) +%!assert (__testcat('uint64', 'uint64', 'uint64', false)) + +%!assert (cat (3, [], [1,2;3,4]), [1,2;3,4]) +%!assert (cat (3, [1,2;3,4], []), [1,2;3,4]) +%!assert (cat (3, [], [1,2;3,4], []), [1,2;3,4]) +%!assert (cat (3, [], [], []), zeros (0, 0, 3)) + +%!assert (cat (3, [], [], 1, 2), cat (3, 1, 2)) +%!assert (cat (3, [], [], [1,2;3,4]), [1,2;3,4]) +%!assert (cat (4, [], [], [1,2;3,4]), [1,2;3,4]) +%!error cat (3, cat (3, [], []), [1,2;3,4]) +%!error cat (3, zeros (0, 0, 2), [1,2;3,4]) + +%!assert ([zeros(3,2,2); ones(1,2,2)], repmat([0;0;0;1],[1,2,2]) ) +%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat(zeros(3,2,2), ones(1,2,2)) ) */ diff -r 5aba9fa234cf -r 4e8f23ccadce src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/ov-fcn-handle.cc Wed Dec 21 09:44:46 2011 -0800 @@ -1759,7 +1759,8 @@ } /* -%!function y = testrecursionfunc (f, x, n) + +%!function y = __testrecursionfunc (f, x, n) %! if (nargin < 3) %! n = 0; %! endif @@ -1767,10 +1768,12 @@ %! y = f (x); %! else %! n++; -%! y = testrecursionfunc (@(x) f(2*x), x, n); +%! y = __testrecursionfunc (@(x) f(2*x), x, n); %! endif -%!test -%! assert (testrecursionfunc (@(x) x, 1), 8); +%!endfunction +%! +%!assert (__testrecursionfunc (@(x) x, 1), 8) + */ octave_fcn_binder::octave_fcn_binder (const octave_value& f, @@ -1958,10 +1961,10 @@ } /* -%!function r = f (g, i) +%!function r = __f (g, i) %! r = g(i); %!endfunction %!test %! x = [1,2;3,4]; -%! assert (f (@(i) x(:,i), 1), [1;3]); +%! assert (__f (@(i) x(:,i), 1), [1;3]); */ diff -r 5aba9fa234cf -r 4e8f23ccadce src/pt-fcn-handle.cc --- a/src/pt-fcn-handle.cc Wed Dec 21 09:12:59 2011 -0800 +++ b/src/pt-fcn-handle.cc Wed Dec 21 09:44:46 2011 -0800 @@ -141,22 +141,24 @@ } /* -%!function r = f2 (f, x) +%!function r = __f2 (f, x) %! r = f (x); -%!function f = f1 (k) -%! f = @(x) f2 (@(y) y-k, x); +%!endfunction +%!function f = __f1 (k) +%! f = @(x) __f2 (@(y) y-k, x); +%!endfunction + +%!assert ((__f1 (3)) (10) == 7) + %!test -%! assert ((f1 (3)) (10) == 7) -%! -%!shared g %! g = @(t) feval (@(x) t*x, 2); -%!assert (g(0.5) == 1) -%! -%!shared f, g, h +%! assert (g(0.5) == 1); + +%!test %! h = @(x) sin (x); %! g = @(f, x) h (x); %! f = @() g (@(x) h, pi); -%!assert (f () == sin (pi)) +%! assert (f () == sin (pi)); */ octave_value_list