changeset 17846:42453dcfa95e

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.
author Rik <rik@octave.org>
date Mon, 04 Nov 2013 10:38:32 -0800
parents 0f912af348e0
children 3a0075793fcd
files scripts/sparse/eigs.m
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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;