GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dim_vector Class Reference

Vector representing the dimensions (size) of an Array. More...

#include "dim-vector.h"

Collaboration diagram for dim_vector:

Public Member Functions

 dim_vector (const dim_vector &dv)
 
template<typename... Ints>
 dim_vector (const octave_idx_type r, const octave_idx_type c, Ints... lengths)
 Construct dim_vector for a N dimensional array. More...
 
 dim_vector (dim_vector &&dv)
 
 dim_vector (octave_idx_type *r)
 
 dim_vector (void)
 
 ~dim_vector (void)
 
bool all_ones (void) const
 
bool all_zero (void) const
 
bool any_neg (void) const
 
bool any_zero (void) const
 
Array< octave_idx_typeas_array (void) const
 
dim_vector as_column (void) const
 
dim_vector as_row (void) const
 
void chop_all_singletons (void)
 
void chop_trailing_singletons (void)
 
octave_idx_type compute_index (const octave_idx_type *idx) const
 Linear index from an index tuple. More...
 
octave_idx_type compute_index (const octave_idx_type *idx, int nidx) const
 Linear index from an incomplete index tuple (nidx < length ()). More...
 
bool concat (const dim_vector &dvb, int dim)
 This corresponds to cat(). More...
 
octave_idx_type cum_compute_index (const octave_idx_type *idx) const
 Compute a linear index from an index tuple. More...
 
dim_vector cumulative (void) const
 Return cumulative dimensions. More...
 
octave_idx_typeelem (int i)
 
octave_idx_type elem (int i) const
 
bool empty_2d (void) const
 
int first_non_singleton (int def=0) const
 
bool hvcat (const dim_vector &dvb, int dim)
 This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1). More...
 
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 index of the last index position that was changed, or length () if just cycled over. More...
 
bool is_nd_vector (void) const
 
bool isvector (void) const
 
int length (void) const
 Number of dimensions. More...
 
dim_vector make_nd_vector (octave_idx_type n) const
 
octave_idx_type ndims (void) const
 Number of dimensions. More...
 
int num_ones (void) const
 
octave_idx_type numel (int n=0) const
 Number of elements that a matrix with this dimensions would have. More...
 
octave_idx_typeoperator() (int i)
 
octave_idx_type operator() (int i) const
 
dim_vectoroperator= (const dim_vector &dv)
 
dim_vectoroperator= (dim_vector &&dv)
 
dim_vector redim (int n) const
 Force certain dimensionality, preserving numel (). More...
 
void resize (int n, int fill_value=0)
 
octave_idx_type safe_numel (void) const
 The following function will throw a std::bad_alloc () exception if the requested size is larger than can be indexed by octave_idx_type. More...
 
dim_vector squeeze (void) const
 
std::string str (char sep='x') const
 
octave_idx_typeto_jit (void) const
 
octave_idx_typexelem (int i)
 
octave_idx_type xelem (int i) const
 
bool zero_by_zero (void) const
 

Static Public Member Functions

static dim_vector alloc (int n)
 
static octave_idx_type dim_max (void)
 

Private Member Functions

octave_idx_typeclonerep (void)
 Clone this->rep. More...
 
octave_idx_typecount (void) const
 
octave_idx_type decrement_count (void)
 
void freerep (void)
 Free the rep. More...
 
octave_idx_type increment_count (void)
 
void make_unique (void)
 
octave_idx_typeresizerep (int n, octave_idx_type fill_value)
 Clone and resize this->rep to length n, filling by given value. More...
 

Static Private Member Functions

static octave_idx_typenewrep (int ndims)
 Construct a new rep with count = 1 and ndims given. More...
 
static octave_idx_typenil_rep (void)
 

Private Attributes

octave_idx_typerep
 

Friends

bool operator== (const dim_vector &a, const dim_vector &b)
 

Detailed Description

Vector representing the dimensions (size) of an Array.

A dim_vector is used to represent dimensions of an Array. It is used on its constructor to specify its size, or when reshaping it.

