# HG changeset patch # User Sebastien Villemot # Date 1551111751 -3600 # Node ID 74e63d2fd0d01f7ad5857cfb917c65ccf48ecad0 # Parent c2e6725987cec31ffb2eba66b7fd18b3e88726ee ordeig.m: Do not fail on 1x1 matrices (bug #55779); * ordeig.m (isquasitri): Special case 1x1 and 2x2 matrices and immediately return true. * ordeig.m: Add regression BIST test for 1x1 matrices. diff -r c2e6725987ce -r 74e63d2fd0d0 scripts/linear-algebra/ordeig.m --- a/scripts/linear-algebra/ordeig.m Mon Feb 25 23:08:27 2019 +0100 +++ b/scripts/linear-algebra/ordeig.m Mon Feb 25 17:22:31 2019 +0100 @@ -99,10 +99,14 @@ endfunction -# Checks whether a matrix is quasi-triangular +## Check whether a matrix is quasi-triangular function retval = isquasitri (A) - v = diag (A, -1) != 0; - retval = all (tril (A, -2)(:) == 0) && all (v(1:end-1) + v(2:end) < 2); + if (length (A) <= 2) + retval = true; + else + v = diag (A, -1) != 0; + retval = (all (tril (A, -2)(:) == 0) && all (v(1:end-1) + v(2:end) < 2)); + endif endfunction @@ -124,6 +128,11 @@ %! lambda = ordeig (AA, BB); %! assert (lambda, diag (AA) ./ diag (BB)); +## Check trivial 1x1 case +%!test <*55779> +%! lambda = ordeig ([6], [2]); +%! assert (lambda, 3); + ## Test input validation %!error ordeig () %!error ordeig (1,2,3)