GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
MArray< T > Class Template Reference

Template for N-dimensional array classes with like-type math operators. More...

#include "MArray.h"

Inheritance diagram for MArray< T >:
Array< T > intNDArray< octave_uint8 > intNDArray< T >

Public Member Functions

 MArray ()
 
template<typename U >
 MArray (const Array< U > &a)
 
 MArray (const dim_vector &dv)
 
 MArray (const dim_vector &dv, const T &val)
 
 MArray (const MArray< T > &a)
 
 ~MArray ()=default
 
void changesign ()
 
MArray< T > hermitian (T(*fcn)(const T &)=nullptr) const
 
void idx_add (const octave::idx_vector &idx, const MArray< T > &vals)
 
void idx_add (const octave::idx_vector &idx, T val)
 Performs indexed accumulative addition. More...
 
void idx_add_nd (const octave::idx_vector &idx, const MArray< T > &vals, int dim=-1)
 
void idx_max (const octave::idx_vector &idx, const MArray< T > &vals)
 
void idx_min (const octave::idx_vector &idx, const MArray< T > &vals)
 
MArray< T > ipermute (const Array< octave_idx_type > &vec) const
 
MArray< T > & operator= (const MArray< T > &a)
 
MArray< T > permute (const Array< octave_idx_type > &vec, bool inv=false) const
 
MArray< T > reshape (const dim_vector &new_dims) const
 
MArray squeeze () const
 
MArray< T > transpose () const
 
- Public Member Functions inherited from Array< T >
 Array ()
 Empty ctor (0 by 0). More...
 
 Array (Array< T, Alloc > &&a)
 
 Array (const Array< T, Alloc > &a)
 No type conversion case. More...
 
 Array (const Array< T, Alloc > &a, const dim_vector &dv)
 Reshape constructor. More...
 
 Array (const Array< U, A > &a)
 Type conversion case. More...
 
 Array (const Container< T > &a, const dim_vector &dv)
 Constructor from standard library sequence containers. More...
 
 Array (const dim_vector &dv)
 nD uninitialized ctor. More...
 
 Array (const dim_vector &dv, const T &val)
 nD initialized ctor. More...
 
 Array (T *ptr, const dim_vector &dv, const Alloc &xallocator=Alloc())
 
virtual ~Array ()
 
Array< T, Allocas_column () const
 Return the array as a column vector. More...
 
Array< T, Allocas_matrix () const
 Return the array as a matrix. More...
 
Array< T, Allocas_row () const
 Return the array as a row vector. More...
 
void clear ()
 
void clear (const dim_vector &dv)
 
void clear (octave_idx_type r, octave_idx_type c)
 
void fill (const T &val)
 
Array< octave_idx_typefind (octave_idx_type, bool) const
 
Array< octave_idx_typefind (octave_idx_type, bool) const
 
sortmode is_sorted_rows (sortmode) const
 
sortmode is_sorted_rows (sortmode) const
 
sortmode issorted (sortmode mode) const
 
sortmode issorted (sortmode) const
 
sortmode issorted (sortmode) const
 
Array< octave_idx_typelookup (const Array< octave::cdef_object > &, sortmode) const
 
Array< octave_idx_typelookup (const Array< octave::idx_vector > &, sortmode) const
 
octave_idx_type lookup (octave::cdef_object const &, sortmode) const
 
octave_idx_type lookup (octave::idx_vector const &, sortmode) const
 
void make_unique ()
 
octave_idx_type nnz () const
 
octave_idx_type nnz () const
 
Array< octave::cdef_object > nth_element (const octave::idx_vector &, int) const
 
Array< octave::idx_vectornth_element (const octave::idx_vector &, int) const
 
octave_idx_type numel () const
 Number of elements in the array. More...
 
Array< T, Alloc > & operator= (Array< T, Alloc > &&a)
 
Array< T, Alloc > & operator= (const Array< T, Alloc > &a)
 
