24 #if defined (HAVE_CONFIG_H) 40 if (n == dimensions.
ndims ())
42 for (
int i = 0;
i < n;
i++)
64 int nda = dimensions.
ndims ();
66 for (
int i = start_dimension;
i < n;
i++)
68 if (
ra_idx(
i) < (
i < nda ? dimensions(
i) : 1))
118 int n = dim.
ndims ();
124 for (
int i = 0;
i < n;
i++)
141 int n = dim.
ndims ();
147 for (
int i = 0;
i < n;
i++)
179 if (n >=
dims.numel ())
194 if (j >=
dims.numel (1))
197 return j*
dims(0) +
i;
214 if (
k >=
dims.numel (2))
225 for (
int d = 0;
d < nd;
d++)
265 assert (n == dimensions.
ndims ());
269 static const char *tag[3] = {
"row",
"column",
nullptr };
271 for (
int i = 0;
i < n;
i++)
283 bool found_first =
false;
285 for (
int i = 0;
i < n;
i++)
345 int n = frozen_lengths.
ndims ();
351 if (!
ra_idx(
i).is_colon_equiv (frozen_lengths(
i)))
397 int n_dims =
dims.ndims ();
401 for (
int i = 0;
i < n_dims;
i++)
404 assert (idx > 0 || idx <
dims.numel ());
413 for (
int i = 0;
i < n_dims;
i++)
415 std::cout <<
"idx: " << idx <<
", var: " <<
var 416 <<
", dims(" <<
i <<
"): " <<
dims(
i) <<
"\n";
429 int ial = ia.
numel ();
430 int rhdvl = rhdv.
ndims ();
432 bool *
scalar =
new bool [ial];
433 bool *colon =
new bool [ial];
436 bool all_colons =
true;
437 for (
int i = 0;
i < ial;
i++)
441 colon[
i] = ia(
i).is_colon ();
443 if (! colon[
i]) rdv(
i) = ia(
i).extent (0);
444 all_colons = all_colons && colon[
i];
454 else if (nonsc == rhdvl)
456 for (
int i = 0, j = 0;
i < ial;
i++)
468 int rhdv0l = rhdv0.
ndims ();
469 for (
int i = 0, j = 0;
i < ial;
i++)
473 rdv(
i) = (j < rhdv0l) ? rhdv0(j++) : 1;
487 bool icol =
i.is_colon ();
490 if (icol && jcol && rhdv.
ndims () == 2)
495 else if (rhdv.
ndims () == 2
498 rdv(0) = (icol ? rhdv(0) :
i.extent (0));
499 rdv(1) = (jcol ? rhdv(1) : j.
extent (0));
506 rdv(0) =
i.extent (0);
509 else if (!
i.is_scalar ())
527 :
ind(_ind),
n(_n) { }
539 (*current_liboctave_error_handler) (
"sub2ind: needs at least 2 indices");
542 bool all_ranges =
true;
552 all_ranges = all_ranges && idx.
is_range ();
555 else if (clen != idx.
length (n))
557 (
"sub2ind: lengths of indices must match");
564 e.set_pos_if_unset (len,
i+1);
567 (*current_liboctave_error_with_id_handler)
568 (
e.err_id (), msg.c_str ());
581 idx = dvx(
i) * idx + idxa(
i)(0);
584 else if (all_ranges && clen != 0)
594 step = dvx(
i) * step + xstep;
608 idxa(
i).copy_data (idx_vec);
650 rdata[j](
i) =
k %
dv(j);
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
dim_vector orig_dimensions(void) const
octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
bool all_ones(const Array< octave_idx_type > &arr)
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
nd group nd example oindent but is performed more efficiently If only and it is a scalar
octave_idx_type extent(octave_idx_type n) const
bool any_orig_empty(const Array< idx_vector > &ra_idx)
dim_vector zero_dims_inquire(const Array< idx_vector > &ia, const dim_vector &rhdv)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
void resize(int n, int fill_value=0)
const T * fortran_vec(void) const
void err_index_out_of_range(int nd, int dim, octave_idx_type idx, octave_idx_type ext)
void err_invalid_index(const std::string &idx, octave_idx_type nd, octave_idx_type dim, const std::string &)
void operator()(octave_idx_type k)
std::complex< T > floor(const std::complex< T > &x)
bool vector_equivalent(const dim_vector &dv)
virtual octave_idx_type numel(const octave_value_list &)
Array< octave_idx_type > get_ra_idx(octave_idx_type idx, const dim_vector &dims)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
octave_value resize(const dim_vector &dv, bool fill=false) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
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)
bool is_range(void) const
bool is_colon(void) const
void chop_all_singletons(void)
int permute_vector_compare(const void *a, const void *b)
octave_idx_type length(octave_idx_type n=0) const
dim_vector freeze(Array< idx_vector > &ra_idx, const dim_vector &dimensions, int resize_ok)
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)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
static dim_vector alloc(int n)
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
bool is_scalar(const dim_vector &dim)
bool isvector(const dim_vector &dim)
N Dimensional Array with copy-on-write semantics.
Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
T::size_type numel(const T &str)
bool all_ok(const Array< idx_vector > &ra_idx)
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
#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)
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
octave_idx_type numel(void) const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
bool is_scalar(void) const
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
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)