# HG changeset patch # User Rik # Date 1383590312 28800 # Node ID 42453dcfa95e390e8def515f4fd624cc9a760eec # Parent 0f912af348e0e6be78588edbfc9d80caec2088ad eigs.m: Fix regression when numeric sigma is used and eig() is called instead of __eigs__. * scripts/sparse/eigs.m: Return k eigenvalues closest to sigma when sigma is numeric. Replace double quotes with single quotes in error messages to avoid having to escape double quote characters so frequently. diff -r 0f912af348e0 -r 42453dcfa95e scripts/sparse/eigs.m --- a/scripts/sparse/eigs.m Mon Nov 04 08:49:23 2013 +0100 +++ b/scripts/sparse/eigs.m Mon Nov 04 10:38:32 2013 -0800 @@ -282,54 +282,57 @@ if (real_valued && symmetric) [~, idx] = sort (real (d), "descend"); else - error ("sigma = \"la\" requires real symmetric problem"); + error ('sigma = "la" requires real symmetric problem'); endif case "sa" if (real_valued && symmetric) [~, idx] = sort (real (d), "ascend"); else - error ("sigma = \"sa\" requires real symmetric problem"); + error ('sigma = "sa" requires real symmetric problem'); endif case "be" if (real_valued && symmetric) [~, idx] = sort (real (d), "ascend"); else - error ("sigma = \"be\" requires real symmetric problem"); + error ('sigma = "be" requires real symmetric problem'); endif case "lr" if (! (real_valued || symmetric)) [~, idx] = sort (real (d), "descend"); else - error ("sigma = \"lr\" requires complex or unsymmetric problem"); + error ('sigma = "lr" requires complex or unsymmetric problem'); endif case "sr" if (! (real_valued || symmetric)) [~, idx] = sort (real (d), "ascend"); else - error ("sigma = \"sr\" requires complex or unsymmetric problem"); + error ('sigma = "sr" requires complex or unsymmetric problem'); endif case "li" if (! (real_valued || symmetric)) [~, idx] = sort (imag (d), "descend"); else - error ("sigma = \"li\" requires complex or unsymmetric problem"); + error ('sigma = "li" requires complex or unsymmetric problem'); endif case "si" if (! (real_valued || symmetric)) [~, idx] = sort (imag (d), "ascend"); else - error ("sigma = \"si\" requires complex or unsymmetric problem"); + error ('sigma = "si" requires complex or unsymmetric problem'); endif otherwise error ("unrecognized value for sigma: %s", sigma); endswitch + else + ## numeric sigma, find k closest values + [~, idx] = sort (abs (d - sigma)); endif d = d(idx); @@ -338,7 +341,7 @@ k = min (k, n); - if (strcmp (sigma, 'be')) + if (strcmp (sigma, "be")) tmp = k / 2; n1 = floor (tmp); n2 = n - ceil (tmp) + 1;