changeset 20892:c07bee629973

2015 Code Sprint: use ovl ().
author Rik <rik@octave.org>
date Mon, 14 Dec 2015 11:28:48 -0800
parents 95c0d4c07c56
children 384ff5aa9437
files libinterp/corefcn/__ilu__.cc libinterp/corefcn/__qp__.cc libinterp/corefcn/besselj.cc libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/det.cc libinterp/corefcn/ellipj.cc libinterp/corefcn/filter.cc libinterp/corefcn/graphics.cc libinterp/corefcn/inv.cc libinterp/corefcn/lsode.cc libinterp/corefcn/lu.cc libinterp/corefcn/luinc.cc libinterp/corefcn/max.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/octave-link.cc libinterp/corefcn/ordschur.cc libinterp/corefcn/profiler.cc libinterp/corefcn/qz.cc libinterp/corefcn/schur.cc libinterp/corefcn/spparms.cc libinterp/corefcn/sqrtm.cc
diffstat 23 files changed, 398 insertions(+), 471 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__ilu__.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/__ilu__.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -134,14 +134,15 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
-  std::string milu;
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
     print_usage ();
 
+  octave_value_list retval (2);
+
+  std::string milu;
+
   // In ILU0 algorithm the zero-pattern of the input matrix is preserved so
   // it's structure does not change during the algorithm.  The same input
   // matrix is used to build the output matrix due to that fact.
@@ -467,18 +468,17 @@
 @deftypefn  {} {[@var{L}, @var{U}] =} __iluc__ (@var{A})\n\
 @deftypefnx {} {[@var{L}, @var{U}] =} __iluc__ (@var{A}, @var{droptol})\n\
 @deftypefnx {} {[@var{L}, @var{U}] =} __iluc__ (@var{A}, @var{droptol}, @var{milu})\n\
-@deftypefnx {} {[@var{L}, @var{U}, @var{P}] =} __iluc__ (@var{A}, @dots{})\n\
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
-  std::string milu = "off";
-  double droptol = 0;
 
   if (nargout != 2 || nargin < 1 || nargin > 3)
     print_usage ();
 
+  std::string milu = "off";
+  double droptol = 0;
+
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
     droptol = args(1).double_value ();
@@ -499,8 +499,7 @@
       param_list(1) = "cols";
       cols_norm = feval ("norm", param_list)(0).vector_value ();
       param_list.clear ();
-      SparseMatrix U;
-      SparseMatrix L;
+      SparseMatrix U, L;
       ilu_crout <SparseMatrix, double> (sm_l, sm_u, L, U,
                                         cols_norm.fortran_vec (),
                                         rows_norm.fortran_vec (),
@@ -508,8 +507,7 @@
       param_list.append (octave_value (L.cols ()));
       SparseMatrix eye =
         feval ("speye", param_list)(0).sparse_matrix_value ();
-      retval(1) = U;
-      retval(0) = L + eye;
+      return ovl (L + eye, U);
     }
   else
     {
@@ -525,8 +523,7 @@
       param_list(1) = "cols";
       cols_norm = feval ("norm", param_list)(0).complex_vector_value ();
       param_list.clear ();
-      SparseComplexMatrix U;
-      SparseComplexMatrix L;
+      SparseComplexMatrix U, L;
       ilu_crout < SparseComplexMatrix, Complex >
                 (sm_l, sm_u, L, U, cols_norm.fortran_vec () ,
                  rows_norm.fortran_vec (), Complex (droptol), milu);
@@ -534,11 +531,8 @@
       param_list.append (octave_value (L.cols ()));
       SparseComplexMatrix eye =
         feval ("speye", param_list)(0).sparse_complex_matrix_value ();
-      retval(1) = U;
-      retval(0) = L + eye;
+      return ovl (L + eye, U);
     }
-
-  return retval;
 }
 
 // That function implements the IKJ and JKI variants of gaussian elimination
@@ -944,17 +938,17 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  int nargin = args.length ();
 
-  int nargin = args.length ();
+  if (nargout < 2 || nargout > 3 || nargin < 1 || nargin > 5)
+    print_usage ();
+
+  octave_value_list retval;
   std::string milu = "";
   double droptol = 0;
   double thresh = 1;
   double udiag = 0;
 
-  if (nargout < 2 || nargout > 3 || nargin < 1 || nargin > 5)
-    print_usage ();
-
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
     droptol = args(1).double_value ();
@@ -985,8 +979,7 @@
       rc_norm = feval ("norm", param_list)(0).vector_value ();
       param_list.clear ();
       Array <octave_idx_type> perm (dim_vector (sm.cols (), 1));
-      SparseMatrix U;
-      SparseMatrix L;
+      SparseMatrix U, L;
       ilu_tp <SparseMatrix, double> (sm, L, U, nnz_u, nnz_l,
                                      rc_norm.fortran_vec (),
                                      perm, droptol, thresh, milu, udiag);
@@ -1036,8 +1029,7 @@
       rc_norm = feval ("norm", param_list)(0).complex_vector_value ();
       Array <octave_idx_type> perm (dim_vector (sm.cols (), 1));
       param_list.clear ();
-      SparseComplexMatrix U;
-      SparseComplexMatrix L;
+      SparseComplexMatrix U, L;
       ilu_tp < SparseComplexMatrix, Complex>
               (sm, L, U, nnz_u, nnz_l, rc_norm.fortran_vec (), perm,
                Complex (droptol), Complex (thresh), milu, udiag);
--- a/libinterp/corefcn/__qp__.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/__qp__.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -491,23 +491,21 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 8)
     print_usage ();
 
-  const ColumnVector x0  (args(0) . vector_value ());
-  const Matrix H         (args(1) . matrix_value ());
-  const ColumnVector q   (args(2) . vector_value ());
-  const Matrix Aeq       (args(3) . matrix_value ());
-  const ColumnVector beq (args(4) . vector_value ());
-  const Matrix Ain       (args(5) . matrix_value ());
-  const ColumnVector bin (args(6) . vector_value ());
-  const int maxit        (args(7) . int_value ());
+  const ColumnVector x0  (args(0).vector_value ());
+  const Matrix H         (args(1).matrix_value ());
+  const ColumnVector q   (args(2).vector_value ());
+  const Matrix Aeq       (args(3).matrix_value ());
+  const ColumnVector beq (args(4).vector_value ());
+  const Matrix Ain       (args(5).matrix_value ());
+  const ColumnVector bin (args(6).vector_value ());
+  const int maxit        (args(7).int_value ());
 
   int iter = 0;
 
-  // Copying the initial guess in the working variable
+  // Copy the initial guess into the working variable
   ColumnVector x = x0;
 
   // Reordering the Lagrange multipliers
@@ -515,12 +513,7 @@
 
   int info = qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
 
