24 #if defined (HAVE_CONFIG_H)
39 int n = ra_idx.
numel ();
41 if (n == dimensions.
ndims ())
43 for (
int i = 0;
i < n;
i++)
64 int n = ra_idx.
numel () - 1;
65 int nda = dimensions.
ndims ();
67 for (
int i = start_dimension;
i < n;
i++)
69 if (
ra_idx(
i) < (
i < nda ? dimensions(
i) : 1))
119 int n = dim.
ndims ();
125 for (
int i = 0;
i < n;
i++)
142 int n = dim.
ndims ();
148 for (
int i = 0;
i < n;
i++)
180 if (n >= dims.
numel ())
195 if (j >= dims.
numel (1))
198 return j*
dims(0) +
i;
215 if (k >= dims.
numel (2))
224 int nd = ra_idx.
numel ();
226 for (
int d = 0;
d < nd;
d++)
264 int n = ra_idx.
numel ();
266 assert (n == dimensions.
ndims ());
270 static const char *tag[3] = {
"row",
"column", 0 };
272 for (
int i = 0;
i < n;
i++)
284 bool found_first =
false;
286 for (
int i = 0;
i < n;
i++)
346 int n = frozen_lengths.
ndims ();
352 if (!
ra_idx(
i).is_colon_equiv (frozen_lengths(
i)))
398 int n_dims = dims.
ndims ();
402 for (
int i = 0;
i < n_dims;
i++)
405 assert (idx > 0 || idx < dims.
numel ());
414 for (
int i = 0;
i < n_dims;
i++)
416 std::cout <<
"idx: " << idx <<
", var: " << var
417 <<
", dims(" <<
i <<
"): " <<
dims(
i) <<
"\n";
430 int ial = ia.
numel ();
431 int rhdvl = rhdv.
ndims ();
433 bool *
scalar =
new bool [ial];
434 bool *colon =
new bool [ial];
437 bool all_colons =
true;
438 for (
int i = 0;
i < ial;
i++)
441 scalar[
i] = ia(
i).is_scalar ();
442 colon[
i] = ia(
i).is_colon ();
443 if (! scalar[
i]) nonsc++;
444 if (! colon[i]) rdv(i) = ia(i).extent (0);
445 all_colons = all_colons && colon[
i];
455 else if (nonsc == rhdvl)
457 for (
int i = 0, j = 0;
i < ial;
i++)
459 if (scalar[
i])
continue;
469 int rhdv0l = rhdv0.
ndims ();
470 for (
int i = 0, j = 0;
i < ial;
i++)
472 if (scalar[
i])
continue;
474 rdv(i) = (j < rhdv0l) ? rhdv0(j++) : 1;
491 if (icol && jcol && rhdv.
ndims () == 2)
496 else if (rhdv.
ndims () == 2
499 rdv(0) = icol ? rhdv(0) : i.
extent (0);
500 rdv(1) = jcol ? rhdv(1) : j.
extent (0);
528 : ind(_ind), n(_n) { }
540 (*current_liboctave_error_handler) (
"sub2ind: needs at least 2 indices");
543 bool all_ranges =
true;
553 all_ranges = all_ranges && idx.
is_range ();
556 else if (clen != idx.
length (n))
558 (
"sub2ind: lengths of indices must match");
568 (*current_liboctave_error_with_id_handler)
569 (e.
err_id (), msg.c_str ());
582 idx = dvx(
i) * idx + idxa(
i)(0);
585 else if (all_ranges && clen != 0)
594 start = dvx(
i) * start + xstart;
595 step = dvx(
i) * step + xstep;
609 idxa(
i).copy_data (idx_vec);
651 rdata[j](
i) = k %
dv(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
nd group nd example oindent but is performed more efficiently If only and it is a scalar
bool any_orig_empty(const Array< idx_vector > &ra_idx)
octave_idx_type numel(void) const
Number of elements in the array.
in that an updated permutation matrix is returned Note that if var
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
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)
bool is_vector(const dim_vector &dim)
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)
bool vector_equivalent(const dim_vector &dv)
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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
virtual std::string message(void) 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
void set_var(const std::string &var_arg="")
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
dim_vector orig_dimensions(void) const
bool any_ones(const Array< octave_idx_type > &arr)
idx_vector sub2ind(const dim_vector &dv, const Array< idx_vector > &idxa)
virtual const char * err_id(void) const =0
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
nd deftypefn *octave_map m
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)
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)
bool is_scalar(const dim_vector &dim)
Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
octave_idx_type extent(octave_idx_type n) const
bool is_range(void) const
T::size_type numel(const T &str)
octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
bool all_ok(const Array< idx_vector > &ra_idx)
=val(i)}if ode{val(i)}occurs in table i
bool is_scalar(void) const
octave_idx_type ndims(void) const
Number of dimensions.
#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 num_ones(const Array< octave_idx_type > &ra_idx)
const T * fortran_vec(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
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