seeds = 1:1000;

function x = func(n)
  x = rand (n);
  x(x < 0.9) = 0;
  x(x != 0) = rand (size (x(x != 0))) - 0.5;
endfunction

function failed = sweepseed (X)
  failed = logical (zeros (size (X)));
  ii = 0;
  for seed = X
    ii++;
    rand ("state", seed)
    w = func (200);
    try
      eigs (w, 1, "lm");
    catch
      printf ("*** Error : %s using seed %d\n", lasterr (), seed)
      failed(ii) = true;
    end_try_catch
  endfor
endfunction

failed = sweepseed (seeds);

all (sweepseed (seeds(failed)))
