46 (*current_liboctave_error_handler)
47 (
"invalid range used as index");
53 (*current_liboctave_error_handler)
54 (
"internal error: idx_vector index out of range");
60 (*current_liboctave_error_handler)
61 (
"internal error: as_array not allowed for this index class");
71 (*current_liboctave_error_handler)
72 (
"internal error: invalid character converted to idx_vector; must be ':'");
92 (*current_liboctave_error_handler)
93 (
"internal error: idx_colon_rep::sort_idx");
109 : start(_start), len (_step ?
std::
max ((_limit - _start) / _step, static_cast<
octave_idx_type> (0)) : -1), step (_step)
124 : start (0), len (r.
nelem ()), step (1)
154 if (i < 0 || i >= len)
160 return start + i*step;
178 if (step < 0 && len > 0)
182 idx.
xelem (i) = len - 1 - i;
198 os << start <<
':' << step <<
':' << start + len*step;
205 return Range (static_cast<double> (start+1),
206 static_cast<double> (step), len);
214 retval.
xelem (i) = start + i*step;
237 if (static_cast<double> (i) !=
x)
246 return convert_index (static_cast<double> (x), conv_error, ext);
320 :
data (0), len (nda.
numel ()), ext (0), aowner (0), orig_dims (nda.
dims ())
380 :
data (0), len (b ? 1 : 0), ext (0), aowner (0), orig_dims (len, len)
393 :
data (0), len (nnz), ext (0), aowner (0), orig_dims ()
422 :
data (0), len (bnda.
nnz ()), ext (0), aowner (0), orig_dims ()
441 d[k++] = j * nr + bnda.
ridx (i);
460 if (n < 0 || n >= len)
479 std::auto_ptr<idx_vector_rep> new_rep (
482 if (ext > len*
xlog2 (1.0 + len))
486 new_rep->
data = new_data;
488 std::copy (
data,
data + len, new_data);
491 lsort.
sort (new_data, len);
497 new_rep->
len = new_len;
515 new_rep->
len = new_len;
522 new_rep->
data = new_data;
536 new_rep->
data = new_data;
545 return new_rep.release ();
552 std::auto_ptr<idx_vector_rep> new_rep (
555 if (ext > len*
xlog2 (1.0 + len))
558 idx.
clear (orig_dims);
564 new_rep->
data = new_data;
565 std::copy (
data,
data + len, new_data);
569 lsort.
sort (new_data, idx_data, len);
579 idx.
clear (orig_dims);
583 new_rep->
data = new_data;
601 return new_rep.release ();
610 os <<
data[ii] <<
',' <<
' ';
613 os <<
data[len-1]; os <<
']';
646 :
data (0), len (b ? 1 : 0), ext (0), lsti (-1), lste (-1),
647 aowner (0), orig_dims (len, len)
651 bool *
d =
new bool [1];
660 :
data (0), len (nnz), ext (bnda.
numel ()), lsti (-1), lste (-1),
661 aowner (0), orig_dims ()
668 while (
ext > 0 && ! bnda(
ext-1))
695 while (!
data[++lste]) ;
702 if (
data[++lste]) --n;
710 if (n < 0 || n >= len)
725 os <<
data[ii] <<
',' <<
' ';
728 os <<
data[ext-1]; os <<
']';
757 retval.
xelem (j++) = i;
782 if (nnz <= bnda.
numel () / factor)
792 bool reduced =
false;
894 if ((l*t == n && tj == 1) || (t == 0 && tj == 0))
1072 for (i = start, j = start + len; i < j; i++) *data++ = i;
1073 else if (step == -1)
1074 for (i = start, j = start - len; i > j; i--) *data++ = i;
1076 for (i = 0, j = start; i < len; i++, j += step) *data++ = j;
1091 std::copy (rdata, rdata + len, data);
1117 (*current_liboctave_error_handler)
1118 (
"internal error: out of range complement index requested");
1129 ndata[i] = ! data[i];
1147 bool retval =
false;
1176 assert (n ==
length (n));
1196 idx.
xelem (ri[i]) = i;
1223 ext = len > 0 ? idata[len - 1] + 1 : 0;
1291 if (! resize_ok &&
extent (z_len) > z_len)
1293 (*current_liboctave_error_handler)
1294 (
"invalid matrix index = %d",
extent (z_len));
1320 #define INSTANTIATE_SCALAR_VECTOR_REP_CONST(T) \
1321 template OCTAVE_API idx_vector::idx_scalar_rep::idx_scalar_rep (T); \
1322 template OCTAVE_API idx_vector::idx_vector_rep::idx_vector_rep (const Array<T>&);
octave_idx_type elem(octave_idx_type n) const
virtual Array< octave_idx_type > as_array(void)
idx_base_rep * sort_uniq_clone(bool uniq=false)
octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type cols(void) const
octave_idx_type extent(octave_idx_type n) const
idx_base_rep * sort_idx(Array< octave_idx_type > &)
octave_idx_type length(octave_idx_type n=0) const
octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type rows(void) const
idx_base_rep * sort_idx(Array< octave_idx_type > &)
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
dim_vector dims(void) const
bool is_vector(void) const
static const idx_vector colon
octave_idx_type numel(void) const
Number of elements in the array.
Array< octave_idx_type > as_array(void)
void set_compare(compare_fcn_type comp)
octave_idx_type checkelem(octave_idx_type i) const
octave_idx_type max(void) const
dim_vector orig_dimensions(void) const
octave_idx_type xelem(octave_idx_type n) const
octave_idx_type get_step(void) const
octave_idx_type fill(const T &val, octave_idx_type n, T *dest) const
octave_idx_type get_start(void) const
octave_idx_type * cidx(void)
Range unconvert(void) const
Array< bool > unconvert(void) const
std::ostream & print(std::ostream &os) const
void gripe_invalid_index(void)
F77_RET_T const double const double double * d
Array< octave_idx_type > as_array(void)
idx_vector inverse_permutation(octave_idx_type n) const
octave_idx_type convert_index(octave_idx_type i, bool &conv_error, octave_idx_type &ext)
idx_base_rep * sort_idx(Array< octave_idx_type > &)
octave_idx_type length(octave_idx_type) const
octave_idx_type nelem(void) const
Number of elements in the array.
virtual bool is_colon_equiv(octave_idx_type) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
dim_vector orig_dimensions(void) const
std::ostream & print(std::ostream &os) const
liboctave_error_handler current_liboctave_error_handler
void copy_data(octave_idx_type *data) const
idx_vector unmask(void) const
Array< double > unconvert(void) const
idx_vector complement(octave_idx_type n) const
idx_base_rep * sort_uniq_clone(bool uniq=false)
std::ostream & print(std::ostream &os) const
static void gripe_index_out_of_range(void)
octave_idx_type length(octave_idx_type) const
const FloatComplex * data(void) const
bool is_vector(void) const
octave_idx_type checkelem(octave_idx_type i) const
static void gripe_invalid_range(void)
virtual idx_class_type idx_class(void) const
octave_idx_type ones_count(void) const
octave_idx_type extent(octave_idx_type n) const
Array< octave_idx_type > as_array(void)
bool is_cont_range(octave_idx_type n, octave_idx_type &l, octave_idx_type &u) const
#define INSTANTIATE_SCALAR_VECTOR_REP_CONST(T)
bool is_permutation(octave_idx_type n) const
double unconvert(void) const
idx_base_rep * sort_idx(Array< octave_idx_type > &)
bool all_zero(void) const
octave_idx_type nnz(void) const
Count nonzero elements.
Array< octave_idx_type > as_array(void) const
T & xelem(octave_idx_type n)
bool is_colon_equiv(octave_idx_type n) const
idx_class_type idx_class(void) const
octave_idx_type length(void) const
Number of elements in the array.
octave_idx_type extent(octave_idx_type n) const
void sort(T *data, octave_idx_type nel)
octave_idx_type * ridx(void)
bool all_elements_are_ints(void) const
octave_idx_type xelem(octave_idx_type i) const
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
idx_base_rep * sort_idx(Array< octave_idx_type > &)
const octave_idx_type * data
std::ostream & print(std::ostream &os) const
bool maybe_reduce(octave_idx_type n, const idx_vector &j, octave_idx_type nj)
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
octave_idx_type get_data(void) const
void unconvert(idx_class_type &iclass, double &scalar, Range &range, Array< double > &array, Array< bool > &mask) const
octave_idx_type freeze(octave_idx_type z_len, const char *tag, bool resize_ok=false)
std::ostream & print(std::ostream &os) const
const T * fortran_vec(void) const
const octave_idx_type * get_data(void) const
const bool * get_data(void) const
const octave_idx_type * raw(void)
octave_idx_type increment(void) const
virtual octave_idx_type length(octave_idx_type n) const =0
idx_vector sorted(bool uniq=false) const
bool is_colon(void) const
F77_RET_T const double * x
static bool scalar(const dim_vector &dims)
octave_idx_type checkelem(octave_idx_type i) const
Array< octave_idx_type > as_array(void)