26 #if defined (HAVE_CONFIG_H)
50 idx = nda.
find (n_to_find, direction == -1);
112 else if (direction > 0)
118 if (v.
cidx (j) == 0 && v.
cidx (j+1) != 0)
120 if (v.
cidx (j+1) >= n_to_find)
133 if (v.
cidx (j) == nz && v.
cidx (j-1) != nz)
135 if (nz - v.
cidx (j-1) >= n_to_find)
143 count = (n_to_find > v.
cidx (end_nc) - v.
cidx (start_nc) ?
144 v.
cidx (end_nc) - v.
cidx (start_nc) : n_to_find);
162 Matrix idx (result_nr, result_nc);
164 Matrix i_idx (result_nr, result_nc);
165 Matrix j_idx (result_nr, result_nc);
178 if (direction < 0 && i < nz - count)
180 i_idx(cx) =
static_cast<double> (v.
ridx (i) + 1);
181 j_idx(cx) =
static_cast<double> (j + 1);
182 idx(cx) = j * nr + v.
ridx (i) + 1;
193 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
244 if (n_to_find < 0 || n_to_find >= nc)
249 else if (direction > 0)
256 start_nc = nc - n_to_find;
275 i_idx(k) =
static_cast<double> (1+i);
276 j_idx(k) =
static_cast<double> (1+j);
277 idx(k) = j * nc + i + 1;
288 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
392 int nargin = args.length ();
394 if (nargin < 1 || nargin > 3)
401 double val = args(1).xscalar_value (
"find: N must be an integer");
405 error (
"find: N must be a non-negative integer");
414 std::string s_arg = args(2).string_value ();
416 if (s_arg ==
"first")
418 else if (s_arg ==
"last")
421 error (R
"(find: DIRECTION must be "first" or "last")");
436 else if (nargout <= 1 && n_to_find == -1 && direction == 1)
461 #define DO_INT_BRANCH(INTT) \
462 else if (arg.is_ ## INTT ## _type ()) \
464 INTT ## NDArray v = arg.INTT ## _array_value (); \
466 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction); \
charNDArray min(char d, const charNDArray &m)
N Dimensional Array with copy-on-write semantics.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
octave_idx_type rows(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
bool isempty(void) const
Size of the specified dimension.
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
const Array< octave_idx_type > & col_perm_vec(void) const
octave_idx_type cols(void) const
octave_idx_type rows(void) const
octave_idx_type cols(void) const
octave_idx_type * cidx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type rows(void) const
octave_idx_type * ridx(void)
Vector representing the dimensions (size) of an Array.
bool isvector(void) const
dim_vector as_column(void) const
bool all_zero(void) const
idx_vector unmask(void) const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool issparse(void) const
bool is_string(void) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
charNDArray char_array_value(bool frc_str_conv=false) const
bool isinteger(void) const
octave_value reshape(const dim_vector &dv) const
PermMatrix perm_matrix_value(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
bool is_single_type(void) const
idx_vector index_vector(bool require_integers=false) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_perm_matrix(void) const
bool iscomplex(void) const
bool islogical(void) const
dim_vector dims(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
#define panic_impossible()
void err_wrong_type_arg(const char *name, const char *s)
octave_value_list find_nonzero_elem_idx(const Array< T > &nda, int nargout, octave_idx_type n_to_find, int direction)
#define DO_INT_BRANCH(INTT)
octave_value::octave_value(const Array< char > &chm, char type) return retval