# HG changeset patch # User John W. Eaton # Date 1401217183 14400 # Node ID 1782f5294fdcd9c6bf6808b9e4dbebc9be82977e # Parent 6e2b1de8348e3e67e97ebda7ed77500c52577347 eigs: selection columns of V, not rows (bug #41795) * eigs.m (select): Choose columns of V, not rows. New test. diff -r 6e2b1de8348e -r 1782f5294fdc scripts/sparse/eigs.m --- a/scripts/sparse/eigs.m Sun May 25 19:20:54 2014 +0200 +++ b/scripts/sparse/eigs.m Tue May 27 14:59:43 2014 -0400 @@ -359,7 +359,7 @@ v = args{1}; v = v(:,idx); - out{1} = v(selection,:); + out{1} = v(:,selection); endif endfunction @@ -1114,8 +1114,25 @@ %! [~, idx] = sort (abs (reseig), "ascend"); %! assert (eigs (A, B, 10, 0), reseig (idx)) +%!test +%! X = [70 47 42 39 50 73 79 23; +%! 19 52 61 80 36 76 63 68; +%! 14 34 66 65 29 4 72 9; +%! 24 8 78 49 58 54 43 33; +%! 62 69 32 31 40 46 22 28; +%! 48 12 45 59 10 17 15 25; +%! 64 67 77 56 13 55 41 74; +%! 37 38 18 21 11 3 71 7; +%! 5 35 16 1 51 27 26 44; +%! 30 57 60 75 2 53 20 6]; +%! Z = X * X'; +%! r = rank (Z); +%! assert (r, 8); +%! [V, D] = eigs (Z, r, "lm"); +%! ZZ = V * D * V'; +%! tmp = abs (Z - ZZ); +%! assert (max (tmp(:)) < 5e-11); + %!assert (eigs (diag (1:5), 5, "sa"), [1;2;3;4;5]); %!assert (eigs (diag (1:5), 5, "la"), [5;4;3;2;1]); %!assert (eigs (diag (1:5), 3, "be"), [1;4;5]); - -