# HG changeset patch # User Mike Miller # Date 1433015164 14400 # Node ID 014e942ac29fbcc15a71b2d2692ae47a7eb018d5 # Parent abbe33bf0c74d43144b8c8f483d04e8cd73ab0e6 linsolve.m: Fix regression when calling linsolve with 2 arguments (bug #45212) * linsolve.m: Fix regression introduced in cset 91e1da1d1918 when linsolve is called with 2 arguments. Add %!test for 2-argument form. diff -r abbe33bf0c74 -r 014e942ac29f scripts/linear-algebra/linsolve.m --- a/scripts/linear-algebra/linsolve.m Thu May 28 22:16:24 2015 -0400 +++ b/scripts/linear-algebra/linsolve.m Sat May 30 15:46:04 2015 -0400 @@ -79,12 +79,13 @@ error ("linsolve: A and B must be numeric"); endif + trans_A = false; + ## Process any opts if (nargin > 2) if (! isstruct (opts)) error ("linsolve: OPTS must be a structure"); endif - trans_A = false; if (isfield (opts, "TRANSA") && opts.TRANSA) trans_A = true; endif @@ -119,6 +120,14 @@ %!test %! n = 10; +%! A = rand (n); +%! x = rand (n, 1); +%! b = A * x; +%! assert (linsolve (A, b), A \ b); +%! assert (linsolve (A, b, struct ()), A \ b); + +%!test +%! n = 10; %! A = triu (gallery ("condex", n)); %! x = rand (n, 1); %! b = A' * x;