changeset 18879:161b11e7da2d stable

Return error code from sparse chol factorization (bug #42587). * chol.cc (Fchol): Return info variable, rather than P which is always 0, for sparse chol factorizations with more than 1 output argument. Add %!test for correct behavior.
author Rik <rik@octave.org>
date Thu, 19 Jun 2014 09:41:12 -0700
parents 77d5e7661b8e
children ff4da3c8ed16
files libinterp/dldfcn/chol.cc
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/chol.cc	Wed Jun 18 13:23:52 2014 -0700
+++ b/libinterp/dldfcn/chol.cc	Thu Jun 19 09:41:12 2014 -0700
@@ -212,7 +212,7 @@
 
                   if (nargout > 1 || info == 0)
                     {
-                      retval(1) = fact.P ();
+                      retval(1) = info;
                       if (LLt)
                         retval(0) = fact.L ();
                       else
@@ -240,7 +240,7 @@
 
                   if (nargout > 1 || info == 0)
                     {
-                      retval(1) = fact.P ();
+                      retval(1) = info;
                       if (LLt)
                         retval(0) = fact.L ();
                       else
@@ -375,6 +375,11 @@
 /*
 %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps))
 %!assert (chol (single ([2, 1; 1, 1])), single ([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single")))
+%!test   
+%! ## Bug #42587
+%! A = sparse ([1 0 8;0 1 8;8 8 1]);
+%! [Q, p] = chol (A);
+%! assert (p != 0);
 
 %!error chol ()
 %!error <matrix must be positive definite> chol ([1, 2; 3, 4])