// Matrix with 10 rows and 20 columns.
// Change its size to 5 rows and 40 columns.
Matrix m2 = m.reshape (dim_vector (5, 40));
// Five dimensional Array of length 10, 20, 3, 8, 7 on each dimension.
NDArray a (dim_vector (10, 20, 3, 8, 7));
// Uninitialized array of same size as other.
NDArray b (a.dims ());
Definition: dMatrix.h:42
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
T octave_idx_type m
Definition: mx-inlines.cc:773

The main thing to understand about this class, is that methods such as ndims() and numel(), return the value for an Array of these dimensions, not the actual number of elements in the dim_vector.

dim_vector d (10, 5, 3);
octave_idx_type n = d.numel (); // returns 150
octave_idx_type nd = d.ndims (); // returns 3
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
octave_idx_type n
Definition: mx-inlines.cc:753

Implementation details

This implementation is more tricky than Array, but the big plus is that dim_vector requires only one allocation instead of two. It is (slightly) patterned after GCC's basic_string implementation. rep is a pointer to an array of memory, comprising count, length, and the data:

//!        <count>
//!        <ndims>
//! rep --> <dims[0]>
//!        <dims[1]>
//!        ...
//! 
The inlines count(), ndims() recover this data from the rep.  Note
that rep points to the beginning of dims to grant faster access
(reinterpret_cast is assumed to be an inexpensive operation). 

Definition at line 92 of file dim-vector.h.

Constructor & Destructor Documentation

◆ dim_vector() [1/5]

template<typename... Ints>
dim_vector::dim_vector ( const octave_idx_type  r,
const octave_idx_type  c,
Ints...  lengths 
)
inline

Construct dim_vector for a N dimensional array.

Each argument to constructor defines the length of an additional dimension. A dim_vector always represents a minimum of 2 dimensions (just like an Array has at least 2 dimensions) and there is no upper limit on the number of dimensions.

dim_vector dv (7, 5);
Matrix mat (dv);

The constructed dim_vector dv will have two elements, $[7, 5]$, one for each dimension. It can then be used to construct a Matrix with such dimensions, i.e., 7 rows and 5 columns.

NDArray x (dim_vector (7, 5, 10));
F77_RET_T const F77_DBLE * x

This will construct a 3 dimensional NDArray of lengths 7, 5, and 10, on the first, second, and third dimension (rows, columns, and pages) respectively.

Note that that there is no constructor that accepts only one dimension length to avoid confusion. The source for such confusion is that constructor could mean:

  • a column vector, i.e., assume $[N, 1]$;
  • a square matrix, i.e., as is common in Octave interpreter;
  • support for a 1 dimensional Array (does not exist);

Using r, c, and lengths... as arguments, allow us to check at compile time that there's at least 2 dimensions specified, while maintaining type safety.

Definition at line 216 of file dim-vector.h.

References r, and Array< T >::rep.

◆ dim_vector() [2/5]

dim_vector::dim_vector ( void  )
inlineexplicit

Definition at line 270 of file dim-vector.h.

Referenced by hvcat().

◆ dim_vector() [3/5]

dim_vector::dim_vector ( const dim_vector dv)
inline

Definition at line 273 of file dim-vector.h.

◆ dim_vector() [4/5]

dim_vector::dim_vector ( dim_vector &&  dv)
inline

Definition at line 276 of file dim-vector.h.

◆ dim_vector() [5/5]

dim_vector::dim_vector ( octave_idx_type r)
inlineexplicit

Definition at line 279 of file dim-vector.h.

◆ ~dim_vector()

dim_vector::~dim_vector ( void  )
inline

Definition at line 318 of file dim-vector.h.

References Array< T >::rep.

Member Function Documentation

◆ all_ones()

◆ all_zero()

◆ alloc()

◆ any_neg()

bool dim_vector::any_neg ( void  ) const
inline

Definition at line 423 of file dim-vector.h.

References Array< T >::ndims(), and Array< T >::rep.

Referenced by Array< T >::resize().

◆ any_zero()

◆ as_array()

Array< octave_idx_type > dim_vector::as_array ( void  ) const

