changeset 20273:014e942ac29f stable

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.
author Mike Miller <mtmiller@octave.org>
date Sat, 30 May 2015 15:46:04 -0400
parents abbe33bf0c74
children 4c2d39de1e96
files scripts/linear-algebra/linsolve.m
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;