Mercurial > hg > octave-terminal
changeset 10777:f2a8f68d9c2b
eigs.cc: Initialize random number generator in test blocks
to get reproducible results.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 08 Jul 2010 09:15:38 -0700 |
parents | 062304bd692e |
children | 6035bf68a755 |
files | src/ChangeLog src/DLD-FUNCTIONS/eigs.cc |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-07-08 Rik <octave@nomad.inbox5.com> + + * DLD_FUNCTIONS/eigs.cc: Initialize random number generator in test + blocks to get reproducible results. + 2010-07-08 Jaroslav Hajek <highegg@gmail.com> * ov-cell.cc (Fstruct2cell): Use octave_map. Optimize. @@ -52,6 +57,7 @@ (Fformat): Document the new engineering format. 2010-07-04 Soren Hauberg <hauberg@gmail.com> + * DLD_FUNCTIONS/__magick_read__.cc: restore locale after GraphicsMagick initialisation.
--- a/src/DLD-FUNCTIONS/eigs.cc +++ b/src/DLD-FUNCTIONS/eigs.cc @@ -753,6 +753,7 @@ %! d2 = sort (d0); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); @@ -828,7 +829,7 @@ %! AA = speye (10); %! fn = @(x) AA * x; %! opts.issym = 1; opts.isreal = 1; -%! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1]); +%! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1],10*eps); %!testif HAVE_ARPACK %! [v1,d1] = eigs(A, k, 'lm'); %! d1 = diag(d1); @@ -872,6 +873,7 @@ %! d0 = eig (A); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); @@ -1001,6 +1003,7 @@ %! d0 = eig (A); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); @@ -1135,6 +1138,7 @@ %! d2 = sort (d0); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (d1, d0(end:-1:(end-k+1)), 1e-11); @@ -1249,6 +1253,7 @@ %! d0 = eig (A); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11); @@ -1378,6 +1383,7 @@ %! d0 = eig (A); %! [~, idx] = sort (abs(d0)); %! d0 = d0(idx); +%! rand("state", 42); % initialize generator to make eigs behavior reproducible %!testif HAVE_ARPACK %! d1 = eigs (A, k); %! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);