# HG changeset patch # User Carnë Draug # Date 1469885448 -3600 # Node ID e35866e6a2e08a8fe14fc97c575ecff0c088b4cb # Parent 20b225a3ebf8ab650d6de437f41534464aead31b normest1: always return a column vector for IT output (patch #8837) * normest1.m: special code path returns a row vector for number of iterations while it returns a column vector for all others. This is Matlab compatible but obviously a bug in Matlab. Fix to always return a vector of same shape. Add tests. diff -r 20b225a3ebf8 -r e35866e6a2e0 scripts/linear-algebra/normest1.m --- a/scripts/linear-algebra/normest1.m Sat Jul 23 17:45:32 2016 +0200 +++ b/scripts/linear-algebra/normest1.m Sat Jul 30 14:30:48 2016 +0100 @@ -111,7 +111,10 @@ v = zeros (n, 1); v(idx) = 1; w = A(:, idx); - k = [0, 1]; + ## Matlab incompatible on purpose. Matlab returns k as a row vector + ## for this special case, but a column vector in all other cases. + ## This is obviously a bug in Matlab that we don't reproduce. + k = [0; 1]; return else realm = isreal (A); @@ -354,3 +357,10 @@ %! unwind_protect_cleanup %! rand ("state", old_state); %! end_unwind_protect + +## Check IT is always a column vector. +%!test +%! [~, ~, ~, it] = normest1 (rand (3), 3); +%! assert (iscolumn (it)) +%! [~, ~, ~, it] = normest1 (rand (50), 20); +%! assert (iscolumn (it))