IT++ 4.3.1
|
General array class. More...
#include <itpp/base/array.h>
Public Member Functions | |
Array (const Factory &f=DEFAULT_FACTORY) | |
Default constructor. An element factory f can be specified. | |
Array (int n, const Factory &f=DEFAULT_FACTORY) | |
Create an Array of size n . An element factory f can be specified. | |
Array (const Array< T > &a, const Factory &f=DEFAULT_FACTORY) | |
Copy constructor. An element factory f can be specified. | |
Array (const std::string &values, const Factory &f=DEFAULT_FACTORY) | |
Create an Array from string. An element factory f can be specified. | |
Array (const char *values, const Factory &f=DEFAULT_FACTORY) | |
Create an Array from char*. An element factory f can be specified. | |
virtual | ~Array () |
Destructor. | |
T & | operator() (int i) |
Get the i element. | |
const T & | operator() (int i) const |
Get the i element. | |
const Array< T > | operator() (int i1, int i2) const |
Sub-array from element i1 to element i2 . | |
const Array< T > | operator() (const Array< int > &indices) const |
Sub-array with the elements given by the integer Array. | |
Array< T > | left (int n) const |
Get n left elements of the array. | |
Array< T > | right (int n) const |
Get n right elements of the array. | |
Array< T > | mid (int pos, int n) const |
Get n elements of the array starting from pos . | |
Array< T > & | operator= (const T &e) |
Assignment operator. | |
Array< T > & | operator= (const Array< T > &a) |
Assignment operator. | |
Array< T > & | operator= (const char *values) |
Assignment operator. | |
int | size () const |
Returns the number of data elements in the array object. | |
int | length () const |
Returns the number of data elements in the array object. | |
void | set_size (int n, bool copy=false) |
Resizing an Array<T>. | |
void | set_length (int n, bool copy=false) |
Resizing an Array<T>. | |
T | shift_right (const T &e) |
Shift in data at position 0. Return data from the last position. | |
const Array< T > | shift_right (const Array< T > &a) |
Shift in array at position 0. Return data from the last position. | |
T | shift_left (const T &e) |
Shift in data at the last position. Return data from position 0. | |
const Array< T > | shift_left (const Array< T > &a) |
Shift in array at the last position. Return data from position 0. | |
void | swap (int i, int j) |
Swap elements i and j. | |
void | set_subarray (int i1, int i2, const Array< T > &a) |
Set the subarray defined by indicies i1 to i2 to Array<T> a. | |
void | set_subarray (int i1, int i2, const T &t) |
Set the subarray defined by indicies i1 to i2 the element value t. | |
Protected Member Functions | |
void | alloc (int n) |
Allocate storage for an array of length n . | |
void | free () |
Free the storage space allocated by the array. | |
bool | in_range (int i) const |
Check whether index i is in the allowed range. | |
Protected Attributes | |
int | ndata |
The current number of elements in the Array. | |
T * | data |
A pointer to the data area. | |
const Factory & | factory |
Element factory (by default set to DEFAULT_FACTORY) | |
Friends | |
const Array< T > | concat (const Array< T > &a1, const T &e) |
Append element e to the end of the Array a . | |
const Array< T > | concat (const T &e, const Array< T > &a) |
Concat element e to the beginning of the Array a . | |
const Array< T > | concat (const Array< T > &a1, const Array< T > &a2) |
Concat Arrays a1 and a2 . | |
const Array< T > | concat (const Array< T > &a1, const Array< T > &a2, const Array< T > &a3) |
Concat Arrays a1 , a2 and a3 . | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<class T> | |
std::ostream & | operator<< (std::ostream &os, const Array< T > &a) |
Output stream for Array<T>. T must have ostream operator<< defined. | |
template<class T> | |
std::istream & | operator>> (std::istream &is, Array< T > &a) |
Input stream for Array<T>. T must have istream operator>> defined. | |
template<class T> | |
void | set_array (Array< T > &a, const char *values) |
Assign a C-style string to an Array<T>. T must have istream operator>> defined. | |
template<class T> | |
void | set_array (Array< T > &a, const std::string &str) |
Assign a string to an Array<T>. T must have istream operator>> defined. | |
General array class.
This class is a general linear array class for arbitrary types. The operations and functions are the same as for the vector Vec
class (except for the arithmetics).
For rarely used types you will need to instantiate the class by
The following example shows how to define an Array of vectors:
For types T with istream operator>>
defined special constructor or operator=
or set_array
functions (see Related Functions) can be used to assign a string literal to an Array. The string literal has the same format that is used by the istream/ostream operators:
By default, Array elements are created using the default constructor for the element type. This can be changed by specifying a suitable Factory in the Array constructor call (see Detailed Description for Factory).
|
inlineexplicit |
Default constructor. An element factory f
can be specified.
Definition at line 217 of file array.h.
References data, factory, and ndata.
Referenced by Array(), concat, concat, concat, concat, left(), mid(), operator()(), operator()(), operator=(), operator=(), operator=(), right(), set_subarray(), shift_left(), and shift_right().
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
|
inline |
Get the i
element.
Definition at line 290 of file array.h.
References data, in_range(), and it_assert_debug.
|
inline |
Get the i
element.
Definition at line 297 of file array.h.
References data, in_range(), and it_assert_debug.
|
inline |
Sub-array from element i1
to element i2
.
Definition at line 304 of file array.h.
References Array(), data, in_range(), it_assert_debug, and ndata.
|
inline |
Sub-array with the elements given by the integer Array.
Definition at line 315 of file array.h.
References Array(), data, in_range(), it_assert_debug, and size().
Array< T > itpp::Array< T >::left | ( | int | n | ) | const |
Get n
left elements of the array.
Definition at line 357 of file array.h.
References Array(), data, in_range(), and it_assert_debug.
Referenced by itpp::Modulator_NCD::get_symbols(), and itpp::Modulator_NRD::get_symbols().
Array< T > itpp::Array< T >::right | ( | int | n | ) | const |
Get n
right elements of the array.
Definition at line 367 of file array.h.
References Array(), data, in_range(), it_assert_debug, and ndata.
Array< T > itpp::Array< T >::mid | ( | int | pos, |
int | n ) const |
|
inline |
|
inline |
Array< T > & itpp::Array< T >::operator= | ( | const char * | values | ) |
|
inline |
Returns the number of data elements in the array object.
Definition at line 155 of file array.h.
References ndata.
Referenced by itpp::MOG_diag::avg_log_lhood(), itpp::MOG_generic::avg_log_lhood(), itpp::TDL_Channel::calc_frequency_response(), itpp::TDL_Channel::calc_impulse_response(), itpp::MOG_generic::check_array_uniformity(), concat, concat, concat, concat, itpp::MOG_diag::enable_c_access(), itpp::MOG_diag::enable_c_access(), itpp::MOG_generic::init(), itpp::MOG_generic::init(), itpp::MOG_generic::init(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile_old::low_level_read(), itpp::it_ifile_old::low_level_read(), itpp::it_ifile::low_level_read_hi(), itpp::it_ifile_old::low_level_read_hi(), itpp::it_ifile::low_level_read_lo(), itpp::it_ifile_old::low_level_read_lo(), itpp::it_ifile_old::low_level_read_lo(), itpp::it_file::low_level_write(), itpp::it_file::low_level_write(), itpp::it_file::low_level_write(), itpp::it_file::low_level_write(), itpp::it_file::low_level_write(), itpp::it_file_old::low_level_write(), itpp::it_file_old::low_level_write(), itpp::it_file_old::low_level_write(), itpp::it_file_old::low_level_write(), itpp::lshift_fix(), itpp::MOG_diag_EM_sup::ml(), operator()(), itpp::Array< DOPPLER_SPECTRUM >::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::operator<<(), itpp::Array< DOPPLER_SPECTRUM >::operator>>(), itpp::Circular_Buffer< T >::put(), itpp::rshift_fix(), itpp::rshift_fix(), itpp::MOG_diag_kmeans_sup::run(), itpp::MOG_generic::set_diag_covs_internal(), itpp::set_fix(), itpp::set_fix(), itpp::set_fix(), itpp::set_fix(), itpp::MOG_generic::set_full_covs_internal(), itpp::MOG_generic::set_means_internal(), set_size(), itpp::to(), and itpp::unfix().
|
inline |
Returns the number of data elements in the array object.
Definition at line 157 of file array.h.
References ndata.
Referenced by itpp::BCH::BCH().
void itpp::Array< T >::set_size | ( | int | n, |
bool | copy = false ) |
Resizing an Array<T>.
Definition at line 257 of file array.h.
References alloc(), data, itpp::destroy_elements(), free(), it_assert_debug, itpp::min(), ndata, and size().
Referenced by itpp::BCH::BCH(), itpp::TDL_Channel::calc_frequency_response(), itpp::TDL_Channel::calc_impulse_response(), itpp::LDPC_Parity_Unstructured::cycle_removal_MGW(), itpp::TDL_Channel::discretize(), itpp::TDL_Channel::generate(), itpp::Circular_Buffer< T >::get(), itpp::Modulator_NCD::init_soft_demodulator(), itpp::Modulator_NRD::init_soft_demodulator(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read(), itpp::it_ifile_old::low_level_read(), itpp::it_ifile_old::low_level_read(), itpp::it_ifile::low_level_read_hi(), itpp::it_ifile_old::low_level_read_hi(), itpp::it_ifile::low_level_read_lo(), itpp::it_ifile_old::low_level_read_lo(), itpp::it_ifile_old::low_level_read_lo(), itpp::MOG_diag_EM_sup::ml(), itpp::GFX::operator*=(), operator=(), operator=(), itpp::Array< DOPPLER_SPECTRUM >::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::operator>>(), itpp::Circular_Buffer< T >::peek(), itpp::Circular_Buffer< T >::peek(), itpp::Circular_Buffer< T >::peek_reverse(), itpp::MOG_diag_kmeans_sup::run(), itpp::MOG_generic::set_diag_covs_unity_internal(), itpp::set_fix(), itpp::set_fix(), itpp::set_fix(), itpp::set_fix(), itpp::MOG_generic::set_full_covs_unity_internal(), set_length(), itpp::ND_UPAM::set_M(), itpp::ND_UPSK::set_M(), itpp::ND_UQAM::set_M(), itpp::MOG_generic::set_means_zero_internal(), and itpp::MOG_generic::setup_covs().
|
inline |
T itpp::Array< T >::shift_right | ( | const T & | e | ) |
Shift in data at position 0. Return data from the last position.
Definition at line 388 of file array.h.
References data, it_assert_debug, and ndata.
const Array< T > itpp::Array< T >::shift_right | ( | const Array< T > & | a | ) |
T itpp::Array< T >::shift_left | ( | const T & | e | ) |
const Array< T > itpp::Array< T >::shift_left | ( | const Array< T > & | a | ) |
void itpp::Array< T >::swap | ( | int | i, |
int | j ) |
Swap elements i and j.
Definition at line 447 of file array.h.
References data, in_range(), and it_assert_debug.
void itpp::Array< T >::set_subarray | ( | int | i1, |
int | i2, | ||
const Array< T > & | a ) |
Set the subarray defined by indicies i1 to i2 to Array<T> a.
Definition at line 458 of file array.h.
References Array(), data, in_range(), it_assert_debug, and ndata.
void itpp::Array< T >::set_subarray | ( | int | i1, |
int | i2, | ||
const T & | t ) |
Set the subarray defined by indicies i1 to i2 the element value t.
Definition at line 472 of file array.h.
References data, in_range(), it_assert_debug, and ndata.
|
inlineprotected |
Allocate storage for an array of length n
.
Definition at line 197 of file array.h.
References itpp::create_elements(), data, factory, and ndata.
Referenced by Array(), Array(), and set_size().
|
inlineprotected |
Free the storage space allocated by the array.
Definition at line 210 of file array.h.
References data, itpp::destroy_elements(), and ndata.
Referenced by set_size(), and ~Array().
|
inlineprotected |
Check whether index i
is in the allowed range.
Definition at line 185 of file array.h.
References ndata.
Referenced by left(), operator()(), operator()(), operator()(), operator()(), right(), set_subarray(), set_subarray(), and swap().
|
|
|
|
|
protected |
The current number of elements in the Array.
Definition at line 187 of file array.h.
Referenced by alloc(), Array(), Array(), Array(), Array(), Array(), free(), in_range(), length(), mid(), operator()(), operator=(), operator=(), right(), set_size(), set_subarray(), set_subarray(), shift_left(), shift_left(), shift_right(), shift_right(), and size().
|
protected |
A pointer to the data area.
Definition at line 189 of file array.h.
Referenced by alloc(), Array(), Array(), Array(), Array(), Array(), free(), left(), mid(), operator()(), operator()(), operator()(), operator()(), operator=(), operator=(), right(), set_size(), set_subarray(), set_subarray(), shift_left(), shift_left(), shift_right(), shift_right(), and swap().
|
protected |