23 #if defined (HAVE_CONFIG_H) 47 idx = nda.
find (n_to_find, direction == -1);
68 jdx.xelem (
i) = idx.
xelem (
i) / nr;
110 else if (direction > 0)
116 if (v.
cidx (j) == 0 && v.
cidx (j+1) != 0)
118 if (v.
cidx (j+1) >= n_to_find)
131 if (v.
cidx (j) == nz && v.
cidx (j-1) != nz)
133 if (nz - v.
cidx (j-1) >= n_to_find)
141 count = (n_to_find > v.
cidx (end_nc) - v.
cidx (start_nc) ?
142 v.
cidx (end_nc) - v.
cidx (start_nc) : n_to_find);
160 Matrix idx (result_nr, result_nc);
162 Matrix i_idx (result_nr, result_nc);
163 Matrix j_idx (result_nr, result_nc);
176 if (direction < 0 &&
i < nz - count)
178 i_idx(cx) =
static_cast<double> (v.
ridx (
i) + 1);
179 j_idx(cx) =
static_cast<double> (j + 1);
180 idx(cx) = j * nr + v.
ridx (
i) + 1;
191 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
242 if (n_to_find < 0 || n_to_find >= nc)
247 else if (direction > 0)
254 start_nc = nc - n_to_find;
273 i_idx(
k) =
static_cast<double> (1+
i);
274 j_idx(
k) =
static_cast<double> (1+j);
275 idx(
k) = j * nc +
i + 1;
286 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
390 int nargin = args.length ();
399 double val = args(1).xscalar_value (
"find: N must be an integer");
403 error (
"find: N must be a non-negative integer");
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); \
octave_idx_type rows(void) const
octave_value_list find_nonzero_elem_idx(const Array< T > &nda, int nargout, octave_idx_type n_to_find, int direction)
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
bool islogical(void) const
OCTINTERP_API void print_usage(void)
idx_vector index_vector(bool require_integers=false) const
identity matrix If supplied two scalar respectively For allows like xample val
octave_idx_type * cidx(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
bool is_perm_matrix(void) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
charNDArray char_array_value(bool frc_str_conv=false) const
octave_idx_type nnz(void) const
Actual number of nonzero terms.
Array< T > index(const idx_vector &i) const
Indexing without resizing.
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_single_type(void) const
bool isinteger(void) const
bool issparse(void) const
#define panic_impossible()
octave_idx_type * ridx(void)
bool all_zero(void) const
#define DO_INT_BRANCH(INTT)
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
void err_wrong_type_arg(const char *name, const char *s)
With real return the complex result
const Array< octave_idx_type > & col_perm_vec(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)
T & xelem(octave_idx_type n)
octave_idx_type cols(void) const
N Dimensional Array with copy-on-write semantics.
boolNDArray bool_array_value(bool warn=false) const
bool isvector(void) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
idx_vector unmask(void) const
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
bool iscomplex(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
PermMatrix perm_matrix_value(void) const
bool is_string(void) const
octave_idx_type cols(void) const
octave_idx_type numel(void) const
Number of elements in the array.
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
dim_vector as_column(void) const
NDArray array_value(bool frc_str_conv=false) const
octave_idx_type rows(void) const
charNDArray min(char d, const charNDArray &m)