Definition at line 285 of file dim-vector.cc.

References elem(), ndims(), and retval.

Referenced by octave_base_value::dump().

◆ as_column()

dim_vector dim_vector::as_column ( void  ) const
inline

Definition at line 445 of file dim-vector.h.

References Array< T >::ndims(), numel(), and Array< T >::xelem().

Referenced by Ffind().

◆ as_row()

dim_vector dim_vector::as_row ( void  ) const
inline

Definition at line 453 of file dim-vector.h.

References Array< T >::ndims(), numel(), and Array< T >::xelem().

Referenced by squeeze().

◆ chop_all_singletons()

void dim_vector::chop_all_singletons ( void  )

Definition at line 65 of file dim-vector.cc.

References make_unique(), ndims(), and rep.

Referenced by Array< T >::assign(), squeeze(), and zero_dims_inquire().

◆ chop_trailing_singletons()

void dim_vector::chop_trailing_singletons ( void  )
inline

◆ clonerep()

octave_idx_type* dim_vector::clonerep ( void  )
inlineprivate

Clone this->rep.

Definition at line 126 of file dim-vector.h.

References Array< T >::ndims(), r, and Array< T >::rep.

◆ compute_index() [1/2]

octave_idx_type dim_vector::compute_index ( const octave_idx_type idx) const
inline

Linear index from an index tuple.

Definition at line 522 of file dim-vector.h.

References compute_index(), and Array< T >::ndims().

Referenced by compute_index(), Array< T >::compute_index_unchecked(), do_bsxfun_op(), and do_inplace_bsxfun_op().

◆ compute_index() [2/2]

octave_idx_type dim_vector::compute_index ( const octave_idx_type idx,
int  nidx 
) const
inline

Linear index from an incomplete index tuple (nidx < length ()).

Definition at line 526 of file dim-vector.h.

References Array< T >::rep.

◆ concat()

bool dim_vector::concat ( const dim_vector dvb,
int  dim 
)

This corresponds to cat().

Definition at line 157 of file dim-vector.cc.

References chop_trailing_singletons(), make_unique(), ndims(), rep, and resize().

Referenced by Array< T >::cat(), octave_map::cat(), Sparse< T >::cat(), do_cat(), and hvcat().

◆ count()

octave_idx_type& dim_vector::count ( void  ) const
inlineprivate

Definition at line 100 of file dim-vector.h.

References Array< T >::rep.

◆ cum_compute_index()

octave_idx_type dim_vector::cum_compute_index ( const octave_idx_type idx) const
inline

Compute a linear index from an index tuple.

Dimensions are required to be cumulative.

Definition at line 569 of file dim-vector.h.

References Array< T >::ndims(), and Array< T >::rep.

Referenced by do_bsxfun_op(), and do_inplace_bsxfun_op().

◆ cumulative()

dim_vector dim_vector::cumulative ( void  ) const
inline

Return cumulative dimensions.

Definition at line 554 of file dim-vector.h.

References Array< T >::ndims(), Array< T >::rep, and retval.

Referenced by convolve(), do_bsxfun_op(), and do_inplace_bsxfun_op().

◆ decrement_count()

octave_idx_type dim_vector::decrement_count ( void  )
inlineprivate

Definition at line 107 of file dim-vector.h.

References octave_atomic_decrement().

◆ dim_max()

octave_idx_type dim_vector::dim_max ( void  )
static

Definition at line 59 of file dim-vector.cc.

References max().

Referenced by Fsizemax(), and safe_numel().

◆ elem() [1/2]

octave_idx_type& dim_vector::elem ( int  i)
inline

Definition at line 233 of file dim-vector.h.

References Array< T >::make_unique(), and Array< T >::xelem().

Referenced by as_array(), and squeeze().

◆ elem() [2/2]

octave_idx_type dim_vector::elem ( int  i) const
inline

Definition at line 239 of file dim-vector.h.

References Array< T >::xelem().

◆ empty_2d()

bool dim_vector::empty_2d ( void  ) const
inline

Definition at line 372 of file dim-vector.h.

