changeset 12082:92b5580c0145 release-3-2-x

Fix nesting error in options parsing of eigs
author David Bateman <dbateman@free.fr>
date Thu, 03 Sep 2009 11:43:58 +0200
parents c781fb52c1d7
children 2dbd6188b789
files src/ChangeLog src/DLD-FUNCTIONS/eigs.cc
diffstat 2 files changed, 31 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Sep 01 09:35:17 2009 +0200
+++ b/src/ChangeLog	Thu Sep 03 11:43:58 2009 +0200
@@ -1,3 +1,9 @@
+2008-09-01  David Bateman  <dbateman@free.fr>
+
+	* DLD-FUNCTIONS/eig.cc (Feigs): Correct nesting error in option
+	parsing that prevented the use of a function for generalized
+	eigenvalue problems.
+
 2009-09-01  Jaroslav Hajek  <highegg@gmail.com>
 
 	* ov-class.cc (get_current_method_class): Check before slicing.
--- a/src/DLD-FUNCTIONS/eigs.cc	Tue Sep 01 09:35:17 2009 +0200
+++ b/src/DLD-FUNCTIONS/eigs.cc	Thu Sep 03 11:43:58 2009 +0200
@@ -425,25 +425,27 @@
 	    }
 	}
 
-      // Note hold off reading B till later to avoid issues of double 
-      // copies of the matrix if B is full/real while A is complex..
-      if (!error_state && nargin > 1 && !(args(1).is_real_scalar ()))
+    }
+
+  // Note hold off reading B till later to avoid issues of double 
+  // copies of the matrix if B is full/real while A is complex..
+  if (!error_state && nargin > 1 + arg_offset && 
+      !(args(1 + arg_offset).is_real_scalar ()))
+    {
+      if (args(1+arg_offset).is_complex_type ())
 	{
-	  if (args(1).is_complex_type ())
-	    {
-	      b_arg = 1+arg_offset;
-	      have_b = true;
-	      bmat = 'G';
-	      b_is_complex = true;
-	      arg_offset++;
-	    }
-	  else
-	    {
-	      b_arg = 1+arg_offset;
-	      have_b = true;
-	      bmat = 'G';
-	      arg_offset++;
-	    }
+	  b_arg = 1+arg_offset;
+	  have_b = true;
+	  bmat = 'G';
+	  b_is_complex = true;
+	  arg_offset++;
+	}
+      else
+	{
+	  b_arg = 1+arg_offset;
+	  have_b = true;
+	  bmat = 'G';
+	  arg_offset++;
 	}
     }
 
@@ -834,6 +836,11 @@
 %! d1 = eigs (fn, n, k, 4.1, opts);
 %! assert (d1, eigs(A,k,4.1), 1e-11);
 %!testif HAVE_ARPACK
+%! AA = speye (10);
+%! fn = @(x) A * x;
+%! opts.issym = 1; opts.isreal = 1;
+%! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1]);
+%!testif HAVE_ARPACK
 %! [v1,d1] = eigs(A, k, 'lm');
 %! d1 = diag(d1);
 %! for i=1:k