26 #if defined (HAVE_CONFIG_H)
49 template <
typename ArrayType>
52 int nargout,
int dim,
bool ismin)
55 ArrayType array = octave_value_extract<ArrayType> (arg);
60 retval(0) = array.min (dim);
62 retval(0) = array.max (dim);
68 retval(0) = array.min (idx, dim);
70 retval(0) = array.max (idx, dim);
89 int nargout,
int dim,
bool ismin)
119 int nargout,
int dim,
bool ismin)
133 retval(0) = array.
all (dim);
135 retval(0) = array.
any (dim);
140 retval = do_minmax_red_op<int8NDArray> (arg, nargout, dim, ismin);
142 retval(0) = retval(0).bool_array_value ();
149 retval = do_minmax_red_op<SparseMatrix> (arg, nargout, dim, ismin);
151 retval(0) = retval(0).sparse_bool_matrix_value ();
157 template <
typename ArrayType>
162 typedef typename ArrayType::element_type ScalarType;
168 ScalarType
x = octave_value_extract<ScalarType> (argx);
169 ArrayType y = octave_value_extract<ArrayType> (argy);
178 ArrayType
x = octave_value_extract<ArrayType> (argx);
179 ScalarType y = octave_value_extract<ScalarType> (argy);
188 ArrayType
x = octave_value_extract<ArrayType> (argx);
189 ArrayType y = octave_value_extract<ArrayType> (argy);
222 else if (y.
numel () == 1)
231 else if (y.
numel () == 1)
242 int nargout,
bool ismin)
244 int nargin = args.
length ();
246 if (nargin < 1 || nargin > 3)
251 const char *fcn = (ismin ?
"min" :
"max");
253 if (nargin == 3 || nargin == 1)
259 dim = args(2).int_value (
true) - 1;
262 error (
"%s: DIM must be a valid dimension", fcn);
264 if (! args(1).isempty ())
265 warning (
"%s: second argument is ignored", fcn);
272 if (arg.
is_range () && (dim == -1 || dim == 1))
275 if (
range.numel () < 1)
283 retval(0) =
range.min ();
285 retval(1) =
static_cast<double>
286 (
range.increment () < 0 ?
range.numel () : 1);
290 retval(0) =
range.max ();
292 retval(1) =
static_cast<double>
298 retval = do_minmax_red_op<SparseMatrix> (arg, nargout, dim,
301 retval = do_minmax_red_op<NDArray> (arg, nargout, dim, ismin);
309 retval = do_minmax_red_op<SparseComplexMatrix> (arg, nargout, dim,
312 retval = do_minmax_red_op<ComplexNDArray> (arg, nargout, dim,
318 retval = do_minmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
322 retval = do_minmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
330 #define MAKE_INT_BRANCH(X) \
332 retval = do_minmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
344 #undef MAKE_INT_BRANCH
376 retval = do_minmax_bin_op<SparseMatrix> (argx, argy, ismin);
378 retval = do_minmax_bin_op<NDArray> (argx, argy, ismin);
387 retval = do_minmax_bin_op<SparseComplexMatrix> (argx, argy,
390 retval = do_minmax_bin_op<ComplexNDArray> (argx, argy, ismin);
395 retval = do_minmax_bin_op<FloatNDArray> (argx, argy, ismin);
399 retval = do_minmax_bin_op<FloatComplexNDArray> (argx, argy, ismin);
406 #define MAKE_INT_BRANCH(X) \
408 retval = do_minmax_bin_op<X ## NDArray> (argx, argy, ismin); \
420 #undef MAKE_INT_BRANCH
428 error (
"%s: cannot compute %s (%s, %s)", fcn, fcn,
509 return do_minmax_body (args, nargout,
true);
731 return do_minmax_body (args, nargout,
false);
889 template <
typename ArrayType>
892 int nargout,
int dim,
bool ismin)
895 ArrayType array = octave_value_extract<ArrayType> (arg);
900 retval(0) = array.cummin (dim);
902 retval(0) = array.cummax (dim);
909 retval(0) = array.cummin (idx, dim);
911 retval(0) = array.cummax (idx, dim);
921 int nargout,
bool ismin)
923 int nargin = args.
length ();
925 if (nargin < 1 || nargin > 2)
928 const char *fcn = (ismin ?
"cummin" :
"cummax");
934 dim = args(1).int_value (
true) - 1;
937 error (
"%s: DIM must be a valid dimension", fcn);
945 retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
949 retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
954 retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
958 retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
962 #define MAKE_INT_BRANCH(X) \
964 retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
976 #undef MAKE_INT_BRANCH
980 retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
983 retval(0) = retval(0).bool_array_value ();
994 DEFUN (cummin, args, nargout,
1026 return do_cumminmax_body (args, nargout,
true);
1049 DEFUN (cummax, args, nargout,
1081 return do_cumminmax_body (args, nargout,
false);
1104 OCTAVE_END_NAMESPACE(
octave)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
bool isempty() const
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
boolNDArray any(int dim=-1) const
boolNDArray all(int dim=-1) const
charNDArray max(int dim=-1) const
charNDArray min(int dim=-1) const
octave_idx_type length() const
boolNDArray bool_array_value(bool warn=false) const
bool is_scalar_type() const
octave::range< double > range_value() const
std::string type_name() const
octave_value resize(const dim_vector &dv, bool fill=false) const
builtin_type_t builtin_type() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void() error(const char *fmt,...)
void err_wrong_type_arg(const char *name, const char *s)
F77_RET_T const F77_DBLE * x
octave_value do_minmax_bin_op< charNDArray >(const octave_value &argx, const octave_value &argy, bool ismin)
#define MAKE_INT_BRANCH(X)
octave_value_list do_minmax_red_op< boolNDArray >(const octave_value &arg, int nargout, int dim, bool ismin)
octave_value_list do_minmax_red_op< charNDArray >(const octave_value &arg, int nargout, int dim, bool ismin)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
Determine the resulting type for a possible mixed-type operation.
charNDArray octave_value_extract< charNDArray >(const octave_value &v)