References Array< T >::ndims(), and Array< T >::xelem().

◆ first_non_singleton()

◆ freerep()

void dim_vector::freerep ( void  )
inlineprivate

Free the rep.

Definition at line 159 of file dim-vector.h.

References Array< T >::rep.

◆ hvcat()

bool dim_vector::hvcat ( const dim_vector dvb,
int  dim 
)

This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).

Definition at line 220 of file dim-vector.cc.

References dim_vector(), concat(), ndims(), and rep.

Referenced by Array< T >::cat(), Sparse< T >::cat(), octave::tm_row_const::cellify(), do_cat(), octave::tm_row_const::init(), and octave::tm_const::init().

◆ increment_count()

octave_idx_type dim_vector::increment_count ( void  )
inlineprivate

Definition at line 102 of file dim-vector.h.

References octave_atomic_increment().

◆ increment_index()

int dim_vector::increment_index ( octave_idx_type idx,
int  start = 0 
) const
inline

Increment a multi-dimensional index tuple, optionally starting from an offset position and return the index of the last index position that was changed, or length () if just cycled over.

Definition at line 539 of file dim-vector.h.

References Array< T >::ndims(), and Array< T >::rep.

Referenced by do_bsxfun_op(), do_inplace_bsxfun_op(), do_mat2cell(), and do_mat2cell_nd().

◆ is_nd_vector()

bool dim_vector::is_nd_vector ( void  ) const
inline

Definition at line 466 of file dim-vector.h.

References Array< T >::ndims(), and Array< T >::xelem().

Referenced by Array< T >::is_nd_vector().

◆ isvector()

bool dim_vector::isvector ( void  ) const
inline

◆ length()

int dim_vector::length ( void  ) const
inline

Number of dimensions.

Synonymous with ndims().

While this method is not officially deprecated, consider using ndims() instead to avoid confusion. Array does not have length because of its odd definition as length of the longest dimension.

Definition at line 343 of file dim-vector.h.

References Array< T >::ndims().

◆ make_nd_vector()

dim_vector dim_vector::make_nd_vector ( octave_idx_type  n) const
inline

◆ make_unique()

void dim_vector::make_unique ( void  )
inlineprivate

Definition at line 165 of file dim-vector.h.

References Array< T >::rep.

Referenced by chop_all_singletons(), and concat().

◆ ndims()

octave_idx_type dim_vector::ndims ( void  ) const
inline

Number of dimensions.

Returns the number of dimensions of the dim_vector. This is number of elements in the dim_vector including trailing singletons. It is also the number of dimensions an Array with this dim_vector would have.

Definition at line 334 of file dim-vector.h.

References Array< T >::rep.

