26 #if defined (HAVE_CONFIG_H)
52 idx = nda.
find (n_to_find, direction == -1);
115 else if (direction > 0)
121 if (v.
cidx (j) == 0 && v.
cidx (j+1) != 0)
123 if (v.
cidx (j+1) >= n_to_find)
136 if (v.
cidx (j) == nz && v.
cidx (j-1) != nz)
138 if (nz - v.
cidx (j-1) >= n_to_find)
146 count = (n_to_find > v.
cidx (end_nc) - v.
cidx (start_nc) ?
147 v.
cidx (end_nc) - v.
cidx (start_nc) : n_to_find);
165 Matrix idx (result_nr, result_nc);
167 Matrix i_idx (result_nr, result_nc);
168 Matrix j_idx (result_nr, result_nc);
181 if (direction < 0 && i < nz - count)
183 i_idx(cx) =
static_cast<double> (v.
ridx (i) + 1);
184 j_idx(cx) =
static_cast<double> (j + 1);
185 idx(cx) = j * nr + v.
ridx (i) + 1;
196 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
247 if (n_to_find < 0 || n_to_find >= nc)
252 else if (direction > 0)
259 start_nc = nc - n_to_find;
278 i_idx(k) =
static_cast<double> (1+i);
279 j_idx(k) =
static_cast<double> (1+j);
280 idx(k) = j * nc + i + 1;
291 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
399 int nargin = args.length ();
401 if (nargin < 1 || nargin > 3)
408 double val = args(1).xscalar_value (
"find: N must be an integer");
412 error (
"find: N must be a non-negative integer");
421 std::string s_arg = args(2).string_value ();
423 if (s_arg ==
"first")
425 else if (s_arg ==
"last")
428 error (R
"(find: DIRECTION must be "first" or "last")");
443 else if (nargout <= 1 && n_to_find == -1 && direction == 1)
468 #define DO_INT_BRANCH(INTT) \
469 else if (arg.is_ ## INTT ## _type ()) \
471 INTT ## NDArray v = arg.INTT ## _array_value (); \
473 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction); \
charNDArray min(char d, const charNDArray &m)
OCTARRAY_API Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
OCTARRAY_OVERRIDABLE_FUNC_API bool isempty(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_API Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
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 rows(void) const
octave_idx_type * cidx(void)
octave_idx_type * ridx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type cols(void) const
Vector representing the dimensions (size) of an Array.
bool isvector(void) const
dim_vector as_column(void) const
bool all_zero(void) const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool issparse(void) const
octave::idx_vector index_vector(bool require_integers=false) 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
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)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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::idx_vector idx_vector