41 if (n == dimensions.
length ())
43 for (
int i = 0; i < n; i++)
64 int n = ra_idx.
length () - 1;
65 int nda = dimensions.
length ();
67 for (
int i = start_dimension; i < n; i++)
69 if (
ra_idx(i) < (i < nda ? dimensions(i) : 1))
127 for (
int i = 0; i < n; i ++)
150 for (
int i = 0; i < n; i ++)
182 if (n >= dims.
numel ())
195 if (j >= dims.
numel (1))
198 return j*dims(0) + i;
205 if (i < 0 || j < 0 || k < 0)
211 if (k >= dims.
numel (2))
214 return (k*dims(1) + j)*dims(0) + i;
220 int nd = ra_idx.
length ();
222 for (
int d = 0;
d < nd;
d++)
239 retval(i) = a(i).
elem (0);
262 assert (n == dimensions.
length ());
266 static const char *tag[3] = {
"row",
"column", 0 };
268 for (
int i = 0; i < n; i++)
269 retval(i) =
ra_idx(i).freeze (dimensions(i), tag[i < 2 ? i : 3],
280 bool found_first =
false;
282 for (
int i = 0; i < n; i++)
324 if (
ra_idx(i).orig_empty ())
342 int n = frozen_lengths.
length ();
348 if (!
ra_idx(i).is_colon_equiv (frozen_lengths(i)))
384 retval(i) =
ra_idx(i).elem (result_idx(i));
394 int n_dims = dims.
length ();
398 for (
int i = 0; i < n_dims; i++)
401 assert (idx > 0 || idx < dims.
numel ());
410 for (
int i = 0; i < n_dims; i++)
412 std::cout <<
"idx: " << idx <<
", var: " << var
413 <<
", dims(" << i <<
"): " << dims(i) <<
"\n";
414 retval(i) = ((
int)
floor(((idx) / (
double)var))) % dims(i);
415 idx -= var * retval(i);
427 int rhdvl = rhdv.
length ();
429 bool *
scalar =
new bool [ial];
430 bool *colon =
new bool [ial];
433 bool all_colons =
true;
434 for (
int i = 0; i < ial; i++)
437 scalar[i] = ia(i).is_scalar ();
438 colon[i] = ia(i).is_colon ();
439 if (! scalar[i]) nonsc++;
440 if (! colon[i]) rdv(i) = ia(i).extent (0);
441 all_colons = all_colons && colon[i];
451 else if (nonsc == rhdvl)
453 for (
int i = 0, j = 0; i < ial; i++)
455 if (scalar[i])
continue;
465 int rhdv0l = rhdv0.
length ();
466 for (
int i = 0, j = 0; i < ial; i++)
468 if (scalar[i])
continue;
470 rdv(i) = (j < rhdv0l) ? rhdv0(j++) : 1;
487 if (icol && jcol && rhdv.
length () == 2)
492 else if (rhdv.
length () == 2
495 rdv(0) = icol ? rhdv(0) : i.
extent (0);
496 rdv(1) = jcol ? rhdv(1) : j.
extent (0);
524 : ind(_ind), n(_n) { }
538 bool all_ranges =
true;
546 all_ranges = all_ranges && idx.
is_range ();
549 else if (clen != idx.
length (n))
563 idx = idx * dvx(i) + idxa(i)(0);
566 else if (all_ranges && clen != 0)
575 start = start * dvx(i) + xstart;
576 step = step * dvx(i) + xstep;
590 idxa(i).copy_data (idx_vec);
610 if (idx.
extent (numel) > numel)
619 retval(j) = k % dv(j);
636 rdata[j](i) = k % dv(j);
642 retval(j) = rdata[j];
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
bool all_ones(const Array< octave_idx_type > &arr)
octave_idx_type length(octave_idx_type n=0) const
bool index_in_bounds(const Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
const octave_base_value const Array< octave_idx_type > & ra_idx
bool any_orig_empty(const Array< idx_vector > &ra_idx)
dim_vector zero_dims_inquire(const Array< idx_vector > &ia, const dim_vector &rhdv)
void resize(int n, int fill_value=0)
bool is_vector(const dim_vector &dim)
void operator()(octave_idx_type k)
T & elem(octave_idx_type n)
bool vector_equivalent(const dim_vector &dv)
void gripe_invalid_index(void)
Array< octave_idx_type > get_ra_idx(octave_idx_type idx, const dim_vector &dims)
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
F77_RET_T const double const double double * d
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
dim_vector orig_dimensions(void) const
liboctave_error_handler current_liboctave_error_handler
bool any_ones(const Array< octave_idx_type > &arr)
idx_vector sub2ind(const dim_vector &dv, const Array< idx_vector > &idxa)
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
static void gripe_index_out_of_range(void)
void chop_all_singletons(void)
const T * data(void) const
int permute_vector_compare(const void *a, const void *b)
void resize(const dim_vector &dv, const T &rfv)
dim_vector freeze(Array< idx_vector > &ra_idx, const dim_vector &dimensions, int resize_ok)
dim_vector redim(int n) const
bool all_colon_equiv(const Array< idx_vector > &ra_idx, const dim_vector &frozen_lengths)
Array< octave_idx_type > conv_to_int_array(const Array< idx_vector > &a)
static dim_vector alloc(int n)
bool is_scalar(const dim_vector &dim)
Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
octave_idx_type length(void) const
Number of elements in the array.
octave_idx_type extent(octave_idx_type n) const
bool is_range(void) const
octave_idx_type compute_index(const octave_idx_type *idx) const
Compute a linear index from an index tuple.
bool all_ok(const Array< idx_vector > &ra_idx)
bool is_scalar(void) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
sub2ind_helper(octave_idx_type *_ind, octave_idx_type _n)
octave_idx_type get_scalar_idx(Array< octave_idx_type > &idx, dim_vector &dims)
Array< idx_vector > conv_to_array(const idx_vector *tmp, const octave_idx_type len)
std::complex< T > floor(const std::complex< T > &x)
octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
const T * fortran_vec(void) const
static idx_vector make_range(octave_idx_type start, octave_idx_type step, octave_idx_type len)
Array< octave_idx_type > get_elt_idx(const Array< idx_vector > &ra_idx, const Array< octave_idx_type > &result_idx)
bool is_colon(void) const
static bool scalar(const dim_vector &dims)