Referenced by rec_resize_helper::rec_resize_helper(), Sparse< T >::Sparse(), all_colon_equiv(), as_array(), Array< T >::as_column(), Array< T >::as_matrix(), Array< T >::as_row(), Array< T >::assign(), Array< T >::cat(), octave::check_dimensions(), chop_all_singletons(), octave_uint64_matrix::complex_matrix_value(), compute_array_dimensions(), concat(), convert_cdata(), octave::convert_packcomplex_Nd(), octave::opengl_texture::create(), Array< T >::diag(), do_accumdim_sum(), do_cat(), do_cellslices_nda(), do_diff(), do_fft(), do_fft2(), do_fftn(), do_num2cell_helper(), do_trilu(), octave::opengl_renderer::draw_image(), octave::end_value(), Fbsxfun(), Fcellslices(), Fellipj(), Ffilter(), fill_matrix(), filter(), Flinspace(), octave_uint64_matrix::float_complex_matrix_value(), octave_uint64_matrix::float_matrix_value(), ComplexNDArray::fourier(), NDArray::fourier(), FloatComplexNDArray::fourier(), FloatNDArray::fourier(), ComplexNDArray::fourier2d(), NDArray::fourier2d(), FloatComplexNDArray::fourier2d(), FloatNDArray::fourier2d(), ComplexNDArray::fourierNd(), NDArray::fourierNd(), FloatComplexNDArray::fourierNd(), FloatNDArray::fourierNd(), freeze(), Fsize(), Fstruct2cell(), octave::tm_const::generic_concat(), get_blkmm_dims(), get_ra_idx(), get_red_dims(), get_vec_dims(), hvcat(), ComplexNDArray::ifourier(), NDArray::ifourier(), FloatComplexNDArray::ifourier(), FloatNDArray::ifourier(), ComplexNDArray::ifourier2d(), NDArray::ifourier2d(), FloatComplexNDArray::ifourier2d(), FloatNDArray::ifourier2d(), ComplexNDArray::ifourierNd(), NDArray::ifourierNd(), FloatComplexNDArray::ifourierNd(), FloatNDArray::ifourierNd(), increment_index(), ind2sub(), index_in_bounds(), octave::tm_const::init(), ComplexNDArray::insert(), FloatComplexNDArray::insert(), is_scalar(), is_valid_bsxfun(), is_valid_inplace_bsxfun(), isvector(), make_nd_vector(), QtHandles::Utils::makeImageFromCData(), mat2cell_mismatch(), octave_uint64_matrix::matrix_value(), SparseComplexMatrix::max(), SparseMatrix::max(), maybe_update_column(), SparseComplexMatrix::min(), SparseMatrix::min(), octave_base_value::ndims(), Array< T >::ndims(), Sparse< T >::ndims(), num_ones(), operator<<(), Array< T >::permute(), redim(), Sparse< T >::reshape(), Sparse< T >::resize(), octave_base_diag< DMT, MT >::resize(), Array< T >::resize(), safe_numel(), octave_base_int_matrix< T >::save_ascii(), octave_bool_matrix::save_ascii(), octave_cell::save_ascii(), octave_complex_matrix::save_ascii(), octave_float_complex_matrix::save_ascii(), octave_float_matrix::save_ascii(), octave_matrix::save_ascii(), octave_char_matrix_str::save_ascii(), octave_struct::save_ascii(), octave_scalar_struct::save_ascii(), octave_bool_matrix::save_binary(), octave_sparse_bool_matrix::save_binary(), octave_cell::save_binary(), octave_complex_matrix::save_binary(), octave_sparse_complex_matrix::save_binary(), octave_float_complex_matrix::save_binary(), octave_float_matrix::save_binary(), octave_matrix::save_binary(), octave_sparse_matrix::save_binary(), octave_char_matrix_str::save_binary(), octave_struct::save_binary(), octave_base_int_matrix< T >::save_binary(), octave_bool_matrix::save_hdf5(), octave_cell::save_hdf5(), octave_complex_matrix::save_hdf5(), octave_float_complex_matrix::save_hdf5(), octave_float_matrix::save_hdf5(), octave_matrix::save_hdf5(), octave_char_matrix_str::save_hdf5(), octave_base_int_matrix< T >::save_hdf5_internal(), scalar(), octave_base_value::size(), octave_class::size(), Array< T >::sort(), octave_lazy_index::sort(), squeeze(), str(), streameuler3d_internal(), try_cellfun_internal_ops(), update_index(), octave::workspace_model::update_table(), array_property::validate(), vector_equivalent(), and zero_dims_inquire().

◆ newrep()

static octave_idx_type* dim_vector::newrep ( int  ndims)
inlinestaticprivate

Construct a new rep with count = 1 and ndims given.

Definition at line 114 of file dim-vector.h.

References Array< T >::ndims(), and r.

◆ nil_rep()

octave_idx_type * dim_vector::nil_rep ( void  )
staticprivate

Definition at line 40 of file dim-vector.cc.

◆ num_ones()

int dim_vector::num_ones ( void  ) const

Definition at line 103 of file dim-vector.cc.

References ndims(), retval, and xelem().

◆ numel()

octave_idx_type dim_vector::numel ( int  n = 0) const
inline

Number of elements that a matrix with this dimensions would have.

Return the number of elements that a matrix with this dimension vector would have, NOT the number of dimensions (elements in the dimension vector).

Definition at line 401 of file dim-vector.h.