Array< octave::cdef_object > sort (Array< octave_idx_type > &sidx, int, sortmode) const
 
Array< octave::idx_vectorsort (Array< octave_idx_type > &sidx, int, sortmode) const
 
Array< octave::cdef_object > sort (int, sortmode) const
 
Array< octave::idx_vectorsort (int, sortmode) const
 
Array< octave_idx_typesort_rows_idx (sortmode) const
 
Array< octave_idx_typesort_rows_idx (sortmode) const
 
octave_idx_type dim1 () const
 
octave_idx_type rows () const
 
octave_idx_type dim2 () const
 
octave_idx_type cols () const
 
octave_idx_type columns () const
 
octave_idx_type dim3 () const
 Size of the specified dimension. More...
 
octave_idx_type pages () const
 Size of the specified dimension. More...
 
size_type size (const size_type d) const
 Size of the specified dimension. More...
 
std::size_t byte_size () const
 Size of the specified dimension. More...
 
const dim_vectordims () const
 Return a const-reference so that dims ()(i) works efficiently. More...
 
Array< T, Allocsqueeze () const
 Chop off leading singleton dimensions. More...
 
octave_idx_type compute_index (octave_idx_type i, octave_idx_type j) const
 Size of the specified dimension. More...
 
octave_idx_type compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
 Size of the specified dimension. More...
 
octave_idx_type compute_index (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
octave_idx_type compute_index_unchecked (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
T & xelem (octave_idx_type n)
 Size of the specified dimension. More...
 
crefT xelem (octave_idx_type n) const
 Size of the specified dimension. More...
 
T & xelem (octave_idx_type i, octave_idx_type j)
 Size of the specified dimension. More...
 
crefT xelem (octave_idx_type i, octave_idx_type j) const
 Size of the specified dimension. More...
 
T & xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k)
 Size of the specified dimension. More...
 
crefT xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
 Size of the specified dimension. More...
 
T & xelem (const Array< octave_idx_type > &ra_idx)
 Size of the specified dimension. More...
 
crefT xelem (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
T & checkelem (octave_idx_type n)
 Size of the specified dimension. More...
 
T & checkelem (octave_idx_type i, octave_idx_type j)
 Size of the specified dimension. More...
 
T & checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k)
 Size of the specified dimension. More...
 
T & checkelem (const Array< octave_idx_type > &ra_idx)
 Size of the specified dimension. More...
 
crefT checkelem (octave_idx_type n) const
 Size of the specified dimension. More...
 
crefT checkelem (octave_idx_type i, octave_idx_type j) const
 Size of the specified dimension. More...
 
crefT checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
 Size of the specified dimension. More...
 
crefT checkelem (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
T & elem (octave_idx_type n)
 Size of the specified dimension. More...
 
T & elem (octave_idx_type i, octave_idx_type j)
 Size of the specified dimension. More...
 
T & elem (octave_idx_type i, octave_idx_type j, octave_idx_type k)
 Size of the specified dimension. More...
 
T & elem (const Array< octave_idx_type > &ra_idx)
 Size of the specified dimension. More...
 
crefT elem (octave_idx_type n) const
 Size of the specified dimension. More...
 
crefT elem (octave_idx_type i, octave_idx_type j) const
 Size of the specified dimension. More...
 
crefT elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
 Size of the specified dimension. More...
 
crefT elem (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
T & operator() (octave_idx_type n)
 Size of the specified dimension. More...
 
T & operator() (octave_idx_type i, octave_idx_type j)
 Size of the specified dimension. More...
 
T & operator() (octave_idx_type i, octave_idx_type j, octave_idx_type k)
 Size of the specified dimension. More...
 
T & operator() (const Array< octave_idx_type > &ra_idx)
 Size of the specified dimension. More...
 
crefT operator() (octave_idx_type n) const
 Size of the specified dimension. More...
 
crefT operator() (octave_idx_type i, octave_idx_type j) const
 Size of the specified dimension. More...
 
crefT operator() (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
 Size of the specified dimension. More...
 
crefT operator() (const Array< octave_idx_type > &ra_idx) const
 Size of the specified dimension. More...
 
Array< T, Alloccolumn (octave_idx_type k) const
 Extract column: A(:,k+1). More...
 
Array< T, Allocpage (octave_idx_type k) const
 Extract page: A(:,:,k+1). More...
 
Array< T, Alloclinear_slice (octave_idx_type lo, octave_idx_type up) const
 Extract a slice from this array as a column vector: A(:)(lo+1:up). More...
 
Array< T, Allocreshape (octave_idx_type nr, octave_idx_type nc) const
 Size of the specified dimension. More...
 
Array< T, Allocreshape (const dim_vector &new_dims) const
 Size of the specified dimension. More...
 
Array< T, Allocpermute (const Array< octave_idx_type > &vec, bool inv=false) const
 Size of the specified dimension. More...
 
Array< T, Allocipermute (const Array< octave_idx_type > &vec) const
 Size of the specified dimension. More...
 
bool issquare () const
 Size of the specified dimension. More...
 
bool isempty () const
 Size of the specified dimension. More...
 
bool isvector () const
 Size of the specified dimension. More...
 
bool is_nd_vector () const
 Size of the specified dimension. More...
 
Array< T, Alloctranspose () const
 Size of the specified dimension. More...
 
Array< T, Allochermitian (T(*fcn)(const T &)=nullptr) const
 Size of the specified dimension. More...
 
const T * data () const
 Size of the specified dimension. More...
 
T * fortran_vec ()
 Size of the specified dimension. More...
 
bool is_shared () const
 Size of the specified dimension. More...
 
int ndims () const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const octave::idx_vector &i) const
 Indexing without resizing. More...
 
Array< T, Allocindex (const octave::idx_vector &i, const octave::idx_vector &j) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const Array< octave::idx_vector > &ia) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const octave::idx_vector &i, bool resize_ok, const T &rfv) const
 Indexing with possible resizing and fill. More...
 
Array< T, Allocindex (const octave::idx_vector &i, bool resize_ok) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const octave::idx_vector &i, const octave::idx_vector &j, bool resize_ok, const T &rfv) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const octave::idx_vector &i, const octave::idx_vector &j, bool resize_ok) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const Array< octave::idx_vector > &ia, bool resize_ok, const T &rfv) const
 Size of the specified dimension. More...
 
