24 #if ! defined (octave_dim_vector_h) 25 #define octave_dim_vector_h 1 27 #include "octave-config.h" 32 #include <initializer_list> 37 template <
typename T>
class Array;
117 std::copy_n (
rep, nd, r);
136 std::copy_n (
rep, nd, r);
137 std::fill_n (r + nd, n - nd, fill_value);
146 assert (count () == 0);
200 template <
typename... Ints>
202 Ints... lengths) :
rep (newrep (2 + sizeof... (Ints)))
204 std::initializer_list<octave_idx_type> all_lengths = {r,
c, lengths...};
207 rep -= all_lengths.size ();
229 if (nd > 2 &&
rep[nd-1] == 1)
234 while (nd > 2 &&
rep[nd-1] == 1);
239 void chop_all_singletons (
void);
364 int n_dims =
ndims ();
368 for (
int i = n;
i < n_dims;
i++)
427 OCTAVE_DEPRECATED (4.4,
"use 'isvector' instead")
446 return num_non_one == 1;
460 for (
int i = 0;
i < orig_dims.
ndims ();
i++)
462 if (orig_dims(
i) != 1)
494 for (
int i = nidx - 1;
i >= 0;
i--)
509 if (++(*idx) ==
rep[
i])
525 for (
int i = 0;
i < nd;
i++)
556 int a_len =
a.ndims ();
557 int b_len =
b.ndims ();
562 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 compute_index(const octave_idx_type *idx, int nidx) const
Linear index from an incomplete index tuple (nidx < length ()).
octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
octave_idx_type * resizerep(int n, octave_idx_type fill_value)
Clone and resize this->rep to length n, filling by given value.
dim_vector(const octave_idx_type r, const octave_idx_type c, Ints... lengths)
Construct dim_vector for a N dimensional array.
bool operator!=(const dim_vector &a, const dim_vector &b)
octave_idx_type xelem(int i) const
#define OCTAVE_ATOMIC_DECREMENT(x)
octave_idx_type & count(void) const
bool zero_by_zero(void) const
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
dim_vector cumulative(void) const
Return cumulative dimensions.
dim_vector make_nd_vector(octave_idx_type n) const
dim_vector as_row(void) const
void resize(int n, int fill_value=0)
octave_idx_type & xelem(int i)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
octave_idx_type & elem(int i)
#define OCTAVE_ATOMIC_INCREMENT(x)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
octave_base_value * rep
The real representation.
bool any_zero(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 freerep(void)
Free the rep.
bool is_vector(void) const
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...
octave_idx_type * to_jit(void) const
int first_non_singleton(int def=0) const
bool empty_2d(void) const
bool all_zero(void) const
static dim_vector alloc(int n)
bool isvector(const dim_vector &dim)
octave_idx_type elem(int i) const
bool operator==(const dim_vector &a, const dim_vector &b)
T & xelem(octave_idx_type n)
N Dimensional Array with copy-on-write semantics.
bool is_nd_vector(void) const
bool all_ones(void) const
T::size_type numel(const T &str)
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
T & operator()(octave_idx_type n)
static octave_idx_type * newrep(int ndims)
Construct a new rep with count = 1 and ndims given.
bool isvector(void) const
static Array< T >::ArrayRep * nil_rep(void)
octave_idx_type * clonerep(void)
Clone this->rep.
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type num_ones(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.
bool is_nd_vector(void) const
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
dim_vector as_column(void) const
Array< T > & operator=(const Array< T > &a)
dim_vector(octave_idx_type *r)
int length(void) const
Number of dimensions.
Array< T >::ArrayRep * rep
dim_vector(const dim_vector &dv)