24 #if defined (HAVE_CONFIG_H)
44 template <
typename ArrayType>
47 int nargout,
int dim,
bool ismin)
50 ArrayType
array = octave_value_extract<ArrayType> (
arg);
55 retval(0) = array.min (dim);
57 retval(0) = array.max (dim);
63 retval(0) = array.min (idx, dim);
65 retval(0) = array.max (idx, dim);
84 int nargout,
int dim,
bool ismin)
114 int nargout,
int dim,
bool ismin)
135 retval = do_minmax_red_op<int8NDArray> (
arg,
nargout, dim, ismin);
144 retval = do_minmax_red_op<SparseMatrix> (
arg,
nargout, dim, ismin);
152 template <
typename ArrayType>
157 typedef typename ArrayType::element_type ScalarType;
163 ScalarType
x = octave_value_extract<ScalarType> (argx);
164 ArrayType
y = octave_value_extract<ArrayType> (argy);
173 ArrayType
x = octave_value_extract<ArrayType> (argx);
174 ScalarType
y = octave_value_extract<ScalarType> (argy);
183 ArrayType
x = octave_value_extract<ArrayType> (argx);
184 ArrayType
y = octave_value_extract<ArrayType> (argy);
217 else if (y.numel () == 1)
226 else if (y.numel () == 1)
241 if (nargin < 1 || nargin > 3)
246 const char *func = ismin ?
"min" :
"max";
248 if (nargin == 3 || nargin == 1)
254 dim =
args(2).int_value (
true) - 1;
257 error (
"%s: DIM must be a valid dimension", func);
259 if (!
args(1).is_empty ())
260 warning (
"%s: second argument is ignored", func);
267 if (arg.
is_range () && (dim == -1 || dim == 1))
270 if (range.
numel () < 1)
280 retval(1) =
static_cast<double>
281 (range.
inc () < 0 ? range.
numel () : 1);
287 retval(1) =
static_cast<double>
288 (range.
inc () >= 0 ? range.
numel () : 1);
292 retval = do_minmax_red_op<SparseMatrix> (arg, nargout, dim,
295 retval = do_minmax_red_op<NDArray> (
arg,
nargout, dim, ismin);
303 retval = do_minmax_red_op<SparseComplexMatrix> (arg, nargout, dim,
306 retval = do_minmax_red_op<ComplexNDArray> (
arg,
nargout, dim,
312 retval = do_minmax_red_op<FloatNDArray> (
arg,
nargout, dim, ismin);
316 retval = do_minmax_red_op<FloatComplexNDArray> (
arg,
nargout, dim,
324 #define MAKE_INT_BRANCH(X) \
326 retval = do_minmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
338 #undef MAKE_INT_BRANCH
370 retval = do_minmax_bin_op<SparseMatrix> (argx, argy, ismin);
372 retval = do_minmax_bin_op<NDArray> (argx, argy, ismin);
381 retval = do_minmax_bin_op<SparseComplexMatrix> (argx, argy,
384 retval = do_minmax_bin_op<ComplexNDArray> (argx, argy, ismin);
389 retval = do_minmax_bin_op<FloatNDArray> (argx, argy, ismin);
393 retval = do_minmax_bin_op<FloatComplexNDArray> (argx, argy, ismin);
400 #define MAKE_INT_BRANCH(X) \
402 retval = do_minmax_bin_op<X ## NDArray> (argx, argy, ismin); \
414 #undef MAKE_INT_BRANCH
422 error (
"%s: cannot compute %s (%s, %s)", func, func,
423 argx.type_name ().c_str (), argy.type_name ().c_str ());
881 template <
typename ArrayType>
884 int nargout,
int dim,
bool ismin)
887 ArrayType
array = octave_value_extract<ArrayType> (
arg);
892 retval(0) = array.cummin (dim);
894 retval(0) = array.cummax (dim);
901 retval(0) = array.cummin (idx, dim);
903 retval(0) = array.cummax (idx, dim);
913 int nargout,
bool ismin)
917 if (nargin < 1 || nargin > 2)
920 const char *func = ismin ?
"cummin" :
"cummax";
926 dim =
args(1).int_value (
true) - 1;
929 error (
"%s: DIM must be a valid dimension", func);
937 retval = do_cumminmax_red_op<NDArray> (
arg,
nargout, dim, ismin);
941 retval = do_cumminmax_red_op<ComplexNDArray> (
arg,
nargout, dim,
946 retval = do_cumminmax_red_op<FloatNDArray> (
arg,
nargout, dim, ismin);
950 retval = do_cumminmax_red_op<FloatComplexNDArray> (
arg,
nargout, dim,
954 #define MAKE_INT_BRANCH(X) \
956 retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
968 #undef MAKE_INT_BRANCH
972 retval = do_cumminmax_red_op<int8NDArray> (
arg,
nargout, dim,
986 DEFUN (cummin, args, nargout,
1018 return do_cumminmax_body (args, nargout,
true);
1041 DEFUN (cummax, args, nargout,
1073 return do_cumminmax_body (args, nargout,
false);
boolNDArray all(int dim=-1) const
charNDArray max(int dim=-1) const
bool is_empty(void) const
bool is_range(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
OCTAVE_EXPORT octave_value_list uint16
octave_idx_type length(void) const
bool is_scalar_type(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
boolNDArray any(int dim=-1) const
octave_value resize(const dim_vector &dv, bool fill=false) const
boolNDArray bool_array_value(bool warn=false) const
octave_value_list do_minmax_red_op< boolNDArray >(const octave_value &arg, int nargout, int dim, bool ismin)
builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
bool is_sparse_type(void) const
OCTAVE_EXPORT octave_value_list uint32
then the function must return scalars which will be concatenated into the return array(s).If code
Range range_value(void) const
static octave_value_list do_minmax_body(const octave_value_list &args, int nargout, bool ismin)
OCTAVE_EXPORT octave_value_list int16
octave_idx_type numel(void) const
static octave_value do_minmax_bin_op(const octave_value &argx, const octave_value &argy, bool ismin)
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
OCTAVE_EXPORT octave_value_list int32
charNDArray octave_value_extract< charNDArray >(const octave_value &v)
static octave_value_list do_minmax_red_op(const octave_value &arg, int nargout, int dim, bool ismin)
void err_wrong_type_arg(const char *name, const char *s)
#define MAKE_INT_BRANCH(X)
OCTAVE_EXPORT octave_value_list int64
void warning(const char *fmt,...)
charNDArray max(char d, const charNDArray &m)
charNDArray min(int dim=-1) const
the element is set to zero In other the statement xample y
octave_value do_minmax_bin_op< charNDArray >(const octave_value &argx, const octave_value &argy, bool ismin)
builtin_type_t builtin_type(void) const
octave_value_list do_minmax_red_op< charNDArray >(const octave_value &arg, int nargout, int dim, bool ismin)
OCTAVE_EXPORT octave_value_list or cell arrays Arguments are concatenated vertically The returned values are padded with blanks as needed to make each row of the string array have the same length Empty input strings are significant and will concatenated in the output For numerical each element is converted to the corresponding ASCII character A range error results if an input is outside the ASCII range(0-255).For cell arrays
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
charNDArray min(char d, const charNDArray &m)