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)
115 if (v.
cidx (j) == 0 && v.
cidx (j+1) != 0)
117 if (v.
cidx (j+1) >= n_to_find)
129 if (v.
cidx (j) == nz && v.
cidx (j-1) != nz)
131 if (nz - v.
cidx (j-1) >= n_to_find)
139 count = (n_to_find > v.
cidx (end_nc) - v.
cidx (start_nc) ?
140 v.
cidx (end_nc) - v.
cidx (start_nc) : n_to_find);
158 Matrix idx (result_nr, result_nc);
160 Matrix i_idx (result_nr, result_nc);
161 Matrix j_idx (result_nr, result_nc);
173 if (direction < 0 &&
i < nz - count)
175 i_idx(cx) =
static_cast<double> (v.
ridx (
i) + 1);
176 j_idx(cx) =
static_cast<double> (j + 1);
177 idx(cx) = j * nr + v.
ridx (
i) + 1;
188 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
239 if (n_to_find < 0 || n_to_find >= nc)
244 else if (direction > 0)
251 start_nc = nc - n_to_find;
269 i_idx(k) =
static_cast<double> (1+
i);
270 j_idx(k) =
static_cast<double> (1+j);
271 idx(k) = j * nc + i + 1;
282 if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1))
388 if (nargin < 1 || nargin > 3)
395 double val =
args(1).xscalar_value (
"find: N must be an integer");
399 error (
"find: N must be a non-negative integer");
412 if (s_arg ==
"first")
414 else if (s_arg ==
"last")
417 error (
"find: DIRECTION must be \"first\" or \"last\"");
432 else if (
nargout <= 1 && n_to_find == -1 && direction == 1)
450 #define DO_INT_BRANCH(INTT) \
451 else if (arg.is_ ## INTT ## _type ()) \
453 INTT ## NDArray v = arg.INTT ## _array_value (); \
455 retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction); \
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
bool is_empty(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 cols(void) const
charNDArray char_array_value(bool frc_str_conv=false) const
bool is_real_type(void) const
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
octave_idx_type rows(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
identity matrix If supplied two scalar respectively For allows like xample val
octave_idx_type cols(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
bool is_perm_matrix(void) const
octave_idx_type * cidx(void)
boolNDArray bool_array_value(bool warn=false) const
octave_idx_type rows(void) const
octave_idx_type nnz(void) const
Actual number of nonzero terms.
idx_vector index_vector(bool require_integers=false) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
FloatNDArray float_array_value(bool frc_str_conv=false) const
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)
idx_vector unmask(void) const
bool is_sparse_type(void) const
bool is_bool_type(void) const
OCTAVE_EXPORT octave_value_list uint32
const Array< octave_idx_type > & col_perm_vec(void) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
bool is_string(void) const
OCTAVE_EXPORT octave_value_list int16
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
bool is_complex_type(void) const
void resize(const dim_vector &dv, const T &rfv)
#define panic_impossible()
OCTAVE_EXPORT octave_value_list int32
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
#define DO_INT_BRANCH(INTT)
void err_wrong_type_arg(const char *name, const char *s)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
T & xelem(octave_idx_type n)
OCTAVE_EXPORT octave_value_list int64
N Dimensional Array with copy-on-write semantics.
NDArray array_value(bool frc_str_conv=false) const
octave_idx_type * ridx(void)
=val(i)}if ode{val(i)}occurs in table i
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
PermMatrix perm_matrix_value(void) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool is_single_type(void) 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
Array< T > index(const idx_vector &i) const
Indexing without resizing.
charNDArray min(char d, const charNDArray &m)
bool is_integer_type(void) const