Array< T, Allocindex (const Array< octave::idx_vector > &ia, bool resize_ok) const
 Size of the specified dimension. More...
 
virtual T resize_fill_value () const
 Size of the specified dimension. More...
 
void resize2 (octave_idx_type nr, octave_idx_type nc, const T &rfv)
 Resizing (with fill). More...
 
void resize2 (octave_idx_type nr, octave_idx_type nc)
 Size of the specified dimension. More...
 
void resize1 (octave_idx_type n, const T &rfv)
 Size of the specified dimension. More...
 
void resize1 (octave_idx_type n)
 Size of the specified dimension. More...
 
void resize (const dim_vector &dv, const T &rfv)
 Size of the specified dimension. More...
 
void resize (const dim_vector &dv)
 Size of the specified dimension. More...
 
void assign (const octave::idx_vector &i, const Array< T, Alloc > &rhs, const T &rfv)
 Indexed assignment (always with resize & fill). More...
 
void assign (const octave::idx_vector &i, const Array< T, Alloc > &rhs)
 Size of the specified dimension. More...
 
void assign (const octave::idx_vector &i, const octave::idx_vector &j, const Array< T, Alloc > &rhs, const T &rfv)
 Size of the specified dimension. More...
 
void assign (const octave::idx_vector &i, const octave::idx_vector &j, const Array< T, Alloc > &rhs)
 Size of the specified dimension. More...
 
