28 #if ! defined (octave_dim_vector_h)
29 #define octave_dim_vector_h 1
31 #include "octave-config.h"
36 #include <initializer_list>
42 template <
typename T>
class Array;
132 std::copy_n (
rep, nd,
r);
151 std::copy_n (
rep, nd,
r);
152 std::fill_n (
r + nd,
n - nd, fill_value);
161 assert (count () == 0);
171 if (decrement_count () == 0)
215 template <
typename... Ints>
217 Ints... lengths) :
rep (newrep (2 + sizeof... (Ints)))
219 std::initializer_list<octave_idx_type> all_lengths = {
r, c, lengths...};
222 rep -= all_lengths.size ();
244 if (nd > 2 &&
rep[nd-1] == 1)
249 while (nd > 2 &&
rep[nd-1] == 1);
254 void chop_all_singletons (
void);
271 { increment_count (); }
274 { increment_count (); }
290 if (decrement_count () == 0)
308 if (
rep && decrement_count () == 0)
324 if (
rep && decrement_count () == 0)
357 if (decrement_count () == 0)
364 std::string str (
char sep =
'x')
const;
403 int n_dims =
ndims ();
407 for (
int i =
n; i < n_dims; i++)
470 for (
int i = 0; i <
ndims (); i++)
481 return num_non_one == 1;
495 for (
int i = 0; i < orig_dims.
ndims (); i++)
497 if (orig_dims(i) != 1)
512 for (
int i = 0; i <
ndims (); i++)
529 for (
int i = nidx - 1; i >= 0; i--)
530 k =
rep[i] * k + idx[i];
542 for (i = start; i <
ndims (); i++)
544 if (++(*idx) ==
rep[i])
560 for (
int i = 0; i < nd; i++)
573 for (
int i = 1; i <
ndims (); i++)
574 k +=
rep[i-1] * idx[i];
591 int a_len = a.
ndims ();
592 int b_len = b.
ndims ();
597 return std::equal (a.
rep, a.
rep + a_len, b.
rep);
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
N Dimensional Array with copy-on-write semantics.
bool is_nd_vector(void) const
Size of the specified dimension.
static Array< T >::ArrayRep * nil_rep(void)
Array< T >::ArrayRep * rep
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
T & xelem(octave_idx_type n)
Size of the specified dimension.
Array< T > & operator=(const Array< T > &a)
T & operator()(octave_idx_type n)
Size of the specified dimension.
int ndims(void) const
Size of the specified dimension.
Vector representing the dimensions (size) of an Array.
octave_idx_type decrement_count(void)
octave_idx_type * clonerep(void)
Clone this->rep.
octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
void freerep(void)
Free the rep.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool zero_by_zero(void) const
void resize(int n, int fill_value=0)
dim_vector(const octave_idx_type r, const octave_idx_type c, Ints... lengths)
Construct dim_vector for a N dimensional array.
static dim_vector alloc(int n)
int increment_index(octave_idx_type *idx, int start=0) const
Increment a multi-dimensional index tuple, optionally starting from an offset position and return the...
bool all_ones(void) const
octave_idx_type & count(void) const
dim_vector(octave_idx_type *r)
octave_idx_type * resizerep(int n, octave_idx_type fill_value)
Clone and resize this->rep to length n, filling by given value.
bool isvector(void) const
dim_vector as_column(void) const
bool all_zero(void) const
dim_vector cumulative(void) const
Return cumulative dimensions.
void chop_trailing_singletons(void)
octave_idx_type elem(int i) const
dim_vector(const dim_vector &dv)
octave_idx_type cum_compute_index(const octave_idx_type *idx) const
Compute a linear index from an index tuple.
static octave_idx_type * newrep(int ndims)
Construct a new rep with count = 1 and ndims given.
octave_idx_type & xelem(int i)
int first_non_singleton(int def=0) const
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type compute_index(const octave_idx_type *idx, int nidx) const
Linear index from an incomplete index tuple (nidx < length ()).
bool empty_2d(void) const
int length(void) const
Number of dimensions.
bool is_nd_vector(void) const
octave_idx_type xelem(int i) const
dim_vector(dim_vector &&dv)
octave_idx_type * to_jit(void) const
bool any_zero(void) const
dim_vector as_row(void) const
octave_idx_type increment_count(void)
octave_idx_type & elem(int i)
dim_vector make_nd_vector(octave_idx_type n) const
bool operator!=(const dim_vector &a, const dim_vector &b)
bool operator==(const dim_vector &a, const dim_vector &b)
octave_idx_type octave_atomic_increment(octave_idx_type *x)
octave_idx_type octave_atomic_decrement(octave_idx_type *x)
T::size_type numel(const T &str)
octave_value::octave_value(const Array< char > &chm, char type) return retval