24 #if ! defined (octave_dim_vector_h)
25 #define octave_dim_vector_h 1
27 #include "octave-config.h"
31 #include <initializer_list>
117 for (
int i = 0;
i < l;
i++)
150 assert (count () == 0);
205 template <
typename... Ints>
207 Ints... lengths) : rep (newrep (2 + sizeof... (Ints)))
209 std::initializer_list<octave_idx_type> all_lengths = {r,
c, lengths...};
212 rep -= all_lengths.size ();
217 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK)
218 assert (i >= 0 && i <
ndims ());
226 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK)
227 assert (i >= 0 && i <
ndims ());
235 if (l > 2 && rep[l-1] == 1)
240 while (l > 2 && rep[l-1] == 1);
245 void chop_all_singletons (
void);
391 int n_dims =
ndims ();
395 for (
int i = n;
i < n_dims;
i++)
415 int n_dims =
ndims ();
418 for (i = 0; i < n_dims; i++)
482 for (
int i = nidx - 1;
i >= 0;
i--)
483 k = rep[
i] * k + idx[
i];
499 if (++(*idx) == rep[
i])
515 for (
int i = 0;
i < nd;
i++)
516 retval.
rep[
i] = k *= rep[
i];
529 k += rep[
i-1] * idx[
i];
546 int a_len = a.
ndims ();
547 int b_len = b.
ndims ();
553 for (
int i = 0;
i < a_len;
i++)
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
octave_idx_type & count(void) const
octave_idx_type compute_index(const octave_idx_type *idx, int nidx) const
Linear index from an incomplete index tuple (nidx < length ()).
octave_idx_type * resizerep(int n, octave_idx_type fill_value)
Clone and resize this->rep to length n, filling by given value.
bool operator!=(const dim_vector &a, const dim_vector &b)
dim_vector(const octave_idx_type r, const octave_idx_type c, Ints...lengths)
Construct dim_vector for a N dimensional array.
#define OCTAVE_ATOMIC_DECREMENT(x)
bool is_vector(void) const
dim_vector cumulative(void) const
Return cumulative dimensions.
SparseBoolMatrix & operator=(const SparseBoolMatrix &a)
void resize(int n, int fill_value=0)
static Sparse< bool >::SparseRep * nil_rep(void)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
octave_idx_type cum_compute_index(const octave_idx_type *idx) const
Compute a linear index from an index tuple.
dim_vector as_column(void) const
octave_idx_type & elem(int i)
#define OCTAVE_ATOMIC_INCREMENT(x)
bool all_ones(void) const
int increment_index(octave_idx_type *idx, int start=0) const
int first_non_singleton(int def=0) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
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
octave_idx_type * to_jit(void) const
void freerep(void)
Free the rep.
Sparse< bool >::SparseRep * rep
bool empty_2d(void) const
bool & operator()(octave_idx_type n)
octave_idx_type ndims(void) const
dim_vector as_row(void) const
bool any_zero(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
static dim_vector alloc(int n)
bool all_zero(void) const
SparseBoolMatrix squeeze(void) const
bool operator==(const dim_vector &a, const dim_vector &b)
T::size_type numel(const T &str)
octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
=val(i)}if ode{val(i)}occurs in table i
bool zero_by_zero(void) const
static octave_idx_type * newrep(int ndims)
Construct a new rep with count = 1 and ndims given.
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type elem(int i) const
octave_idx_type * clonerep(void)
Clone this->rep.
octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
Vector representing the dimensions (size) of an Array.
void chop_trailing_singletons(void)
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
int length(void) const
Number of dimensions.
dim_vector(octave_idx_type *r)
dim_vector(const dim_vector &dv)