GNU Octave
4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
#include "dim-vector.h"
Static Public Member Functions | |
static dim_vector | alloc (int n) |
static octave_idx_type | dim_max (void) |
Private Member Functions | |
octave_idx_type * | clonerep (void) |
Clone this->rep. More... | |
octave_idx_type & | count (void) const |
void | freerep (void) |
Free the rep. More... | |
void | make_unique (void) |
octave_idx_type & | ndims (void) const |
octave_idx_type * | resizerep (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_type * | newrep (int ndims) |
Construct a new rep with count = 1 and ndims given. More... | |
static octave_idx_type * | nil_rep (void) |
Private Attributes | |
octave_idx_type * | rep |
Friends | |
bool | operator== (const dim_vector &a, const dim_vector &b) |
Definition at line 53 of file dim-vector.h.
|
inline |
Construct dim_vector for 2 dimensional array.
It can be used to construct a 2D array. Example:
The constructed dim_vector dv
will have two elements, , one for each dimension. It can then be used to construct a Matrix with such dimensions, i.e., 7 rows and 5 columns.
There are constructors available for up to 7 dimensions. For a higher number of dimensions, use redim() or resize().
Note that that there is no constructor for a 1 element dim_vector. This is because there are no 1 dimensional Array in liboctave. Such constructor did exist in liboctave but was removed in version 4.0.0 due to its potential for confusion.
Definition at line 174 of file dim-vector.h.
|
inline |
Construct dim_vector for 3 dimensional array.
It can be used to construct a 3D array. Example:
This will construct a 3 dimensional NDArray of lengths 7, 5, and 4, on the first, second, and third dimension (rows, columns, and pages) respectively.
Definition at line 186 of file dim-vector.h.
|
inline |
Construct dim_vector for 4 dimensional array.
Definition at line 188 of file dim-vector.h.
|
inline |
Construct dim_vector for 5 dimensional array.
Definition at line 190 of file dim-vector.h.
|
inline |
Construct dim_vector for 6 dimensional array.
Definition at line 192 of file dim-vector.h.
|
inline |
Construct dim_vector for 7 dimensional array.
Definition at line 194 of file dim-vector.h.
|
inlineexplicit |
|
inline |
Definition at line 250 of file dim-vector.h.
|
inlineexplicit |
Definition at line 254 of file dim-vector.h.
|
inline |
Definition at line 275 of file dim-vector.h.
|
inline |
Definition at line 349 of file dim-vector.h.
Referenced by octave_value_list::all_scalars(), octave_base_sparse< T >::print_as_scalar(), octave_base_matrix< MT >::print_as_scalar(), octave_base_diag< DMT, MT >::print_as_scalar(), and octave_perm_matrix::print_as_scalar().
|
inline |
Definition at line 304 of file dim-vector.h.
Referenced by octave_map::concat(), do_fft2(), do_fftn(), octave_rand::do_float_nd_array(), octave_rand::do_nd_array(), idx_vector::idx_mask_rep::idx_mask_rep(), idx_vector::idx_vector_rep::idx_vector_rep(), oct_catop_matrix_struct(), and oct_catop_struct_matrix().
|
inlinestatic |
Definition at line 256 of file dim-vector.h.
References OCTREFCOUNT_ATOMIC_INCREMENT.
Referenced by Array< T >::assign(), convolve(), do_mat2cell(), do_mat2cell_nd(), symbol_table::do_workspace_info(), Fbase64_decode(), Fblkmm(), Freshape(), Fvec(), get_dims_str(), get_red_dims(), Array< T >::index(), Array< T >::permute(), redim(), patch::properties::update_data(), and zero_dims_inquire().
|
inline |
Definition at line 385 of file dim-vector.h.
Referenced by Array< T >::resize().
|
inline |
Definition at line 331 of file dim-vector.h.
Referenced by do_fft(), Farrayfun(), Fcellfun(), octave_base_sparse< T >::print_as_scalar(), octave_base_matrix< MT >::print_as_scalar(), octave_base_diag< DMT, MT >::print_as_scalar(), octave_perm_matrix::print_as_scalar(), print_empty_nd_array(), and single_type_concat().
|
inline |
Definition at line 414 of file dim-vector.h.
|
inline |
Definition at line 422 of file dim-vector.h.
References elem, and jit_convention::length.
void dim_vector::chop_all_singletons | ( | void | ) |
Definition at line 43 of file dim-vector.cc.
References make_unique(), ndims(), and rep.
Referenced by Array< T >::assign(), and zero_dims_inquire().
|
inline |
Definition at line 214 of file dim-vector.h.
Referenced by Array< octave_value >::Array(), Array< T >::Array(), Array< T >::assign(), Array< T >::clear(), concat(), do_mx_minmax_op(), do_rand(), Fcell(), fill_matrix(), Array< T >::index(), make_vector_dims(), and Array< T >::nth_element().
|
inlineprivate |
Clone this->rep.
Definition at line 79 of file dim-vector.h.
|
inline |
Compute a linear index from an index tuple.
Definition at line 448 of file dim-vector.h.
Referenced by compute_index(), Array< octave_value >::compute_index_unchecked(), do_bsxfun_op(), and do_inplace_bsxfun_op().
|
inline |
Ditto, but the tuple may be incomplete (nidx < length ()).
Definition at line 459 of file dim-vector.h.
bool dim_vector::concat | ( | const dim_vector & | dvb, |
int | dim | ||
) |
This corresponds to cat().
Definition at line 177 of file dim-vector.cc.
References chop_trailing_singletons(), make_unique(), match(), ndims(), rep, and resize().
Referenced by octave_map::cat(), Sparse< T >::cat(), Array< T >::cat(), do_cat(), and hvcat().
|
inlineprivate |
Definition at line 63 of file dim-vector.h.
|
inline |
Compute a linear index from an index tuple.
Dimensions are required to be cumulative.
Definition at line 504 of file dim-vector.h.
Referenced by do_bsxfun_op(), and do_inplace_bsxfun_op().
|
inline |
Return cumulative dimensions.
Definition at line 489 of file dim-vector.h.
Referenced by convolve(), do_bsxfun_op(), and do_inplace_bsxfun_op().
|
static |
Definition at line 37 of file dim-vector.cc.
References max().
Referenced by Fsizemax(), and safe_numel().
|
inline |
Definition at line 197 of file dim-vector.h.
Referenced by num_ones(), squeeze(), and str().
|
inline |
Definition at line 206 of file dim-vector.h.
|
inline |
Definition at line 320 of file dim-vector.h.
Definition at line 435 of file dim-vector.h.
Referenced by do_accumdim_sum(), do_cellslices_nda(), do_diff(), Fcellslices(), Fdot(), Fnth_element(), Fsort(), MArray< T >::idx_add_nd(), SparseMatrix::max(), SparseComplexMatrix::max(), SparseMatrix::min(), and SparseComplexMatrix::min().
|
inlineprivate |
Free the rep.
Definition at line 122 of file dim-vector.h.
bool dim_vector::hvcat | ( | const dim_vector & | dvb, |
int | dim | ||
) |
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
Definition at line 241 of file dim-vector.cc.
References concat(), dim_vector(), length(), and rep.
Referenced by Sparse< T >::cat(), Array< T >::cat(), and do_cat().
|
inline |
Definition at line 474 of file dim-vector.h.
Referenced by do_bsxfun_op(), do_inplace_bsxfun_op(), do_mat2cell(), and do_mat2cell_nd().
|
inline |
Definition at line 430 of file dim-vector.h.
References elem, and jit_convention::length.
Referenced by Fdot(), Fissorted(), Range::index(), Array< T >::index(), Array< octave_value >::is_vector(), and idx_vector::is_vector().
|
inline |
Definition at line 281 of file dim-vector.h.
Referenced by all_colon_equiv(), Array< octave_value >::as_column(), Array< octave_value >::as_matrix(), Array< octave_value >::as_row(), Array< T >::assign(), Array< T >::cat(), check_dimensions(), OCTAVE_VALUE_INT_MATRIX_T::complex_matrix_value(), convert_packcomplex_Nd(), Array< T >::diag(), do_accumdim_sum(), do_cat(), do_cellslices_nda(), do_diff(), do_fft(), do_fft2(), do_fftn(), do_mx_minmax_op(), do_num2cell_helper(), do_trilu(), symbol_table::do_workspace_info(), Fblkmm(), Fbsxfun(), Fcellslices(), Fellipj(), Fend(), Ffilter(), fill_matrix(), filter(), Find2sub(), Fiscolumn(), Fismatrix(), Fisrow(), Fissquare(), Fisvector(), OCTAVE_VALUE_INT_MATRIX_T::float_complex_matrix_value(), OCTAVE_VALUE_INT_MATRIX_T::float_matrix_value(), ComplexNDArray::fourier(), FloatComplexNDArray::fourier(), FloatNDArray::fourier(), NDArray::fourier(), ComplexNDArray::fourier2d(), FloatComplexNDArray::fourier2d(), FloatNDArray::fourier2d(), NDArray::fourier2d(), ComplexNDArray::fourierNd(), FloatComplexNDArray::fourierNd(), FloatNDArray::fourierNd(), NDArray::fourierNd(), freeze(), Fsize(), Fstruct2cell(), get_dims_str(), get_ra_idx(), get_red_dims(), get_vec_dims(), hvcat(), idx_vector::idx_mask_rep::idx_mask_rep(), idx_vector::idx_vector_rep::idx_vector_rep(), ComplexNDArray::ifourier(), FloatComplexNDArray::ifourier(), FloatNDArray::ifourier(), NDArray::ifourier(), ComplexNDArray::ifourier2d(), FloatComplexNDArray::ifourier2d(), FloatNDArray::ifourier2d(), NDArray::ifourier2d(), ComplexNDArray::ifourierNd(), FloatComplexNDArray::ifourierNd(), FloatNDArray::ifourierNd(), NDArray::ifourierNd(), increment_index(), ind2sub(), index_in_bounds(), tm_const::init(), ComplexNDArray::insert(), FloatComplexNDArray::insert(), is_scalar(), is_valid_bsxfun(), is_valid_inplace_bsxfun(), is_vector(), isvector(), octave_value::length(), make_vector_dims(), mat2cell_mismatch(), OCTAVE_VALUE_INT_MATRIX_T::matrix_value(), SparseMatrix::max(), SparseComplexMatrix::max(), maybe_update_column(), SparseMatrix::min(), SparseComplexMatrix::min(), octave_base_value::ndims(), Array< octave_value >::ndims(), Sparse< bool >::ndims(), Array< T >::nth_element(), num_ones(), operator<<(), Array< T >::permute(), rec_index_helper::rec_index_helper(), rec_resize_helper::rec_resize_helper(), redim(), Sparse< T >::reshape(), octave_base_diag< DMT, MT >::resize(), Sparse< T >::resize(), Array< T >::resize(), safe_numel(), octave_base_int_matrix< T >::save_ascii(), octave_struct::save_ascii(), octave_float_complex_matrix::save_ascii(), octave_char_matrix_str::save_ascii(), octave_complex_matrix::save_ascii(), octave_cell::save_ascii(), octave_float_matrix::save_ascii(), octave_bool_matrix::save_ascii(), octave_matrix::save_ascii(), octave_scalar_struct::save_ascii(), octave_base_int_matrix< T >::save_binary(), octave_sparse_bool_matrix::save_binary(), octave_struct::save_binary(), octave_sparse_complex_matrix::save_binary(), octave_sparse_matrix::save_binary(), octave_float_complex_matrix::save_binary(), octave_char_matrix_str::save_binary(), octave_complex_matrix::save_binary(), octave_cell::save_binary(), octave_float_matrix::save_binary(), octave_bool_matrix::save_binary(), octave_matrix::save_binary(), octave_base_int_matrix< T >::save_hdf5(), octave_float_complex_matrix::save_hdf5(), octave_char_matrix_str::save_hdf5(), octave_complex_matrix::save_hdf5(), octave_cell::save_hdf5(), octave_float_matrix::save_hdf5(), octave_bool_matrix::save_hdf5(), octave_matrix::save_hdf5(), save_hdf5_empty(), scalar(), octave_class::size(), octave_base_value::size(), octave_lazy_index::sort(), Array< T >::sort(), idx_vector::idx_vector_rep::sort_uniq_clone(), Sparse< T >::Sparse(), squeeze(), str(), try_cellfun_internal_ops(), update_index(), array_property::validate(), vector_equivalent(), and zero_dims_inquire().
|
inlineprivate |
Definition at line 128 of file dim-vector.h.
References OCTREFCOUNT_ATOMIC_DECREMENT.
Referenced by chop_all_singletons(), and concat().
|
inlineprivate |
Definition at line 61 of file dim-vector.h.
Referenced by chop_all_singletons(), and concat().
|
inlinestaticprivate |
Construct a new rep with count = 1 and ndims given.
Definition at line 67 of file dim-vector.h.
|
inlinestaticprivate |
Definition at line 237 of file dim-vector.h.
int dim_vector::num_ones | ( | void | ) | const |
Definition at line 81 of file dim-vector.cc.
|
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 361 of file dim-vector.h.
Referenced by airy(), betainc(), betaincinv(), biry(), compute_index(), convert_packcomplex_Nd(), octave_base_int_matrix< T >::convert_to_str_internal(), octave_sparse_matrix::convert_to_str_internal(), octave_float_matrix::convert_to_str_internal(), octave_matrix::convert_to_str_internal(), dims_to_numel(), do_bessel(), do_bsxfun_op(), do_inplace_bsxfun_op(), do_object2cell(), Fbsxfun(), octave_fftw::fftNd(), filter(), Fregexprep(), Freshape(), gammainc(), get_ra_idx(), octave_fftw::ifftNd(), ind2sub(), octave_base_sparse< T >::is_true(), octave_base_matrix< MT >::is_true(), octave_char_matrix_str::load_ascii(), octave_cell::load_ascii(), octave_base_int_matrix< T >::load_binary(), octave_float_complex_matrix::load_binary(), octave_char_matrix_str::load_binary(), octave_complex_matrix::load_binary(), octave_cell::load_binary(), octave_float_matrix::load_binary(), octave_bool_matrix::load_binary(), octave_matrix::load_binary(), octave_cell::load_hdf5(), octave_bool_matrix::load_hdf5(), make_vector_dims(), octave_class::numel(), octave_base_value::numel(), octave_print_internal_template(), read_mat5_binary_element(), Sparse< T >::reshape(), octave_float_complex::resize(), octave_complex::resize(), octave_scalar::resize(), octave_float_scalar::resize(), octave_bool::resize(), OCTAVE_VALUE_INT_SCALAR_T::resize(), octave_char_matrix_str::save_ascii(), octave_cell::save_ascii(), octave_float_complex_matrix::save_binary(), octave_char_matrix_str::save_binary(), octave_complex_matrix::save_binary(), octave_cell::save_binary(), octave_float_matrix::save_binary(), octave_matrix::save_binary(), octave_char_matrix_str::save_hdf5(), octave_cell::save_hdf5(), save_mat5_binary_element(), and Array< T >::sort().
|
inline |
Definition at line 283 of file dim-vector.h.
|
inline |
Definition at line 285 of file dim-vector.h.
References OCTREFCOUNT_ATOMIC_DECREMENT.
|
inline |
Definition at line 261 of file dim-vector.h.
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 266 of file dim-vector.cc.
References alloc(), length(), and rep.
Referenced by Array< octave_value >::as_matrix(), octave_base_matrix< MT >::assign(), Array< T >::assign(), compute_index(), convolve(), dims_to_numel(), do_bsxfun_op(), do_inplace_bsxfun_op(), Fcell2struct(), Fdot(), Find2sub(), Fsize(), Fsub2ind(), MArray< T >::idx_add_nd(), Array< T >::index(), Sparse< T >::index(), Array< T >::insert(), Array< T >::resize(), sub2ind(), octave_struct::subsasgn(), octave_cell::subsasgn(), and tree_evaluator::visit_simple_for_command().
Definition at line 287 of file dim-vector.h.
Referenced by octave_map::cat(), concat(), mxArray_matlab::dims_to_dim_vector(), do_accumdim_sum(), do_bsxfun_op(), octave_map::do_cat(), do_num2cell_helper(), do_rand(), Fbsxfun(), Fcell(), Fend(), fill_matrix(), freeze(), Fresize(), Fstruct2cell(), get_dim_vector(), get_dimensions(), get_object_dims(), octave_base_int_matrix< T >::load_ascii(), octave_struct::load_ascii(), octave_float_complex_matrix::load_ascii(), octave_char_matrix_str::load_ascii(), octave_complex_matrix::load_ascii(), octave_cell::load_ascii(), octave_float_matrix::load_ascii(), octave_bool_matrix::load_ascii(), octave_matrix::load_ascii(), octave_base_int_matrix< T >::load_binary(), octave_float_complex_matrix::load_binary(), octave_char_matrix_str::load_binary(), octave_complex_matrix::load_binary(), octave_cell::load_binary(), octave_float_matrix::load_binary(), octave_bool_matrix::load_binary(), octave_matrix::load_binary(), octave_base_int_matrix< T >::load_hdf5(), octave_float_complex_matrix::load_hdf5(), octave_char_matrix_str::load_hdf5(), octave_complex_matrix::load_hdf5(), octave_cell::load_hdf5(), octave_float_matrix::load_hdf5(), octave_bool_matrix::load_hdf5(), octave_matrix::load_hdf5(), load_hdf5_empty(), Array< T >::nth_element(), Array< T >::permute(), read_mat5_binary_element(), Sparse< T >::reshape(), single_type_concat(), Array< T >::sort(), Array< T >::squeeze(), squeeze(), and zero_dims_inquire().
|
inlineprivate |
Clone and resize this->rep to length n, filling by given value.
Definition at line 96 of file dim-vector.h.
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 93 of file dim-vector.cc.
References dim_max(), idx_max, length(), and rep.
Referenced by Array< T >::Array(), Array< T >::clear(), octave_base_sparse< SparseComplexMatrix >::numel(), Sparse< bool >::numel(), and Sparse< T >::Sparse().
dim_vector dim_vector::squeeze | ( | void | ) | const |
Definition at line 112 of file dim-vector.cc.
References dim_vector(), elem(), length(), and resize().
Referenced by octave_map::squeeze().
Definition at line 63 of file dim-vector.cc.
References elem(), and length().
Referenced by Array< T >::Array(), cbuni(), do_bsxfun_op(), symbol_table::do_workspace_info(), octave_base_value::dump(), eval_error(), Fblkmm(), gammainc(), get_dims_str(), gripe_betainc_nonconformant(), gripe_betaincinv_nonconformant(), gripe_nonconformant(), operator<<(), print_empty_nd_array(), octave_struct::print_raw(), octave_cell::print_raw(), octave_scalar_struct::print_raw(), Sparse< T >::reshape(), zacon(), zairy(), zasyi(), zbesh(), zbesi(), zbesj(), zbesy(), zbiry(), zbknu(), zbuni(), zkscl(), zmlri(), zseri(), zunhj(), zuni1(), zuni2(), zunik(), zunk1(), zunk2(), zuoik(), and zwrsk().
|
inline |
Definition at line 230 of file dim-vector.h.
Referenced by Array< octave_value >::jit_dimensions().
|
inline |
Definition at line 326 of file dim-vector.h.
Referenced by Array< T >::assign(), Array< T >::cat(), tm_row_const::tm_row_const_rep::cellify(), tm_row_const::tm_row_const_rep::do_init_element(), and tm_row_const::tm_row_const_rep::init().
|
friend |
Definition at line 519 of file dim-vector.h.
|
private |
Definition at line 59 of file dim-vector.h.
Referenced by chop_all_singletons(), concat(), dim_vector(), hvcat(), redim(), and safe_numel().