26 #if defined (HAVE_CONFIG_H)
47 template <
typename ArrayType>
50 int nargout,
int dim,
bool ismin)
53 ArrayType array = octave_value_extract<ArrayType> (arg);
58 retval(0) = array.min (dim);
60 retval(0) = array.max (dim);
66 retval(0) = array.min (idx, dim);
68 retval(0) = array.max (idx, dim);
87 int nargout,
int dim,
bool ismin)
117 int nargout,
int dim,
bool ismin)
138 retval = do_minmax_red_op<int8NDArray> (arg, nargout, dim, ismin);
147 retval = do_minmax_red_op<SparseMatrix> (arg, nargout, dim, ismin);
155 template <
typename ArrayType>
160 typedef typename ArrayType::element_type ScalarType;
166 ScalarType
x = octave_value_extract<ScalarType> (argx);
167 ArrayType y = octave_value_extract<ArrayType> (argy);
176 ArrayType
x = octave_value_extract<ArrayType> (argx);
177 ScalarType y = octave_value_extract<ScalarType> (argy);
186 ArrayType
x = octave_value_extract<ArrayType> (argx);
187 ArrayType y = octave_value_extract<ArrayType> (argy);
220 else if (y.
numel () == 1)
229 else if (y.
numel () == 1)
240 int nargout,
bool ismin)
242 int nargin = args.
length ();
244 if (nargin < 1 || nargin > 3)
249 const char *func = (ismin ?
"min" :
"max");
251 if (nargin == 3 || nargin == 1)
257 dim = args(2).int_value (
true) - 1;
260 error (
"%s: DIM must be a valid dimension", func);
262 if (! args(1).isempty ())
263 warning (
"%s: second argument is ignored", func);
270 if (arg.
is_range () && (dim == -1 || dim == 1))
273 if (range.
numel () < 1)
283 retval(1) =
static_cast<double>
284 (range.
inc () < 0 ? range.
numel () : 1);
290 retval(1) =
static_cast<double>
291 (range.
inc () >= 0 ? range.
numel () : 1);
295 retval = do_minmax_red_op<SparseMatrix> (arg, nargout, dim,
298 retval = do_minmax_red_op<NDArray> (arg, nargout, dim, ismin);
306 retval = do_minmax_red_op<SparseComplexMatrix> (arg, nargout, dim,
309 retval = do_minmax_red_op<ComplexNDArray> (arg, nargout, dim,
315 retval = do_minmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
319 retval = do_minmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
327 #define MAKE_INT_BRANCH(X) \
329 retval = do_minmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
341 #undef MAKE_INT_BRANCH
373 retval = do_minmax_bin_op<SparseMatrix> (argx, argy, ismin);
375 retval = do_minmax_bin_op<NDArray> (argx, argy, ismin);
384 retval = do_minmax_bin_op<SparseComplexMatrix> (argx, argy,
387 retval = do_minmax_bin_op<ComplexNDArray> (argx, argy, ismin);
392 retval = do_minmax_bin_op<FloatNDArray> (argx, argy, ismin);
396 retval = do_minmax_bin_op<FloatComplexNDArray> (argx, argy, ismin);
403 #define MAKE_INT_BRANCH(X) \
405 retval = do_minmax_bin_op<X ## NDArray> (argx, argy, ismin); \
417 #undef MAKE_INT_BRANCH
425 error (
"%s: cannot compute %s (%s, %s)", func, func,
886 template <
typename ArrayType>
889 int nargout,
int dim,
bool ismin)
892 ArrayType array = octave_value_extract<ArrayType> (arg);
897 retval(0) = array.cummin (dim);
899 retval(0) = array.cummax (dim);
906 retval(0) = array.cummin (idx, dim);
908 retval(0) = array.cummax (idx, dim);
918 int nargout,
bool ismin)
920 int nargin = args.
length ();
922 if (nargin < 1 || nargin > 2)
925 const char *func = (ismin ?
"cummin" :
"cummax");
931 dim = args(1).int_value (
true) - 1;
934 error (
"%s: DIM must be a valid dimension", func);
942 retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
946 retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
951 retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
955 retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
959 #define MAKE_INT_BRANCH(X) \
961 retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
973 #undef MAKE_INT_BRANCH
977 retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
991 DEFUN (cummin, args, nargout,
1046 DEFUN (cummax, args, nargout,
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
bool isempty(void) const
Size of the specified dimension.
octave_idx_type numel(void) const
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(void) const
boolNDArray bool_array_value(bool warn=false) const
bool issparse(void) const
builtin_type_t builtin_type(void) const
bool is_scalar_type(void) const
Range range_value(void) const
bool is_range(void) const
std::string type_name(void) const
OCTINTERP_API void print_usage(void)
#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
static octave_value_list do_minmax_body(const octave_value_list &args, int nargout, bool ismin)
octave_value do_minmax_bin_op< charNDArray >(const octave_value &argx, const octave_value &argy, bool ismin)
#define MAKE_INT_BRANCH(X)
static octave_value_list do_cumminmax_red_op(const octave_value &arg, int nargout, int dim, bool ismin)
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)
static octave_value_list do_cumminmax_body(const octave_value_list &args, int nargout, bool ismin)
static octave_value_list do_minmax_red_op(const octave_value &arg, int nargout, int dim, bool ismin)
static octave_value do_minmax_bin_op(const octave_value &argx, const octave_value &argy, 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.
octave_value::octave_value(const Array< char > &chm, char type) return retval
charNDArray octave_value_extract< charNDArray >(const octave_value &v)