References elem, n, Array< T >::ndims(), and retval.

Referenced by octave::math::airy(), octave::math::biry(), compute_index(), octave::convert_packcomplex_Nd(), octave_float_matrix::convert_to_str_internal(), octave_matrix::convert_to_str_internal(), octave_sparse_matrix::convert_to_str_internal(), octave::dims_to_numel(), octave::math::do_bessel(), do_bessel(), do_bsxfun_op(), do_inplace_bsxfun_op(), do_num2cell(), do_object2cell(), Fbsxfun(), octave::fftw::fftNd(), filter(), Fregexprep(), Freshape(), get_ra_idx(), octave::fftw::ifftNd(), ind2sub(), octave_base_matrix< MT >::is_true(), octave_base_sparse< T >::is_true(), octave_perm_matrix::is_true(), octave_cell::load_ascii(), octave_char_matrix_str::load_ascii(), octave_bool_matrix::load_binary(), octave_cell::load_binary(), octave_complex_matrix::load_binary(), octave_float_complex_matrix::load_binary(), octave_float_matrix::load_binary(), octave_matrix::load_binary(), octave_char_matrix_str::load_binary(), octave_base_int_matrix< T >::load_binary(), octave_bool_matrix::load_hdf5(), octave_cell::load_hdf5(), octave_base_value::numel(), octave_class::numel(), octave_print_internal_template(), read_mat5_binary_element(), Sparse< T >::reshape(), octave_bool::resize(), octave_complex::resize(), octave_float_scalar::resize(), octave_float_complex::resize(), octave_uint64_scalar::resize(), octave_scalar::resize(), octave_cell::save_ascii(), octave_char_matrix_str::save_ascii(), octave_cell::save_binary(), octave_complex_matrix::save_binary(), octave_float_complex_matrix::save_binary(), octave_float_matrix::save_binary(), octave_matrix::save_binary(), octave_char_matrix_str::save_binary(), octave_cell::save_hdf5(), octave_char_matrix_str::save_hdf5(), save_mat5_binary_element(), Array< T >::sort(), octave_cell::subsasgn(), and octave_struct::subsasgn().

◆ operator()() [1/2]

octave_idx_type& dim_vector::operator() ( int  i)
inline

Definition at line 345 of file dim-vector.h.

References elem.

◆ operator()() [2/2]

octave_idx_type dim_vector::operator() ( int  i) const
inline

Definition at line 347 of file dim-vector.h.

References elem.

◆ operator=() [1/2]

dim_vector& dim_vector::operator= ( const dim_vector dv)
inline

Definition at line 286 of file dim-vector.h.

References Array< T >::rep, and rep.

◆ operator=() [2/2]

dim_vector& dim_vector::operator= ( dim_vector &&  dv)
inline

Definition at line 300 of file dim-vector.h.

References Array< T >::rep.

◆ redim()

dim_vector dim_vector::redim ( int  n) const

Force certain dimensionality, preserving numel ().

Missing dimensions are set to 1, redundant are folded into the trailing one. If n = 1, the result is 2d and the second dim is 1 (dim_vectors are always at least 2D).

Definition at line 245 of file dim-vector.cc.

References alloc(), n, ndims(), Array< T >::rep, rep, and retval.

Referenced by Array< T >::as_matrix(), Array< T >::assign(), octave_base_matrix< MT >::assign(), compute_index(), convolve(), octave::dims_to_numel(), do_bsxfun_op(), do_inplace_bsxfun_op(), Fcell2struct(), Fdot(), Find2sub(), Fsize(), MArray< T >::idx_add_nd(), Sparse< T >::index(), Array< T >::index(), Array< T >::insert(), Array< T >::resize(), sub2ind(), octave_cell::subsasgn(), octave_struct::subsasgn(), and octave::tree_evaluator::visit_simple_for_command().

◆ resize()

void dim_vector::resize ( int  n,
int  fill_value = 0 
)
inline

Definition at line 349 of file dim-vector.h.

References len, n, Array< T >::ndims(), r, and Array< T >::rep.