-  retval(3) = iter;
-  retval(2) = info;
-  retval(1) = lambda;
-  retval(0) = x;
-
-  return retval;
+  return ovl (x, lambda, info, iter);
 }
 
 /*
--- a/libinterp/corefcn/besselj.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/besselj.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -81,13 +81,13 @@
 do_bessel (enum bessel_type type, const char *fn,
            const octave_value_list& args, int nargout)
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  octave_value_list retval (nargout > 1 ? 2 : 1);
+
   bool scaled = false;
   if (nargin == 3)
     {
@@ -128,10 +128,9 @@
 
               DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = static_cast<float> (ierr);
-
-              retval(0) = result;
             }
           else
             {
@@ -143,10 +142,9 @@
 
               DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = NDArray (ierr);
-
-              retval(0) = result;
             }
         }
       else
@@ -169,10 +167,9 @@
 
               DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = NDArray (ierr);
-
-              retval(0) = result;
             }
           else
             {
@@ -187,10 +184,9 @@
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+                  retval(0) = result;
                   if (nargout > 1)
                     retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
                 }
               else
                 {
@@ -202,10 +198,9 @@
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+                  retval(0) = result;
                   if (nargout > 1)
                     retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
                 }
             }
         }
@@ -225,10 +220,9 @@
 
               DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = static_cast<double> (ierr);
-
-              retval(0) = result;
             }
           else
             {
@@ -239,10 +233,9 @@
 
               DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = NDArray (ierr);
-
-              retval(0) = result;
             }
         }
       else
@@ -265,10 +258,9 @@
 
               DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
 
+              retval(0) = result;
               if (nargout > 1)
                 retval(1) = NDArray (ierr);
-
-              retval(0) = result;
             }
           else
             {
@@ -283,10 +275,9 @@
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+                  retval(0) = result;
                   if (nargout > 1)
                     retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
                 }
               else
                 {
@@ -297,10 +288,9 @@
 
                   DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
+                  retval(0) = result;
                   if (nargout > 1)
                     retval(1) = NDArray (ierr);
-
-                  retval(0) = result;
                 }
             }
         }
@@ -432,13 +422,13 @@
 See besselj.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 4)
     print_usage ();
 
+  octave_value_list retval;
+
   if (nargin == 2)
     {
       retval = do_bessel (BESSEL_H1, "besselh", args, nargout);
@@ -517,17 +507,14 @@
 @end enumerate\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
 
-  bool scale = (nargin == 3);
+  octave_value_list retval (nargout > 1 ? 2 : 1);
 
   int kind = 0;
-
   if (nargin > 1)
     {
       kind = args(0).xint_value ("airy: K must be an integer value");
@@ -536,7 +523,9 @@
         error ("airy: K must be 0, 1, 2, or 3");
     }
 
-  int idx = nargin == 1 ? 0 : 1;
+  bool scale = (nargin == 3);
+
+  int idx = (nargin == 1 ? 0 : 1);
 
   if (args(idx).is_single_type ())
     {
@@ -550,10 +539,9 @@
       else
         result = airy (z, kind == 1, scale, ierr);
 
+      retval(0) = result;
       if (nargout > 1)
         retval(1) = NDArray (ierr);
-
-      retval(0) = result;
     }
   else
     {
@@ -567,17 +555,16 @@
       else
         result = airy (z, kind == 1, scale, ierr);
 
+      retval(0) = result;
       if (nargout > 1)
         retval(1) = NDArray (ierr);
-
-      retval(0) = result;
     }
 
   return retval;
 }
 
 /*
-%!# FIXME: Function airy does not yet have BIST tests
+FIXME: Function airy does not yet have BIST tests
 */
 
 /*
--- a/libinterp/corefcn/daspk.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/daspk.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -277,7 +277,7 @@
 @seealso{dassl}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (4);
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
@@ -445,22 +445,22 @@
 
   std::string msg = dae.error_message ();
 
-  retval(3) = msg;
-  retval(2) = static_cast<double> (dae.integration_state ());
-
   if (dae.integration_ok ())
     {
+      retval(0) = output;
       retval(1) = deriv_output;
-      retval(0) = output;
     }
   else
     {
-      retval(1) = Matrix ();
-      retval(0) = Matrix ();
-
       if (nargout < 3)
         error ("daspk: %s", msg.c_str ());
+
+      retval(0) = Matrix ();
+      retval(1) = Matrix ();
     }
 
+  retval(2) = static_cast<double> (dae.integration_state ());
+  retval(3) = msg;
+
   return retval;
 }
--- a/libinterp/corefcn/dasrt.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/dasrt.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -356,7 +356,7 @@
 @seealso{dasrt_options, daspk, dasrt, lsode}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (5);
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
@@ -554,24 +554,24 @@
 
   std::string msg = dae.error_message ();
 
-  retval(4) = msg;
-  retval(3) = static_cast<double> (dae.integration_state ());
-
   if (dae.integration_ok ())
     {
-      retval(2) = output.times ();
+      retval(0) = output.state ();
       retval(1) = output.deriv ();
-      retval(0) = output.state ();
+      retval(2) = output.times ();
     }
   else
     {
-      retval(2) = Matrix ();
-      retval(1) = Matrix ();
-      retval(0) = Matrix ();
-
       if (nargout < 4)
         error ("dasrt: %s", msg.c_str ());
+
+      retval(0) = Matrix ();
+      retval(1) = Matrix ();
+      retval(2) = Matrix ();
     }
 
+  retval(3) = static_cast<double> (dae.integration_state ());
+  retval(4) = msg;
+
   return retval;
 }
--- a/libinterp/corefcn/dassl.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/dassl.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -278,7 +278,7 @@
 @seealso{daspk, dasrt, lsode}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (4);
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
@@ -447,23 +447,23 @@
 
   std::string msg = dae.error_message ();
 
-  retval(3) = msg;
-  retval(2) = static_cast<double> (dae.integration_state ());
-
   if (dae.integration_ok ())
     {
+      retval(0) = output;
       retval(1) = deriv_output;
-      retval(0) = output;
     }
   else
     {
-      retval(1) = Matrix ();
-      retval(0) = Matrix ();
-
       if (nargout < 3)
         error ("dassl: %s", msg.c_str ());
+
+      retval(0) = Matrix ();
+      retval(1) = Matrix ();
     }
 
+  retval(2) = static_cast<double> (dae.integration_state ());
+  retval(3) = msg;
+
   return retval;
 }
 
--- a/libinterp/corefcn/det.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/det.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -64,8 +64,6 @@
 @seealso{cond, condest, rcond}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 1)
     print_usage ();
 
@@ -75,28 +73,29 @@
   octave_idx_type nc = arg.columns ();
 
   if (nr == 0 && nc == 0)
-    {
-      retval(0) = 1.0;
-      return retval;
-    }
+    return octave_value (1.0);
 
   int arg_is_empty = empty_arg ("det", nr, nc);
   if (arg_is_empty < 0)
-    return retval;
+    return octave_value_list ();
   if (arg_is_empty > 0)
-    return octave_value (Matrix (1, 1, 1.0));
-
+    return octave_value (1.0);
 
   if (nr != nc)
     {
       gripe_square_matrix_required ("det");
-      return retval;
+      return octave_value_list ();
     }
 
+  octave_value_list retval (2);
+
   bool isfloat = arg.is_single_type ();
 
   if (arg.is_diag_matrix ())
     {
+      if (nargout <= 1)
+        retval.resize (1);
+
       if (arg.is_complex_type ())
         {
           if (isfloat)
@@ -133,6 +132,9 @@
     }
   else if (arg.is_perm_matrix ())
     {
+      if (nargout <= 1)
+        retval.resize (1);
+
       retval(0) = static_cast<double> (arg.perm_matrix_value ().determinant ());
       if (nargout > 1)
         retval(1) = 1.0;
@@ -150,8 +152,8 @@
           MAYBE_CAST (rep, octave_float_matrix);
           MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
           FloatDET det = m.determinant (mtype, info, rcond);
+          retval(0) = info == -1 ? 0.0f : det.value ();
           retval(1) = rcond;
-          retval(0) = info == -1 ? 0.0f : det.value ();
           if (rep)
             rep->matrix_type (mtype);
         }
@@ -166,8 +168,8 @@
           MAYBE_CAST (rep, octave_float_complex_matrix);
           MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
           FloatComplexDET det = m.determinant (mtype, info, rcond);
+          retval(0) = info == -1 ? FloatComplex (0.0) : det.value ();
           retval(1) = rcond;
-          retval(0) = info == -1 ? FloatComplex (0.0) : det.value ();
           if (rep)
             rep->matrix_type (mtype);
         }
@@ -185,8 +187,8 @@
               SparseMatrix m = arg.sparse_matrix_value ();
 
               DET det = m.determinant (info, rcond);
+              retval(0) = info == -1 ? 0.0 : det.value ();
               retval(1) = rcond;
-              retval(0) = info == -1 ? 0.0 : det.value ();
             }
           else
             {
@@ -196,8 +198,8 @@
               MatrixType mtype = rep ? rep -> matrix_type ()
                 : MatrixType ();
               DET det = m.determinant (mtype, info, rcond);
+              retval(0) = info == -1 ? 0.0 : det.value ();
               retval(1) = rcond;
-              retval(0) = info == -1 ? 0.0 : det.value ();
               if (rep)
                 rep->matrix_type (mtype);
             }
@@ -213,8 +215,8 @@
               SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
 
               ComplexDET det = m.determinant (info, rcond);
+              retval(0) = info == -1 ? Complex (0.0) : det.value ();
               retval(1) = rcond;
-              retval(0) = info == -1 ? Complex (0.0) : det.value ();
             }
           else
             {
@@ -224,8 +226,8 @@
               MatrixType mtype = rep ? rep -> matrix_type ()
                 : MatrixType ();
               ComplexDET det = m.determinant (mtype, info, rcond);
+              retval(0) = info == -1 ? Complex (0.0) : det.value ();
               retval(1) = rcond;
-              retval(0) = info == -1 ? Complex (0.0) : det.value ();
               if (rep)
                 rep->matrix_type (mtype);
             }
@@ -233,6 +235,7 @@
       else
         gripe_wrong_type_arg ("det", arg);
     }
+
   return retval;
 }
 
--- a/libinterp/corefcn/ellipj.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/ellipj.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -68,13 +68,13 @@
 @seealso{ellipke}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  octave_value_list retval (nargout > 3 ? 4 : 3);
+
   octave_value u_arg = args(0);
   octave_value m_arg = args(1);
 
@@ -94,11 +94,10 @@
 
               ellipj (u, m, sn, cn, dn, err);
 
-              if (nargout > 3)
-                retval(3) = err;
-              retval(2) = dn;
-              retval(1) = cn;
-              retval(0) = sn;
+              if (nargout <= 3)
+                return ovl (sn, cn, dn);
+              else
+                return ovl (sn, cn, dn, err);
             }
           else
             {
@@ -110,11 +109,10 @@
 
               ellipj (u, m, sn, cn, dn, err);
 
-              if (nargout > 3)
-                retval(3) = err;
-              retval(2) = dn;
-              retval(1) = cn;
-              retval(0) = sn;
+              if (nargout <= 3)
+                return ovl (sn, cn, dn);
+              else
+                return ovl (sn, cn, dn, err);
             }
         }
       else
@@ -137,11 +135,11 @@
           for (octave_idx_type i = 0; i < nel; i++)
             ellipj (pu[i], m, psn[i], pcn[i], pdn[i], perr[i]);
 
-          if (nargout > 3)
-            retval(3) = err;
-          retval(2) = dn;
-          retval(1) = cn;
-          retval(0) = sn;
+
+          if (nargout <= 3)
+            return ovl (sn, cn, dn);
+          else
+            return ovl (sn, cn, dn, err);
         }
     }
   else
@@ -171,11 +169,10 @@
               for (octave_idx_type i = 0; i < nel; i++)
                 ellipj (u, pm[i], psn[i], pcn[i], pdn[i], perr[i]);
 
-              if (nargout > 3)
-                retval(3) = err;
-              retval(2) = dn;
-              retval(1) = cn;
-              retval(0) = sn;
+              if (nargout <= 3)
+                return ovl (sn, cn, dn);
+              else
+                return ovl (sn, cn, dn, err);
             }
           else
             {
@@ -195,11 +192,10 @@
               for (octave_idx_type i = 0; i < nel; i++)
                 ellipj (u, pm[i], psn[i], pcn[i], pdn[i], perr[i]);
 
-              if (nargout > 3)
-                retval(3) = err;
-              retval(2) = dn;
-              retval(1) = cn;
-              retval(0) = sn;
+              if (nargout <= 3)
+                return ovl (sn, cn, dn);
+              else
+                return ovl (sn, cn, dn, err);
             }
         }
       else
@@ -231,11 +227,10 @@
                       ellipj (pu[i], pm[j], sn(i,j), cn(i,j), dn(i,j),
                               err(i,j));
 
-                  if (nargout > 3)
-                    retval(3) = err;
-                  retval(2) = dn;
-                  retval(1) = cn;
-                  retval(0) = sn;
+                  if (nargout <= 3)
+                    return ovl (sn, cn, dn);
+                  else
+                    return ovl (sn, cn, dn, err);
                 }
               else if (sz_m == sz_u)
                 {
@@ -253,11 +248,10 @@
                   for (octave_idx_type i = 0; i < nel; i++)
                     ellipj (pu[i], pm[i], psn[i], pcn[i], pdn[i], perr[i]);
 
-                  if (nargout > 3)
-                    retval(3) = err;
-                  retval(2) = dn;
-                  retval(1) = cn;
-                  retval(0) = sn;
+                  if (nargout <= 3)
+                    return ovl (sn, cn, dn);
+                  else
+                    return ovl (sn, cn, dn, err);
                 }
               else
                 error ("ellipj: Invalid size combination for U and M");
@@ -288,11 +282,10 @@
                       ellipj (pu[i], pm[j], sn(i,j), cn(i,j), dn(i,j),
                               err(i,j));
 
-                  if (nargout > 3)
-                    retval(3) = err;
-                  retval(2) = dn;
-                  retval(1) = cn;
-                  retval(0) = sn;
+                  if (nargout <= 3)
+                    return ovl (sn, cn, dn);
+                  else
+                    return ovl (sn, cn, dn, err);
                 }
               else if (sz_m == sz_u)
                 {
@@ -310,11 +303,10 @@
                   for (octave_idx_type i = 0; i < nel; i++)
                     ellipj (pu[i], pm[i], psn[i], pcn[i], pdn[i], perr[i]);
 
-                  if (nargout > 3)
-                    retval(3) = err;
-                  retval(2) = dn;
-                  retval(1) = cn;
-                  retval(0) = sn;
+                  if (nargout <= 3)
+                    return ovl (sn, cn, dn);
+                  else
+                    return ovl (sn, cn, dn, err);
                 }
               else
                 error ("ellipj: Invalid size combination for U and M");
--- a/libinterp/corefcn/filter.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/filter.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -371,8 +371,6 @@
 @seealso{filter2, fftfilt, freqz}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 3 || nargin > 5)
@@ -402,6 +400,8 @@
         dim = 0;
     }
 
+  octave_value_list retval (nargout > 1 ? 2 : 1);
+
   bool isfloat = (args(0).is_single_type ()
                   || args(1).is_single_type ()
                   || args(2).is_single_type ()
@@ -444,10 +444,9 @@
 
           FloatComplexNDArray y (filter (b, a, x, si, dim));
 
+          retval(0) = y;
           if (nargout == 2)
             retval(1) = si;
-
-          retval(0) = y;
         }
       else
         {
@@ -482,10 +481,9 @@
 
           ComplexNDArray y (filter (b, a, x, si, dim));
 
+          retval(0) = y;
           if (nargout == 2)
             retval(1) = si;
-
-          retval(0) = y;
         }
     }
   else
@@ -523,10 +521,9 @@
 
           FloatNDArray y (filter (b, a, x, si, dim));
 
+          retval(0) = y;
           if (nargout == 2)
             retval(1) = si;
-
-          retval(0) = y;
         }
       else
         {
@@ -561,10 +558,9 @@
 
           NDArray y (filter (b, a, x, si, dim));
 
+          retval(0) = y;
           if (nargout == 2)
             retval(1) = si;
-
-          retval(0) = y;
         }
     }
 
--- a/libinterp/corefcn/graphics.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/graphics.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -6818,8 +6818,8 @@
 
   retval.resize (1, 2);
 
+  retval(0) = min_val;
   retval(1) = max_val;
-  retval(0) = min_val;
 
   return retval;
 }
--- a/libinterp/corefcn/inv.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/inv.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -58,11 +58,11 @@
 @seealso{ldivide, rdivide}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 1)
     print_usage ();
 
+  octave_value_list retval;
+
   octave_value arg = args(0);
 
   octave_idx_type nr = arg.rows ();
--- a/libinterp/corefcn/lsode.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/lsode.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -261,7 +261,7 @@
 @seealso{daspk, dassl, dasrt}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (3);
 
   warned_fcn_imaginary = false;
   warned_jac_imaginary = false;
@@ -427,18 +427,15 @@
 
   std::string msg = ode.error_message ();
 
-  retval(2) = msg;
-  retval(1) = static_cast<double> (ode.integration_state ());
-
   if (ode.integration_ok ())
     retval(0) = output;
+  else if (nargout < 2)
+    error ("lsode: %s", msg.c_str ());
   else
-    {
-      retval(0) = Matrix ();
+    retval(0) = Matrix ();
 
-      if (nargout < 2)
-        error ("lsode: %s", msg.c_str ());
-    }
+  retval(1) = static_cast<double> (ode.integration_state ());
+  retval(2) = msg;
 
   return retval;
 }
--- a/libinterp/corefcn/lu.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/lu.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -142,7 +142,6 @@
 @seealso{luupdate, ilu, chol, hess, qr, qz, schur, svd}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
   bool issparse = (nargin > 0 && args(0).is_sparse_type ());
 
@@ -150,29 +149,28 @@
       || (! issparse && (nargin > 2 || nargout > 3)))
     print_usage ();
 
-  bool scale = (nargout == 5);
   bool vecout = false;
   Matrix thres;
+  int n = 1;
 
-  int n = 1;
   while (n < nargin)
     {
       if (args(n).is_string ())
         {
           std::string tmp = args(n++).string_value ();
 
-          if (tmp.compare ("vector") == 0)
+          if (tmp == "vector")
             vecout = true;
           else
             error ("lu: unrecognized string argument");
         }
       else
         {
+          if (! issparse)
+            error ("lu: can not define pivoting threshold THRES for full matrices");
           Matrix tmp = args(n++).matrix_value ();
 
-          if (!issparse)
-            error ("lu: can not define pivoting threshold THRES for full matrices");
-          else if (tmp.numel () == 1)
+          if (tmp.numel () == 1)
             {
               thres.resize (1,2);
               thres(0) = tmp(0);
@@ -185,6 +183,9 @@
         }
     }
 
+  octave_value_list retval;
+  bool scale = (nargout == 5);
+
   octave_value arg = args(0);
 
   octave_idx_type nr = arg.rows ();
@@ -195,29 +196,26 @@
   if (issparse)
     {
       if (arg_is_empty < 0)
-        return retval;
+        return octave_value_list ();
       else if (arg_is_empty > 0)
         return octave_value_list (5, SparseMatrix ());
 
       if (arg.is_real_type ())
         {
-
           SparseMatrix m = arg.sparse_matrix_value ();
 
           if (nargout < 4)
             {
-
-              ColumnVector Qinit;
-              Qinit.resize (nc);
+              ColumnVector Qinit (nc);
               for (octave_idx_type i = 0; i < nc; i++)
-                Qinit (i) = i;
+                Qinit(i) = i;
               SparseLU fact (m, Qinit, thres, false, true);
 
               if (nargout < 2)
                 retval(0) = fact.Y ();
               else
                 {
-
+                  retval.resize (nargout == 3 ? 3 : 2); 
                   retval(1)
                     = octave_value (
                         fact.U () * fact.Pc_mat ().transpose (),
@@ -226,7 +224,8 @@
 
                   PermMatrix P = fact.Pr_mat ();
                   SparseMatrix L = fact.L ();
-                  if (nargout < 3)
+
+                  if (nargout == 2)
                       retval(0)
                         = octave_value (P.transpose () * L,
                             MatrixType (MatrixType::Permuted_Lower,
@@ -239,34 +238,32 @@
                       else
                         retval(2) = P;
                     }
-
                 }
-
             }
           else
             {
-
+              retval.resize (scale ? 5 : 4);
               SparseLU fact (m, thres, scale);
 
-              if (scale)
-                retval(4) = fact.R ();
+              retval(0) = octave_value (fact.L (),
+                                        MatrixType (MatrixType::Lower));
+              retval(1) = octave_value (fact.U (),
+                                        MatrixType (MatrixType::Upper));
 
               if (vecout)
                 {
+                  retval(2) = fact.Pr_vec ();
                   retval(3) = fact.Pc_vec ();
-                  retval(2) = fact.Pr_vec ();
                 }
               else
                 {
+                  retval(2) = fact.Pr_mat ();
                   retval(3) = fact.Pc_mat ();
-                  retval(2) = fact.Pr_mat ();
                 }
-              retval(1) = octave_value (fact.U (),
-                                        MatrixType (MatrixType::Upper));
-              retval(0) = octave_value (fact.L (),
-                                        MatrixType (MatrixType::Lower));
+
+              if (scale)
+                retval(4) = fact.R ();
             }
-
         }
       else if (arg.is_complex_type ())
         {
@@ -274,20 +271,16 @@
 
           if (nargout < 4)
             {
-
-              ColumnVector Qinit;
-              Qinit.resize (nc);
+              ColumnVector Qinit (nc);
               for (octave_idx_type i = 0; i < nc; i++)
-                Qinit (i) = i;
+                Qinit(i) = i;
               SparseComplexLU fact (m, Qinit, thres, false, true);
 
               if (nargout < 2)
-
                 retval(0) = fact.Y ();
-
               else
                 {
-
+                  retval.resize (nargout == 3 ? 3 : 2); 
                   retval(1)
                     = octave_value (
                         fact.U () * fact.Pc_mat ().transpose (),
@@ -296,7 +289,7 @@
 
                   PermMatrix P = fact.Pr_mat ();
                   SparseComplexMatrix L = fact.L ();
-                  if (nargout < 3)
+                  if (nargout == 2)
                     retval(0)
                       = octave_value (P.transpose () * L,
                                       MatrixType (MatrixType::Permuted_Lower,
@@ -309,32 +302,31 @@
                       else
                         retval(2) = P;
                     }
-
                 }
-
             }
           else
             {
+              retval.resize (scale ? 5 : 4);
+              SparseComplexLU fact (m, thres, scale);
 
-              SparseComplexLU fact (m, thres, scale);
+              retval(0) = octave_value (fact.L (),
+                                        MatrixType (MatrixType::Lower));
+              retval(1) = octave_value (fact.U (),
+                                        MatrixType (MatrixType::Upper));
+
+              if (vecout)
+                {
+                  retval(2) = fact.Pr_vec ();
+                  retval(3) = fact.Pc_vec ();
+                }
+              else
+                {
+                  retval(2) = fact.Pr_mat ();
+                  retval(3) = fact.Pc_mat ();
+                }
 
               if (scale)
                 retval(4) = fact.R ();
-
-              if (vecout)
-                {
-                  retval(3) = fact.Pc_vec ();
-                  retval(2) = fact.Pr_vec ();
-                }
-              else
-                {
-                  retval(3) = fact.Pc_mat ();
-                  retval(2) = fact.Pr_mat ();
-                }
-              retval(1) = octave_value (fact.U (),
-                                        MatrixType (MatrixType::Upper));
-              retval(0) = octave_value (fact.L (),
-                                        MatrixType (MatrixType::Lower));
             }
 
         }
@@ -344,7 +336,7 @@
   else
     {
       if (arg_is_empty < 0)
-        return retval;
+        return octave_value_list ();
       else if (arg_is_empty > 0)
         return octave_value_list (3, Matrix ());
 
@@ -360,15 +352,14 @@
                 {
                 case 0:
                 case 1:
-                  retval(0) = fact.Y ();
+                  retval = ovl (fact.Y ());
                   break;
 
                 case 2:
                   {
                     PermMatrix P = fact.P ();
                     FloatMatrix L = P.transpose () * fact.L ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = L;
+                    retval = ovl (L, get_lu_u (fact));
                   }
                   break;
 
@@ -376,11 +367,11 @@
                 default:
                   {
                     if (vecout)
-                      retval(2) = fact.P_vec ();
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P_vec ());
                     else
-                      retval(2) = fact.P ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = get_lu_l (fact);
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P ());
                   }
                   break;
                 }
@@ -395,15 +386,14 @@
                 {
                 case 0:
                 case 1:
-                  retval(0) = fact.Y ();
+                  retval = ovl (fact.Y ());
                   break;
 
                 case 2:
                   {
                     PermMatrix P = fact.P ();
                     Matrix L = P.transpose () * fact.L ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = L;
+                    retval = ovl (L, get_lu_u (fact));
                   }
                   break;
 
@@ -411,11 +401,11 @@
                 default:
                   {
                     if (vecout)
-                      retval(2) = fact.P_vec ();
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P_vec ());
                     else
-                      retval(2) = fact.P ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = get_lu_l (fact);
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P ());
                   }
                   break;
                 }
@@ -433,15 +423,14 @@
                 {
                 case 0:
                 case 1:
-                  retval(0) = fact.Y ();
+                  retval = ovl (fact.Y ());
                   break;
 
                 case 2:
                   {
                     PermMatrix P = fact.P ();
                     FloatComplexMatrix L = P.transpose () * fact.L ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = L;
+                    retval = ovl (L, get_lu_u (fact));
                   }
                   break;
 
@@ -449,11 +438,11 @@
                 default:
                   {
                     if (vecout)
-                      retval(2) = fact.P_vec ();
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P_vec ());
                     else
-                      retval(2) = fact.P ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = get_lu_l (fact);
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P ());
                   }
                   break;
                 }
@@ -468,15 +457,14 @@
                 {
                 case 0:
                 case 1:
-                  retval(0) = fact.Y ();
+                  retval = ovl (fact.Y ());
                   break;
 
                 case 2:
                   {
                     PermMatrix P = fact.P ();
                     ComplexMatrix L = P.transpose () * fact.L ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = L;
+                    retval = ovl (L, get_lu_u (fact));
                   }
                   break;
 
@@ -484,11 +472,11 @@
                 default:
                   {
                     if (vecout)
-                      retval(2) = fact.P_vec ();
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P_vec ());
                     else
-                      retval(2) = fact.P ();
-                    retval(1) = get_lu_u (fact);
-                    retval(0) = get_lu_l (fact);
+                      retval = ovl (get_lu_l (fact), get_lu_u (fact),
+                                    fact.P ());
                   }
                   break;
                 }
@@ -576,6 +564,7 @@
   octave_idx_type m = l.rows ();
   octave_idx_type k = u.rows ();
   octave_idx_type n = u.columns ();
+
   return ((l.ndims () == 2 && u.ndims () == 2 && k == l.columns ())
           && k == std::min (m, n)
           && (p.is_undefined () || p.rows () == m));
@@ -626,7 +615,6 @@
 @seealso{lu, cholupdate, qrupdate}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
 
   if (nargin != 4 && nargin != 5)
@@ -640,111 +628,102 @@
   octave_value argx = args(2 + pivoted);
   octave_value argy = args(3 + pivoted);
 
-  if (argl.is_numeric_type () && argu.is_numeric_type ()
-      && argx.is_numeric_type () && argy.is_numeric_type ()
-      && (! pivoted || argp.is_perm_matrix ()))
-    {
-      if (check_lu_dims (argl, argu, argp))
-        {
-          PermMatrix P = (pivoted
-                          ? argp.perm_matrix_value ()
-                          : PermMatrix::eye (argl.rows ()));
+  if (! (argl.is_numeric_type () && argu.is_numeric_type ()
+         && argx.is_numeric_type () && argy.is_numeric_type ()
+         && (! pivoted || argp.is_perm_matrix ())))
+    error ("luupdate: L, U, X, and Y must be numeric");
 
-          if (argl.is_real_type ()
-              && argu.is_real_type ()
-              && argx.is_real_type ()
-              && argy.is_real_type ())
-            {
-              // all real case
-              if (argl.is_single_type ()
-                  || argu.is_single_type ()
-                  || argx.is_single_type ()
-                  || argy.is_single_type ())
-                {
-                  FloatMatrix L = argl.float_matrix_value ();
-                  FloatMatrix U = argu.float_matrix_value ();
-                  FloatMatrix x = argx.float_matrix_value ();
-                  FloatMatrix y = argy.float_matrix_value ();
+  if (! check_lu_dims (argl, argu, argp))
+    error ("luupdate: dimension mismatch");
 
-                  FloatLU fact (L, U, P);
-                  if (pivoted)
-                    fact.update_piv (x, y);
-                  else
-                    fact.update (x, y);
-
-                  if (pivoted)
-                    retval(2) = fact.P ();
-                  retval(1) = get_lu_u (fact);
-                  retval(0) = get_lu_l (fact);
-                }
-              else
-                {
-                  Matrix L = argl.matrix_value ();
-                  Matrix U = argu.matrix_value ();
-                  Matrix x = argx.matrix_value ();
-                  Matrix y = argy.matrix_value ();
-
-                  LU fact (L, U, P);
-                  if (pivoted)
-                    fact.update_piv (x, y);
-                  else
-                    fact.update (x, y);
+  octave_value_list retval;
+  PermMatrix P = (pivoted
+                  ? argp.perm_matrix_value ()
+                  : PermMatrix::eye (argl.rows ()));
 
-                  if (pivoted)
-                    retval(2) = fact.P ();
-                  retval(1) = get_lu_u (fact);
-                  retval(0) = get_lu_l (fact);
-                }
-            }
-          else
-            {
-              // complex case
-              if (argl.is_single_type ()
-                  || argu.is_single_type ()
-                  || argx.is_single_type ()
-                  || argy.is_single_type ())
-                {
-                  FloatComplexMatrix L = argl.float_complex_matrix_value ();
-                  FloatComplexMatrix U = argu.float_complex_matrix_value ();
-                  FloatComplexMatrix x = argx.float_complex_matrix_value ();
-                  FloatComplexMatrix y = argy.float_complex_matrix_value ();
-
-                  FloatComplexLU fact (L, U, P);
-                  if (pivoted)
-                    fact.update_piv (x, y);
-                  else
-                    fact.update (x, y);
+  if (argl.is_real_type () && argu.is_real_type ()
+      && argx.is_real_type () && argy.is_real_type ())
+    {
+      // all real case
+      if (argl.is_single_type () || argu.is_single_type ()
+          || argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatMatrix L = argl.float_matrix_value ();
+          FloatMatrix U = argu.float_matrix_value ();
+          FloatMatrix x = argx.float_matrix_value ();
+          FloatMatrix y = argy.float_matrix_value ();
 
-                  if (pivoted)
-                    retval(2) = fact.P ();
-                  retval(1) = get_lu_u (fact);
-                  retval(0) = get_lu_l (fact);
-                }
-              else
-                {
-                  ComplexMatrix L = argl.complex_matrix_value ();
-                  ComplexMatrix U = argu.complex_matrix_value ();
-                  ComplexMatrix x = argx.complex_matrix_value ();
-                  ComplexMatrix y = argy.complex_matrix_value ();
+          FloatLU fact (L, U, P);
+          if (pivoted)
+            fact.update_piv (x, y);
+          else
+            fact.update (x, y);
 
-                  ComplexLU fact (L, U, P);
-                  if (pivoted)
-                    fact.update_piv (x, y);
-                  else
-                    fact.update (x, y);
-
-                  if (pivoted)
-                    retval(2) = fact.P ();
-                  retval(1) = get_lu_u (fact);
-                  retval(0) = get_lu_l (fact);
-                }
-            }
+          if (pivoted)
+            retval(2) = fact.P ();
+          retval(1) = get_lu_u (fact);
+          retval(0) = get_lu_l (fact);
         }
       else
-        error ("luupdate: dimension mismatch");
+        {
+          Matrix L = argl.matrix_value ();
+          Matrix U = argu.matrix_value ();
+          Matrix x = argx.matrix_value ();
+          Matrix y = argy.matrix_value ();
+
+          LU fact (L, U, P);
+          if (pivoted)
+            fact.update_piv (x, y);
+          else
+            fact.update (x, y);
+
+          if (pivoted)
+            retval(2) = fact.P ();
+          retval(1) = get_lu_u (fact);
+          retval(0) = get_lu_l (fact);
+        }
     }
   else
-    error ("luupdate: L, U, X, and Y must be numeric");
+    {
+      // complex case
+      if (argl.is_single_type () || argu.is_single_type ()
+          || argx.is_single_type () || argy.is_single_type ())
+        {
+          FloatComplexMatrix L = argl.float_complex_matrix_value ();
+          FloatComplexMatrix U = argu.float_complex_matrix_value ();
+          FloatComplexMatrix x = argx.float_complex_matrix_value ();
+          FloatComplexMatrix y = argy.float_complex_matrix_value ();
+
+          FloatComplexLU fact (L, U, P);
+          if (pivoted)
+            fact.update_piv (x, y);
+          else
+            fact.update (x, y);
+
+          if (pivoted)
+            retval(2) = fact.P ();
+          retval(1) = get_lu_u (fact);
+          retval(0) = get_lu_l (fact);
+        }
+      else
+        {
+          ComplexMatrix L = argl.complex_matrix_value ();
+          ComplexMatrix U = argu.complex_matrix_value ();
+          ComplexMatrix x = argx.complex_matrix_value ();
+          ComplexMatrix y = argy.complex_matrix_value ();
+
+          ComplexLU fact (L, U, P);
+          if (pivoted)
+            fact.update_piv (x, y);
+          else
+            fact.update (x, y);
+
+          if (pivoted)
+            retval(2) = fact.P ();
+          retval(1) = get_lu_u (fact);
+          retval(0) = get_lu_l (fact);
+        }
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/luinc.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/luinc.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -99,16 +99,18 @@
 @end deftypefn")
 {
   int nargin = args.length ();
-  octave_value_list retval;
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  if (! args(0).is_sparse_type ())
+    error ("luinc: matrix A must be sparse");
+
   bool zero_level = false;
   bool milu = false;
   bool udiag = false;
   Matrix thresh;
-  double droptol = -1.;
+  double droptol = -1.0;
   bool vecout = false;
 
   if (args(1).is_string ())
@@ -133,7 +135,7 @@
         {
           double val = tmp.double_value ();
 
-          milu = (val == 0. ? false : true);
+          milu = (val == 0.0 ? false : true);
         }
 
       tmp = map.getfield ("udiag");
@@ -141,7 +143,7 @@
         {
           double val = tmp.double_value ();
 
-          udiag = (val == 0. ? false : true);
+          udiag = (val == 0.0 ? false : true);
         }
 
       tmp = map.getfield ("thresh");
@@ -151,7 +153,7 @@
 
           if (thresh.numel () == 1)
             {
-              thresh.resize (1,2);
+              thresh.resize (1, 2);
               thresh(1) = thresh(0);
             }
           else if (thresh.numel () != 2)
@@ -165,7 +167,7 @@
     {
       std::string tmp = args(2).string_value ();
 
-      if (tmp.compare ("vector") == 0)
+      if (tmp == "vector")
         vecout = true;
       else
         error ("luinc: unrecognized string argument");
@@ -175,7 +177,9 @@
   if (zero_level)
     error ("luinc: zero-level factorization not implemented");
 
-  if (args(0).type_name () == "sparse matrix")
+  octave_value_list retval;
+
+  if (args(0).is_real_type ())
     {
       SparseMatrix sm = args(0).sparse_matrix_value ();
       octave_idx_type sm_nr = sm.rows ();
@@ -183,7 +187,7 @@
       ColumnVector Qinit (sm_nc);
 
       for (octave_idx_type i = 0; i < sm_nc; i++)
-        Qinit (i) = i;
+        Qinit(i) = i;
 
       switch (nargout)
         {
@@ -250,16 +254,15 @@
           break;
         }
     }
-  else if (args(0).type_name () == "sparse complex matrix")
+  else
     {
-      SparseComplexMatrix sm =
-        args(0).sparse_complex_matrix_value ();
+      SparseComplexMatrix sm = args(0).sparse_complex_matrix_value ();
       octave_idx_type sm_nr = sm.rows ();
       octave_idx_type sm_nc = sm.cols ();
       ColumnVector Qinit (sm_nc);
 
       for (octave_idx_type i = 0; i < sm_nc; i++)
-        Qinit (i) = i;
+        Qinit(i) = i;
 
       switch (nargout)
         {
@@ -270,7 +273,6 @@
             SparseComplexLU fact (sm, Qinit, thresh, false, true,
                                   droptol, milu, udiag);
 
-
             SparseMatrix P = fact.Pr ();
             SparseComplexMatrix L = P.transpose () * fact.L ();
 
@@ -327,8 +329,6 @@
           break;
         }
     }
-  else
-    error ("luinc: matrix A must be sparse");
 
   return retval;
 }
--- a/libinterp/corefcn/max.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/max.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -46,12 +46,18 @@
 do_minmax_red_op (const octave_value& arg,
                   int nargout, int dim, bool ismin)
 {
-  octave_value_list retval;
+  octave_value_list retval (nargout > 1 ? 2 : 1);
   ArrayType array = octave_value_extract<ArrayType> (arg);
 
-  if (nargout == 2)
+  if (nargout <= 1)
     {
-      retval.resize (2);
+      if (ismin)
+        retval(0) = array.min (dim);
+      else
+        retval(0) = array.max (dim);
+    }
+  else
+    {
       Array<octave_idx_type> idx;
       if (ismin)
         retval(0) = array.min (idx, dim);
@@ -60,13 +66,6 @@
 
       retval(1) = octave_value (idx, true, true);
     }
-  else
-    {
-      if (ismin)
-        retval(0) = array.min (dim);
-      else
-        retval(0) = array.max (dim);
-    }
 
   return retval;
 }
@@ -84,12 +83,18 @@
 do_minmax_red_op<charNDArray> (const octave_value& arg,
                                int nargout, int dim, bool ismin)
 {
-  octave_value_list retval;
+  octave_value_list retval (nargout > 1 ? 2 : 1);
   charNDArray array = octave_value_extract<charNDArray> (arg);
 
-  if (nargout == 2)
+  if (nargout <= 1)
     {
-      retval.resize (2);
+      if (ismin)
+        retval(0) = NDArray (array.min (dim));
+      else
+        retval(0) = NDArray (array.max (dim));
+    }
+  else
+    {
       Array<octave_idx_type> idx;
       if (ismin)
         retval(0) = NDArray (array.min (idx, dim));
@@ -98,13 +103,6 @@
 
       retval(1) = octave_value (idx, true, true);
     }
-  else
-    {
-      if (ismin)
-        retval(0) = NDArray (array.min (dim));
-      else
-        retval(0) = NDArray (array.max (dim));
-    }
 
   return retval;
 }
@@ -227,15 +225,15 @@
 do_minmax_body (const octave_value_list& args,
                 int nargout, bool ismin)
 {
-  octave_value_list retval;
-
-  const char *func = ismin ? "min" : "max";
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
   
+  octave_value_list retval (nargout > 1 ? 2 : 1);
+
+  const char *func = ismin ? "min" : "max";
+
   if (nargin == 3 || nargin == 1)
     {
       octave_value arg = args(0);
@@ -876,10 +874,17 @@
 do_cumminmax_red_op (const octave_value& arg,
                      int nargout, int dim, bool ismin)
 {
-  octave_value_list retval;
+  octave_value_list retval (nargout > 1 ? 2 : 1);
   ArrayType array = octave_value_extract<ArrayType> (arg);
 
-  if (nargout == 2)
+  if (nargout <= 1)
+    {
+      if (ismin)
+        retval(0) = array.cummin (dim);
+      else
+        retval(0) = array.cummax (dim);
+    }
+  else
     {
       retval.resize (2);
       Array<octave_idx_type> idx;
@@ -890,13 +895,6 @@
 
       retval(1) = octave_value (idx, true, true);
     }
-  else
-    {
-      if (ismin)
-        retval(0) = array.cummin (dim);
-      else
-        retval(0) = array.cummax (dim);
-    }
 
   return retval;
 }
@@ -905,15 +903,13 @@
 do_cumminmax_body (const octave_value_list& args,
                    int nargout, bool ismin)
 {
-  octave_value_list retval;
-
-  const char *func = ismin ? "cummin" : "cummax";
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  const char *func = ismin ? "cummin" : "cummax";
+
   octave_value arg = args(0);
   int dim = -1;
   if (nargin == 2)
@@ -924,6 +920,8 @@
         error ("%s: DIM must be a valid dimension", func);
     }
 
+  octave_value_list retval;
+
   switch (arg.builtin_type ())
     {
     case btyp_double:
--- a/libinterp/corefcn/oct-stream.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/oct-stream.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -4378,21 +4378,17 @@
 string_vector
 octave_stream_list::do_get_info (int fid) const
 {
-  string_vector retval;
-
   octave_stream os = do_lookup (fid);
 
-  if (os.is_valid ())
-    {
-      retval.resize (3);
-
-      retval(2) = oct_mach_info::float_format_as_string (os.float_format ());
-      retval(1) = octave_stream::mode_as_string (os.mode ());
-      retval(0) = os.name ();
-    }
-  else
+  if (! os.is_valid ())
     ::error ("invalid file id = %d", fid);
 
+  string_vector retval (3);
+
+  retval(0) = os.name ();
+  retval(1) = octave_stream::mode_as_string (os.mode ());
+  retval(2) = oct_mach_info::float_format_as_string (os.float_format ());
+
   return retval;
 }
 
--- a/libinterp/corefcn/octave-link.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/octave-link.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -254,9 +254,7 @@
               it++;
             }
 
-          retval(0) = items;
-          retval(1) = *it++;
-          retval(2) = atoi (it->c_str ());
+          retval = ovl (items, *it++, atoi (it->c_str ()));
         }
     }
 
@@ -319,8 +317,7 @@
           items.xelem(i++) = *it;
         }
 
-      retval(1) = result.second;
-      retval(0) = items;
+      retval = ovl (items, result.second);
     }
 
   return retval;
--- a/libinterp/corefcn/ordschur.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/ordschur.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -141,8 +141,7 @@
           if (info != 0) \
             error ("ordschur: trsen failed"); \
  \
-          retval(0) = U; \
-          retval(1) = S;
+          retval = ovl (U, S);
 
   if (double_type)
     {
--- a/libinterp/corefcn/profiler.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/profiler.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -433,11 +433,11 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () > 0)
     warning ("profiler_data: ignoring extra arguments");
 
+  octave_value_list retval;
+
   if (nargout > 1)
     retval(1) = profiler.get_hierarchical ();
   retval(0) = profiler.get_flat ();
--- a/libinterp/corefcn/qz.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/qz.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -374,7 +374,6 @@
 @seealso{eig, balance, lu, chol, hess, qr, qzhess, schur, svd}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
   int nargin = args.length ();
 
 #ifdef DEBUG
@@ -455,6 +454,8 @@
             << std::endl;
 #endif
 
+  octave_value_list retval;
+
   int arg_is_empty = empty_arg ("qz", nn, args(0).columns ());
 
   if (arg_is_empty < 0)
@@ -1213,7 +1214,6 @@
       }
       break;
 
-
     case 1:
     case 0:
 #ifdef DEBUG
--- a/libinterp/corefcn/schur.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/schur.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -128,8 +128,6 @@
 @seealso{rsf2csf, ordschur, lu, chol, hess, qr, qz, svd}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2 || nargout > 2)
@@ -138,7 +136,6 @@
   octave_value arg = args(0);
 
   std::string ord;
-
   if (nargin == 2)
     ord = args(1).xstring_value ("schur: second argument must be a string");
 
@@ -162,7 +159,7 @@
         {
           warning ("schur: incorrect ordered schur argument '%s'",
                    ord.c_str ());
-          return retval;
+          return octave_value_list ();
         }
     }
 
@@ -172,9 +169,11 @@
   if (nr != nc)
     {
       gripe_square_matrix_required ("schur");
-      return retval;
+      return octave_value_list ();
     }
 
+  octave_value_list retval (nargout > 1 ? 2 : 1);
+
   if (! arg.is_numeric_type ())
     gripe_wrong_type_arg ("schur", arg);
   else if (arg.is_single_type ())
@@ -183,32 +182,32 @@
         {
           FloatMatrix tmp = arg.float_matrix_value ();
 
-          if (nargout == 0 || nargout == 1)
+          if (nargout <= 1)
             {
               FloatSCHUR result (tmp, ord, false);
-              retval(0) = result.schur_matrix ();
+              retval = ovl (result.schur_matrix ());
             }
           else
             {
               FloatSCHUR result (tmp, ord, true);
-              retval(1) = result.schur_matrix ();
-              retval(0) = result.unitary_matrix ();
+              retval = ovl (result.unitary_matrix (),
+                            result.schur_matrix ());
             }
         }
       else
         {
           FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
 
-          if (nargout == 0 || nargout == 1)
+          if (nargout <= 1)
             {
               FloatComplexSCHUR result (ctmp, ord, false);
-              retval(0) = mark_upper_triangular (result.schur_matrix ());
+              retval = ovl (mark_upper_triangular (result.schur_matrix ()));
             }
           else
             {
               FloatComplexSCHUR result (ctmp, ord, true);
-              retval(1) = mark_upper_triangular (result.schur_matrix ());
-              retval(0) = result.unitary_matrix ();
+              retval = ovl (result.unitary_matrix (),
+                            mark_upper_triangular (result.schur_matrix ()));
             }
         }
     }
@@ -218,32 +217,32 @@
         {
           Matrix tmp = arg.matrix_value ();
 
-          if (nargout == 0 || nargout == 1)
+          if (nargout <= 1)
             {
               SCHUR result (tmp, ord, false);
-              retval(0) = result.schur_matrix ();
+              retval = ovl (result.schur_matrix ());
             }
           else
             {
               SCHUR result (tmp, ord, true);
-              retval(1) = result.schur_matrix ();
-              retval(0) = result.unitary_matrix ();
+              retval = ovl (result.unitary_matrix (),
+                            result.schur_matrix ());
             }
         }
       else
         {
           ComplexMatrix ctmp = arg.complex_matrix_value ();
 
-          if (nargout == 0 || nargout == 1)
+          if (nargout <= 1)
             {
               ComplexSCHUR result (ctmp, ord, false);
-              retval(0) = mark_upper_triangular (result.schur_matrix ());
+              retval = ovl (mark_upper_triangular (result.schur_matrix ()));
             }
           else
             {
               ComplexSCHUR result (ctmp, ord, true);
-              retval(1) = mark_upper_triangular (result.schur_matrix ());
-              retval(0) = result.unitary_matrix ();
+              retval = ovl (result.unitary_matrix (),
+                            mark_upper_triangular (result.schur_matrix ()));
             }
         }
     }
--- a/libinterp/corefcn/spparms.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/spparms.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -113,12 +113,10 @@
       if (nargout == 0)
         octave_sparse_params::print_info (octave_stdout, "");
       else if (nargout == 1)
-        retval(0) =  octave_sparse_params::get_vals ();
+        retval = ovl (octave_sparse_params::get_vals ());
       else if (nargout == 2)
-        {
-          retval(1) = octave_sparse_params::get_vals ();
-          retval(0) = octave_sparse_params::get_keys ();
-        }
+        retval = ovl (octave_sparse_params::get_keys (),
+                      octave_sparse_params::get_vals ());
       else
         error ("spparms: too many output arguments");
     }
@@ -150,7 +148,7 @@
               if (xisnan (val))
                 error ("spparms: KEY not recognized");
               else
-                retval(0) = val;
+                retval = ovl (val);
             }
         }
       else
--- a/libinterp/corefcn/sqrtm.cc	Mon Dec 14 14:01:36 2015 +0000
+++ b/libinterp/corefcn/sqrtm.cc	Mon Dec 14 11:28:48 2015 -0800
@@ -212,8 +212,6 @@
 @seealso{expm, logm}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   if (args.length () != 1)
     print_usage ();
 
@@ -225,9 +223,12 @@
   if (n != nc || arg.ndims () > 2)
     gripe_square_matrix_required ("sqrtm");
 
+  octave_value_list retval (nargout > 1 ? 3 : 1);
+
   if (nargout > 1)
     {
-      retval.resize (1, 2);
+      // FIXME: Octave does not calculate a condition number with respect to
+      //        sqrtm.  Should this return NaN instead of -1?
       retval(2) = -1.0;
     }