26#if defined (HAVE_CONFIG_H)
49 (*current_liboctave_error_handler) (
"invalid range used as index");
54 (*current_liboctave_error_handler)
55 (
"internal error: idx_vector index out of range");
66 (*current_liboctave_error_handler)
67 (
"internal error: as_array not allowed for this index class");
77 (*current_liboctave_error_handler)
78 (
"internal error: invalid character converted to idx_vector; must be ':'");
93 (*current_liboctave_error_handler)
94 (
"internal error: idx_colon_rep::sort_idx");
106 m_len (step ?
std::
max ((limit - start) / step,
127 if (r.all_elements_are_ints ())
139 double b = r.base ();
140 double inc = r.increment ();
149 if (i < 0 || i >=
m_len)
169 if (m_step < 0 && m_len > 0)
194 return range<double>::make_n_element_range
222 if (
static_cast<double> (i) !=
x)
233 template <
typename T>
241 template <
typename T>
290 template <
typename T>
293 m_aowner (nullptr), m_orig_dims (nda.dims ())
332 m_orig_dims (inda.dims ())
347 :
idx_base_rep (), m_data (nullptr), m_len (b ? 1 : 0), m_ext (0),
348 m_aowner (nullptr), m_orig_dims (m_len, m_len)
361 :
idx_base_rep (), m_data (nullptr), m_len (nnz), m_ext (0),
362 m_aowner (nullptr), m_orig_dims ()
389 :
idx_base_rep (), m_data (nullptr), m_len (bnda.nnz ()), m_ext (0),
390 m_aowner (nullptr), m_orig_dims ()
407 d[k++] = j * nr + bnda.
ridx (i);
426 if (n < 0 || n >=
m_len)
442 std::unique_ptr<idx_vector_rep> new_rep
449 new_rep->m_data = new_data;
460 new_rep->m_len = new_len;
461 if (new_rep->m_orig_dims.ndims () == 2 && new_rep->m_orig_dims(0) == 1)
462 new_rep->m_orig_dims =
dim_vector (1, new_len);
464 new_rep->m_orig_dims =
dim_vector (new_len, 1);
478 new_rep->m_len = new_len;
479 if (new_rep->m_orig_dims.ndims () == 2 && new_rep->m_orig_dims(0) == 1)
480 new_rep->m_orig_dims =
dim_vector (1, new_len);
482 new_rep->m_orig_dims =
dim_vector (new_len, 1);
485 new_rep->m_data = new_data;
499 new_rep->m_data = new_data;
508 return new_rep.release ();
515 std::unique_ptr<idx_vector_rep> new_rep
527 new_rep->m_data = new_data;
546 new_rep->m_data = new_data;
564 return new_rep.release ();
572 os <<
m_data[i] <<
',' <<
' ';
613 :
idx_base_rep (), m_data (nullptr), m_len (b ? 1 : 0), m_ext (0),
614 m_lsti (-1), m_lste (-1), m_aowner (nullptr), m_orig_dims (m_len, m_len)
618 bool *
d =
new bool [1];
628 m_lsti (-1), m_lste (-1), m_aowner (nullptr), m_orig_dims ()
673 if (n < 0 || n >=
m_len)
684 os <<
m_data[i] <<
',' <<
' ';
716 retval.
xelem (j++) = i;
741 if (nnz <= bnda.
numel () / factor)
750 bool reduced =
false;
852 if ((l*t == n && tj == 1) || (t == 0 && tj == 0))
1004 assert (r !=
nullptr);
1016 (*current_liboctave_error_handler) (
"colon not allowed");
1026 for (i = m_start, j = m_start + m_len; i < j; i++) *m_data++ = i;
1027 else if (m_step == -1)
1028 for (i = m_start, j = m_start - m_len; i > j; i--) *m_data++ = i;
1030 for (i = 0, j = m_start; i < m_len; i++, j += m_step) *m_data++ = j;
1045 std::copy_n (rdata, m_len, m_data);
1070 (*current_liboctave_error_handler)
1071 (
"internal error: out of range complement index requested");
1079 const bool *m_data = r->
get_data ();
1082 ndata[i] = ! m_data[i];
1083 std::fill_n (ndata + m_ext, n - m_ext,
true);
1098 bool retval =
false;
1126 assert (n ==
length (n));
1146 idx.
xelem (ri[i]) = i;
1163 const bool *m_data = r->
get_data ();
1172 m_ext = (m_len > 0 ? idata[m_len - 1] + 1 : 0);
1238 if (! resize_ok &&
extent (z_len) > z_len)
1239 (*current_liboctave_error_handler)
1240 (
"invalid matrix index = %" OCTAVE_IDX_TYPE_FORMAT,
extent (z_len));
1262#define INSTANTIATE_SCALAR_VECTOR_REP_CONST(T) \
1263 template OCTAVE_API idx_vector::idx_scalar_rep::idx_scalar_rep (T); \
1264 template OCTAVE_API idx_vector::idx_vector_rep::idx_vector_rep (const Array<T>&);
T & xelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_API void clear(void)
octave_idx_type numel(void) const
Number of elements in the array.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_API octave_idx_type nnz(void) const
Count nonzero elements.
const T * data(void) const
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_API Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
OCTARRAY_API void fill(const T &val)
octave_idx_type rows(void) const
dim_vector dims(void) const
octave_idx_type * ridx(void)
octave_idx_type * cidx(void)
octave_idx_type cols(void) const
Vector representing the dimensions (size) of an Array.
bool isvector(void) const
dim_vector make_nd_vector(octave_idx_type n) const
virtual Array< octave_idx_type > as_array(void)
virtual bool is_colon_equiv(octave_idx_type) const
virtual octave_idx_type length(octave_idx_type n) const =0
refcount< octave_idx_type > m_count
virtual idx_class_type idx_class(void) const
OCTAVE_API octave_idx_type checkelem(octave_idx_type i) const
OCTAVE_NORETURN idx_base_rep * sort_idx(Array< octave_idx_type > &)
OCTAVE_API std::ostream & print(std::ostream &os) const
idx_colon_rep(void)=default
octave_idx_type xelem(octave_idx_type i) const
OCTAVE_API ~idx_mask_rep(void)
OCTAVE_API idx_base_rep * sort_idx(Array< octave_idx_type > &)
idx_mask_rep(void)=delete
OCTAVE_API std::ostream & print(std::ostream &os) const
OCTAVE_API Array< bool > unconvert(void) const
const bool * get_data(void) const
octave_idx_type length(octave_idx_type) const
octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type extent(octave_idx_type n) const
OCTAVE_API Array< octave_idx_type > as_array(void)
dim_vector orig_dimensions(void) const
OCTAVE_API range< double > unconvert(void) const
OCTAVE_API idx_base_rep * sort_uniq_clone(bool uniq=false)
OCTAVE_API std::ostream & print(std::ostream &os) const
OCTAVE_API Array< octave_idx_type > as_array(void)
idx_range_rep(void)=delete
octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type length(octave_idx_type) const
OCTAVE_API idx_base_rep * sort_idx(Array< octave_idx_type > &)
octave_idx_type get_start(void) const
octave_idx_type get_step(void) const
idx_scalar_rep(void)=delete
OCTAVE_API idx_base_rep * sort_idx(Array< octave_idx_type > &)
octave_idx_type get_data(void) const
OCTAVE_API double unconvert(void) const
OCTAVE_API Array< octave_idx_type > as_array(void)
OCTAVE_API std::ostream & print(std::ostream &os) const
OCTAVE_API octave_idx_type checkelem(octave_idx_type i) const
const octave_idx_type * get_data(void) const
OCTAVE_API Array< double > unconvert(void) const
idx_base_rep * sort_uniq_clone(bool uniq=false)
Array< octave_idx_type > * m_aowner
const octave_idx_type * m_data
octave_idx_type xelem(octave_idx_type i) const
OCTAVE_API Array< octave_idx_type > as_array(void)
OCTAVE_API idx_base_rep * sort_idx(Array< octave_idx_type > &)
OCTAVE_API std::ostream & print(std::ostream &os) const
OCTAVE_API octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type extent(octave_idx_type n) const
OCTAVE_API void copy_data(octave_idx_type *data) const
OCTAVE_API octave_idx_type freeze(octave_idx_type z_len, const char *tag, bool resize_ok=false)
bool is_colon(void) const
OCTAVE_API Array< octave_idx_type > as_array(void) const
idx_vector sorted(bool uniq=false) const
octave_idx_type extent(octave_idx_type n) const
OCTAVE_API idx_vector inverse_permutation(octave_idx_type n) const
octave_idx_type max(void) const
octave_idx_type xelem(octave_idx_type n) const
idx_class_type idx_class(void) const
OCTAVE_API idx_vector complement(octave_idx_type n) const
OCTAVE_API bool maybe_reduce(octave_idx_type n, const idx_vector &j, octave_idx_type nj)
octave_idx_type elem(octave_idx_type n) const
OCTAVE_API octave_idx_type ones_count(void) const
OCTAVE_API bool isvector(void) const
OCTAVE_API bool is_cont_range(octave_idx_type n, octave_idx_type &l, octave_idx_type &u) const
static OCTAVE_API idx_vector_rep * nil_rep(void)
static const idx_vector colon
dim_vector orig_dimensions(void) const
octave_idx_type fill(const T &val, octave_idx_type n, T *dest) const
OCTAVE_API idx_vector unmask(void) const
OCTAVE_API octave_idx_type increment(void) const
OCTAVE_API void unconvert(idx_class_type &iclass, double &scalar, range< double > &range, Array< double > &array, Array< bool > &mask) const
octave_idx_type length(octave_idx_type n=0) const
OCTAVE_API bool is_permutation(octave_idx_type n) const
bool is_colon_equiv(octave_idx_type n) const
const OCTAVE_API octave_idx_type * raw(void)
void set_compare(const compare_fcn_type &comp)
void sort(T *data, octave_idx_type nel)
#define INSTANTIATE_SCALAR_VECTOR_REP_CONST(T)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
std::complex< T > trunc(const std::complex< T > &x)
Complex log2(const Complex &x)
static OCTAVE_NORETURN void err_index_out_of_range(void)
void err_invalid_index(const std::string &idx, octave_idx_type nd, octave_idx_type dim, const std::string &)
octave_idx_type convert_index(octave_idx_type i, octave_idx_type &ext)
static OCTAVE_NORETURN void err_invalid_range(void)
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
T::size_type numel(const T &str)
static bool scalar(const dim_vector &dims)