Mercurial > hg > octave-terminal
changeset 14182:f8d99761244c stable
test: Expand %!testif functionality to multiple conditions
* test.m: Add testing for multiple conditions in %!testif statement.
* svds.m, eigs.cc: Test for ARPACK and other libraries before running
some tests.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 09 Jan 2012 13:32:44 -0800 |
parents | 6b28e8a8c777 |
children | 9e6ec5f55827 |
files | scripts/sparse/svds.m scripts/testfun/test.m src/DLD-FUNCTIONS/eigs.cc |
diffstat | 3 files changed, 33 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/sparse/svds.m +++ b/scripts/sparse/svds.m @@ -264,13 +264,13 @@ %! assert (flag, !1); %! assert (s2, s(end:-1:end-k+1), 1e-10); %! -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! [u2,s2,v2,flag] = svds (A,k,0,opts); %! s2 = diag (s2); %! assert (flag, !1); %! assert (s2, s(k:-1:1), 1e-10); %! -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! idx = floor(n/2); %! % Don't put sigma right on a singular value or there are convergence issues %! sigma = 0.99*s(idx) + 0.01*s(idx+1);
--- a/scripts/testfun/test.m +++ b/scripts/testfun/test.m @@ -456,8 +456,10 @@ ### TESTIF elseif (strcmp (__type, "testif")) - [__e, __feat] = regexp (__code, '^\s*(\S+)', 'end', 'tokens'); - if (isempty (findstr (octave_config_info ("DEFS"), __feat{1}{1}))) + __e = regexp (__code, '.$', 'lineanchors', 'once'); + __feat = regexp (__code(1:__e), '\w+', 'match'); + __have_feat = strfind (octave_config_info ("DEFS"), __feat); + if (any (cellfun ("isempty", __have_feat))) __xskip++; __istest = 0; __code = ""; # Skip the code.
--- a/src/DLD-FUNCTIONS/eigs.cc +++ b/src/DLD-FUNCTIONS/eigs.cc @@ -789,7 +789,7 @@ %!testif HAVE_ARPACK %! d1 = eigs (A, k, 'lm'); %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 'sm'); %! assert (d1, d0(k:-1:1), 1e-11); %!testif HAVE_ARPACK @@ -804,15 +804,15 @@ %!testif HAVE_ARPACK %! d1 = eigs (A, k+1, 'be'); %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 4.1); %! [~,idx0] = sort (abs(d0 - 4.1)); %! [~,idx1] = sort (abs(d1 - 4.1)); %! assert (d1(idx1), d0(idx0(1:k)), 1e-11); -%!testif HAVE_CHOLMOD +%!testif HAVE_ARPACK, HAVE_CHOLMOD %! d1 = eigs(A, speye(n), k, 'lm'); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11); %!testif HAVE_ARPACK %! opts.cholB=true; @@ -824,17 +824,17 @@ %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! d1 = eigs(A, speye(n), k, 4.1, opts); %! assert (abs(d1), eigs(A,k,4.1), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! q = [2:n,1]; %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); %! assert (abs(d1), eigs(A,k,4.1), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11); %!testif HAVE_ARPACK %! fn = @(x) A * x; @@ -846,7 +846,7 @@ %! opts.issym = 1; opts.isreal = 1; %! d1 = eigs (fn, n, k, 'sm', opts); %! assert (d1, d0(k:-1:1), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! fn = @(x) (A - 4.1 * eye(n)) \ x; %! opts.issym = 1; opts.isreal = 1; %! d1 = eigs (fn, n, k, 4.1, opts); @@ -862,7 +862,7 @@ %! for i=1:k %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) %! endfor -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! [v1,d1] = eigs(A, k, 'sm'); %! d1 = diag(d1); %! for i=1:k @@ -909,7 +909,7 @@ %!testif HAVE_ARPACK %! d1 = eigs (A, k, 'lm'); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 'sm'); %! assert (abs(d1), abs(d0(1:k)), 1e-11); %!testif HAVE_ARPACK @@ -932,13 +932,13 @@ %! [~, idx] = sort (imag(abs(d0))); %! d2 = d0(idx); %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 4.1); %! [~,idx0] = sort (abs(d0 - 4.1)); %! [~,idx1] = sort (abs(d1 - 4.1)); %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); -%!testif HAVE_CHOLMOD +%!testif HAVE_ARPACK, HAVE_CHOLMOD %! d1 = eigs(A, speye(n), k, 'lm'); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); %!testif HAVE_ARPACK @@ -951,19 +951,19 @@ %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! d1 = eigs(A, speye(n), k, 4.1, opts); %! assert (abs(d1), eigs(A,k,4.1), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! q = [2:n,1]; %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); %! assert (abs(d1), eigs(A,k,4.1), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11); %!testif HAVE_ARPACK %! fn = @(x) A * x; @@ -975,7 +975,7 @@ %! opts.issym = 0; opts.isreal = 1; %! d1 = eigs (fn, n, k, 'sm', opts); %! assert (abs(d1), d0(1:k), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! fn = @(x) (A - 4.1 * eye(n)) \ x; %! opts.issym = 0; opts.isreal = 1; %! d1 = eigs (fn, n, k, 4.1, opts); @@ -986,7 +986,7 @@ %! for i=1:k %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) %! endfor -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! [v1,d1] = eigs(A, k, 'sm'); %! d1 = diag(d1); %! for i=1:k @@ -1039,7 +1039,7 @@ %!testif HAVE_ARPACK %! d1 = eigs (A, k, 'lm'); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 'sm'); %! assert (abs(d1), abs(d0(1:k)), 1e-11); %!testif HAVE_ARPACK @@ -1062,13 +1062,13 @@ %! [~, idx] = sort (imag(abs(d0))); %! d2 = d0(idx); %! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! d1 = eigs (A, k, 4.1); %! [~,idx0] = sort (abs(d0 - 4.1)); %! [~,idx1] = sort (abs(d1 - 4.1)); %! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11); %! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11); -%!testif HAVE_CHOLMOD +%!testif HAVE_ARPACK, HAVE_CHOLMOD %! d1 = eigs(A, speye(n), k, 'lm'); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); %!testif HAVE_ARPACK @@ -1081,21 +1081,21 @@ %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! d1 = eigs(A, speye(n), k, 4.1, opts); %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! opts.cholB=true; %! q = [2:n,1]; %! opts.permB=q; %! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts); %! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11); %! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11); %!testif HAVE_ARPACK %! fn = @(x) A * x; @@ -1107,7 +1107,7 @@ %! opts.issym = 0; opts.isreal = 0; %! d1 = eigs (fn, n, k, 'sm', opts); %! assert (abs(d1), d0(1:k), 1e-11); -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! fn = @(x) (A - 4.1 * eye(n)) \ x; %! opts.issym = 0; opts.isreal = 0; %! d1 = eigs (fn, n, k, 4.1, opts); @@ -1118,7 +1118,7 @@ %! for i=1:k %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) %! endfor -%!testif HAVE_UMFPACK +%!testif HAVE_ARPACK, HAVE_UMFPACK %! [v1,d1] = eigs(A, k, 'sm'); %! d1 = diag(d1); %! for i=1:k