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))
329 DEFUN (find, args, nargout,
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); \
619 OCTAVE_END_NAMESPACE(
octave)
charNDArray min(char d, const charNDArray &m)
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
bool isempty() const
Size of the specified dimension.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
octave_idx_type rows() const
octave_idx_type cols() const
const Array< octave_idx_type > & col_perm_vec() const
octave_idx_type cols() const
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
Vector representing the dimensions (size) of an Array.
dim_vector as_column() const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
octave::idx_vector index_vector(bool require_integers=false) const
bool is_perm_matrix() const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
bool is_single_type() const
charNDArray char_array_value(bool frc_str_conv=false) const
octave_value reshape(const dim_vector &dv) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
PermMatrix perm_matrix_value() const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) 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() 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