Referenced by octave_map::cat(), compute_array_dimensions(), concat(), convert_cdata(), mxArray_matlab::dims_to_dim_vector(), do_accumdim_sum(), do_bsxfun_op(), octave_map::do_cat(), do_num2cell_helper(), do_rand(), octave::end_value(), Fbsxfun(), Fcell(), Fcell2struct(), fill_matrix(), Fresize(), Fstruct2cell(), get_dim_vector(), octave::get_dimensions(), octave_base_int_matrix< T >::load_ascii(), octave_bool_matrix::load_ascii(), octave_cell::load_ascii(), octave_complex_matrix::load_ascii(), octave_float_complex_matrix::load_ascii(), octave_float_matrix::load_ascii(), octave_matrix::load_ascii(), octave_char_matrix_str::load_ascii(), octave_struct::load_ascii(), octave_bool_matrix::load_binary(), octave_cell::load_binary(), octave_complex_matrix::load_binary(), octave_float_complex_matrix::load_binary(), octave_float_matrix::load_binary(), octave_matrix::load_binary(), octave_char_matrix_str::load_binary(), octave_struct::load_binary(), octave_base_int_matrix< T >::load_binary(), octave_bool_matrix::load_hdf5(), octave_cell::load_hdf5(), octave_complex_matrix::load_hdf5(), octave_float_complex_matrix::load_hdf5(), octave_float_matrix::load_hdf5(), octave_matrix::load_hdf5(), octave_char_matrix_str::load_hdf5(), octave_base_int_matrix< T >::load_hdf5_internal(), Array< T >::permute(), read_mat5_binary_element(), Sparse< T >::reshape(), single_type_concat(), Array< T >::sort(), Array< T >::squeeze(), and zero_dims_inquire().

◆ resizerep()

octave_idx_type* dim_vector::resizerep ( int  n,
octave_idx_type  fill_value 
)
inlineprivate

Clone and resize this->rep to length n, filling by given value.

Definition at line 139 of file dim-vector.h.

References n, Array< T >::ndims(), r, and Array< T >::rep.

◆ safe_numel()

octave_idx_type dim_vector::safe_numel ( void  ) const

The following function will throw a std::bad_alloc () exception if the requested size is larger than can be indexed by octave_idx_type.

This may be smaller than the actual amount of memory that can be safely allocated on a system. However, if we don't fail here, we can end up with a mysterious crash inside a function that is iterating over an array using octave_idx_type indices.

Definition at line 115 of file dim-vector.cc.

References dim_max(), idx_max, n, ndims(), and rep.

Referenced by Array< T >::Array(), Sparse< T >::Sparse(), Array< T >::clear(), octave_base_sparse< T >::numel(), and Sparse< T >::numel().

◆ squeeze()

dim_vector dim_vector::squeeze ( void  ) const

Definition at line 134 of file dim-vector.cc.

References as_row(), chop_all_singletons(), elem(), ndims(), and xelem().

Referenced by octave_map::squeeze().

◆ str()

◆ to_jit()

octave_idx_type* dim_vector::to_jit ( void  ) const
inline

Definition at line 257 of file dim-vector.h.

References Array< T >::rep.

Referenced by Array< T >::jit_dimensions().

◆ xelem() [1/2]

octave_idx_type& dim_vector::xelem ( int  i)
inline

Definition at line 227 of file dim-vector.h.

References Array< T >::rep.

Referenced by num_ones(), squeeze(), and str().

◆ xelem() [2/2]

octave_idx_type dim_vector::xelem ( int  i) const
inline

Definition at line 229 of file dim-vector.h.

References Array< T >::rep.

◆ zero_by_zero()

Friends And Related Function Documentation

◆ operator==

bool operator== ( const dim_vector a,
const dim_vector b 
)
friend

Definition at line 585 of file dim-vector.h.

Member Data Documentation

◆ rep

octave_idx_type* dim_vector::rep
private

Definition at line 98 of file dim-vector.h.

Referenced by chop_all_singletons(), concat(), hvcat(), operator=(), redim(), and safe_numel().


The documentation for this class was generated from the following files: