Mercurial > octave
changeset 25124:435645a627dd stable
Fix random seed for pinv BIST tests (bug #53560).
* pinv.cc (Fpinv): Save and restore existing random seed. Use a fixed
random seed of 42 for pinv BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 04 Apr 2018 14:43:35 -0700 |
parents | fc8803962533 |
children | bae60a19bb61 |
files | libinterp/corefcn/pinv.cc |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/pinv.cc Wed Apr 04 22:03:38 2018 +0200 +++ b/libinterp/corefcn/pinv.cc Wed Apr 04 14:43:35 2018 -0700 @@ -155,6 +155,9 @@ /* %!shared a, b, tol, hitol, d, u, x, y +%! old_state = rand ("state"); +%! restore_state = onCleanup (@() rand ("state", old_state)); +%! rand ("state", 42); # initialize generator to make behavior reproducible %! a = reshape (rand*[1:16], 4, 4); # Rank 2 matrix %! b = pinv (a); %! tol = 4e-14; @@ -163,7 +166,8 @@ %! u = rand (4); # Could be singular by freak accident %! x = inv (u)*d*u; %! y = pinv (x, sqrt (eps)); -%! + +## Verify Penrose conditions for pseudoinverse %!assert (a*b*a, a, tol) %!assert (b*a*b, b, tol) %!assert ((b*a)', b*a, tol)