Mercurial > octave
changeset 25300:4c98a9e5ce25 stable
Fix segmentation fault in eigs when B is not SPD (bug #53719).
* eigs-base.cc (make_cholb): check for info != 0 after a sparse
Cholesky factorization.
* eigs.m (select): Fix conditions for "lr", "sr", "li", and "si"
cases. New test.
author | Marco Caliari <marco.caliari@univr.it> |
---|---|
date | Tue, 24 Apr 2018 08:29:11 +0200 |
parents | 537b732926fb |
children | 1a632692a58e |
files | liboctave/numeric/eigs-base.cc scripts/sparse/eigs.m |
diffstat | 2 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/numeric/eigs-base.cc Tue Apr 24 10:35:49 2018 -0400 +++ b/liboctave/numeric/eigs-base.cc Tue Apr 24 08:29:11 2018 +0200 @@ -210,7 +210,7 @@ octave_idx_type info; octave::math::sparse_chol<SparseMatrix> fact (b, info, false); - if (fact.P () != 0) + if (info != 0) return false; else { @@ -248,7 +248,7 @@ octave_idx_type info; octave::math::sparse_chol<SparseComplexMatrix> fact (b, info, false); - if (fact.P () != 0) + if (info != 0) return false; else {
--- a/scripts/sparse/eigs.m Tue Apr 24 10:35:49 2018 -0400 +++ b/scripts/sparse/eigs.m Tue Apr 24 08:29:11 2018 +0200 @@ -305,28 +305,28 @@ endif case "lr" - if (! (real_valued || symmetric)) + if (! (real_valued && symmetric)) [~, idx] = sort (real (d), "descend"); else error ('eigs: SIGMA = "lr" requires complex or unsymmetric problem'); endif case "sr" - if (! (real_valued || symmetric)) + if (! (real_valued && symmetric)) [~, idx] = sort (real (d), "ascend"); else error ('eigs: SIGMA = "sr" requires complex or unsymmetric problem'); endif case "li" - if (! (real_valued || symmetric)) + if (! (real_valued && symmetric)) [~, idx] = sort (imag (d), "descend"); else error ('eigs: SIGMA = "li" requires complex or unsymmetric problem'); endif case "si" - if (! (real_valued || symmetric)) + if (! (real_valued && symmetric)) [~, idx] = sort (imag (d), "ascend"); else error ('eigs: SIGMA = "si" requires complex or unsymmetric problem'); @@ -1443,3 +1443,10 @@ %! warning ("off", "Octave:eigs:UnconvergedEigenvalues", "local"); %! d = eigs (Afun, 100, 6, "lm", opts); %! assert (d(6), NaN+1i*NaN); +%!testif HAVE_ARPACK +%! A = sparse (magic (10)); +%! B = sparse (magic (10)); # not HPD +%! fail ("eigs (A, B, 4)", "eigs: The matrix B is not positive definite") +%!testif HAVE_ARPACK +%! A = rand (8); +%! eigs (A, 6, "lr"); # this failed in 4.2.x