comparison src/DLD-FUNCTIONS/eigs.cc @ 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 7c02ec148a3c
children 2dbd6188b789
comparison
equal deleted inserted replaced
12081:c781fb52c1d7 12082:92b5580c0145
423 amm = (args(0).matrix_value()); 423 amm = (args(0).matrix_value());
424 symmetric = amm.is_symmetric(); 424 symmetric = amm.is_symmetric();
425 } 425 }
426 } 426 }
427 427
428 // Note hold off reading B till later to avoid issues of double 428 }
429 // copies of the matrix if B is full/real while A is complex.. 429
430 if (!error_state && nargin > 1 && !(args(1).is_real_scalar ())) 430 // Note hold off reading B till later to avoid issues of double
431 { 431 // copies of the matrix if B is full/real while A is complex..
432 if (args(1).is_complex_type ()) 432 if (!error_state && nargin > 1 + arg_offset &&
433 { 433 !(args(1 + arg_offset).is_real_scalar ()))
434 b_arg = 1+arg_offset; 434 {
435 have_b = true; 435 if (args(1+arg_offset).is_complex_type ())
436 bmat = 'G'; 436 {
437 b_is_complex = true; 437 b_arg = 1+arg_offset;
438 arg_offset++; 438 have_b = true;
439 } 439 bmat = 'G';
440 else 440 b_is_complex = true;
441 { 441 arg_offset++;
442 b_arg = 1+arg_offset; 442 }
443 have_b = true; 443 else
444 bmat = 'G'; 444 {
445 arg_offset++; 445 b_arg = 1+arg_offset;
446 } 446 have_b = true;
447 bmat = 'G';
448 arg_offset++;
447 } 449 }
448 } 450 }
449 451
450 if (!error_state && nargin > (1+arg_offset)) 452 if (!error_state && nargin > (1+arg_offset))
451 k = args(1+arg_offset).nint_value (); 453 k = args(1+arg_offset).nint_value ();
832 %! fn = @(x) (A - 4.1 * eye(n)) \ x; 834 %! fn = @(x) (A - 4.1 * eye(n)) \ x;
833 %! opts.issym = 1; opts.isreal = 1; 835 %! opts.issym = 1; opts.isreal = 1;
834 %! d1 = eigs (fn, n, k, 4.1, opts); 836 %! d1 = eigs (fn, n, k, 4.1, opts);
835 %! assert (d1, eigs(A,k,4.1), 1e-11); 837 %! assert (d1, eigs(A,k,4.1), 1e-11);
836 %!testif HAVE_ARPACK 838 %!testif HAVE_ARPACK
839 %! AA = speye (10);
840 %! fn = @(x) A * x;
841 %! opts.issym = 1; opts.isreal = 1;
842 %! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1]);
843 %!testif HAVE_ARPACK
837 %! [v1,d1] = eigs(A, k, 'lm'); 844 %! [v1,d1] = eigs(A, k, 'lm');
838 %! d1 = diag(d1); 845 %! d1 = diag(d1);
839 %! for i=1:k 846 %! for i=1:k
840 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11) 847 %! assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
841 %! endfor 848 %! endfor