void assign (const Array< octave::idx_vector > &ia, const Array< T, Alloc > &rhs, const T &rfv)
 Size of the specified dimension. More...
 
void assign (const Array< octave::idx_vector > &ia, const Array< T, Alloc > &rhs)
 Size of the specified dimension. More...
 
void delete_elements (const octave::idx_vector &i)
 Deleting elements. More...
 
void delete_elements (int dim, const octave::idx_vector &i)
 A(:,...,I,...,:) = [] (>= 2 subscripts, one of them is non-colon) More...
 
void delete_elements (const Array< octave::idx_vector > &ia)
 Dispatcher to the above two. More...
 
Array< T, Alloc > & insert (const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
 Insert an array into another at a specified position. More...
 
Array< T, Alloc > & insert (const Array< T, Alloc > &a, octave_idx_type r, octave_idx_type c)
 This is just a special case for idx = [r c 0 ...]. More...
 
void maybe_economize ()
 Size of the specified dimension. More...
 
void print_info (std::ostream &os, const std::string &prefix) const
 Size of the specified dimension. More...
 
Array< T, Allocsort (int dim=0, sortmode mode=ASCENDING) const
 Size of the specified dimension. More...
 
Array< T, Allocsort (Array< octave_idx_type > &sidx, int dim=0, sortmode mode=ASCENDING) const
 Size of the specified dimension. More...
 
sortmode issorted (sortmode mode=UNSORTED) const
 Ordering is auto-detected or can be specified. More...
 
Array< octave_idx_typesort_rows_idx (sortmode mode=ASCENDING) const
 Sort by rows returns only indices. More...
 
sortmode is_sorted_rows (sortmode mode=UNSORTED) const
 Ordering is auto-detected or can be specified. More...
 
octave_idx_type lookup (const T &value, sortmode mode=UNSORTED) const
 Do a binary lookup in a sorted array. More...
 
Array< octave_idx_typelookup (const Array< T, Alloc > &values, sortmode mode=UNSORTED) const
 Ditto, but for an array of values, specializing on the case when values are sorted. More...
 
octave_idx_type nnz () const
 Count nonzero elements. More...
 
Array< octave_idx_typefind (octave_idx_type n=-1, bool backward=false) const
 Find indices of (at most n) nonzero elements. More...
 
Array< T, Allocnth_element (const octave::idx_vector &n, int dim=0) const
 Returns the n-th element in increasing order, using the same ordering as used for sort. More...
 
Array< T, Allocdiag (octave_idx_type k=0) const
 Get the kth super or subdiagonal. More...
 
Array< T, Allocdiag (octave_idx_type m, octave_idx_type n) const
 Size of the specified dimension. More...
 
Array< U, Amap (F fcn) const
 Apply function fcn to each element of the Array<T, Alloc>. More...
 
Array< U, Amap (U(&fcn)(T)) const
 Overloads for function references. More...
 
Array< U, Amap (U(&fcn)(const T &)) const
 Size of the specified dimension. More...
 
bool test (F fcn) const
 Generic any/all test functionality with arbitrary predicate. More...
 
bool test_any (F fcn) const
 Simpler calls. More...
 
bool test_any (bool(&fcn)(T)) const
 Overloads for function references. More...
 
bool test_any (bool(&fcn)(const T &)) const
 Size of the specified dimension. More...
 
bool test_all (F fcn) const
 Size of the specified dimension. More...
 
bool test_all (bool(&fcn)(T)) const
 Size of the specified dimension. More...
 
bool test_all (bool(&fcn)(const T &)) const
 Size of the specified dimension. More...
 
bool optimize_dimensions (const dim_vector &dv)
 Returns true if this->dims () == dv, and if so, replaces this->m_dimensions by a shallow copy of dv. More...
 

Additional Inherited Members

- Public Types inherited from Array< T >
typedef bool(* compare_fcn_type) (typename ref_param< T >::type, typename ref_param< T >::type)
 
typedef ref_param< T >::type crefT
 
typedef T element_type
 
typedef octave_idx_type size_type
 Used for operator(), and returned by numel() and size() (beware: signed integer) More...
 
typedef T value_type
 
- Static Public Member Functions inherited from Array< T >
static Array< T, Alloccat (int dim, octave_idx_type n, const Array< T, Alloc > *array_list)
 Concatenation along a specified (0-based) dimension, equivalent to cat(). More...
 
- Protected Member Functions inherited from Array< T >
 Array (const Array< T, Alloc > &a, const dim_vector &dv, octave_idx_type l, octave_idx_type u)
 slice constructor More...
 
- Protected Attributes inherited from Array< T >
dim_vector m_dimensions
 
Array< T, Alloc >::ArrayRep * m_rep
 
T * m_slice_data
 
octave_idx_type m_slice_len
 

Detailed Description

template<typename T>
class MArray< T >

Template for N-dimensional array classes with like-type math operators.

Definition at line 60 of file MArray.h.

Constructor & Destructor Documentation

◆ MArray() [1/5]

template<typename T >
MArray< T >::MArray ( )
inline

Definition at line 66 of file MArray.h.

◆ MArray() [2/5]

template<typename T >
MArray< T >::MArray ( const dim_vector dv)
inlineexplicit

Definition at line 68 of file MArray.h.

◆ MArray() [3/5]

template<typename T >
MArray< T >::MArray ( const dim_vector dv,
const T &  val 
)
inlineexplicit

Definition at line 71 of file MArray.h.

◆ MArray() [4/5]

template<typename T >
MArray< T >::MArray ( const MArray< T > &  a)
inline

Definition at line 74 of file MArray.h.

◆ MArray() [5/5]

template<typename T >
template<typename U >
MArray< T >::MArray ( const Array< U > &  a)
inline

Definition at line 77 of file MArray.h.

◆ ~MArray()

template<typename T >
MArray< T >::~MArray ( )
default

Member Function Documentation

◆ changesign()

template<typename T >
void MArray< T >::changesign

◆ hermitian()

template<typename T >
MArray<T> MArray< T >::hermitian ( T(*)(const T &)  fcn = nullptr) const
inline

◆ idx_add() [1/2]

template<typename T >
void MArray< T >::idx_add ( const octave::idx_vector idx,
const MArray< T > &  vals 
)

Definition at line 82 of file MArray.cc.

References Array< T, Alloc >::data(), len, min(), n, Array< T, Alloc >::numel(), and numel().

◆ idx_add() [2/2]

template<typename T >
void MArray< T >::idx_add ( const octave::idx_vector idx,
val 
)

Performs indexed accumulative addition.

Definition at line 64 of file MArray.cc.

References len, n, and numel().

◆ idx_add_nd()

◆ idx_max()

template<typename T >
void MArray< T >::idx_max ( const octave::idx_vector idx,
const MArray< T > &  vals 
)

Definition at line 134 of file MArray.cc.

References Array< T, Alloc >::data(), len, min(), n, Array< T, Alloc >::numel(), and numel().

◆ idx_min()

template<typename T >
void MArray< T >::idx_min ( const octave::idx_vector idx,
const MArray< T > &  vals 
)

Definition at line 115 of file MArray.cc.

◆ ipermute()

template<typename T >
MArray<T> MArray< T >::ipermute ( const Array< octave_idx_type > &  vec) const
inline

Definition at line 94 of file MArray.h.

References Array< T, Alloc >::ipermute().

◆ operator=()

◆ permute()

template<typename T >
MArray<T> MArray< T >::permute ( const Array< octave_idx_type > &  vec,
bool  inv = false 
) const
inline

◆ reshape()

template<typename T >
MArray<T> MArray< T >::reshape ( const dim_vector new_dims) const
inline

◆ squeeze()

template<typename T >
MArray MArray< T >::squeeze ( ) const
inline

◆ transpose()


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