Mercurial > octave
diff libinterp/corefcn/max.cc @ 20892:c07bee629973
2015 Code Sprint: use ovl ().
author | Rik <rik@octave.org> |
---|---|
date | Mon, 14 Dec 2015 11:28:48 -0800 |
parents | 1142cf6abc0d |
children | 4d3daf7e43f3 |
line wrap: on
line diff
--- 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: