#include <itpp/base/array.h>
Public Member Functions | |
Array (const Factory &f=DEFAULT_FACTORY) | |
Default constructor. An element factory f can be specified. | |
Array (const 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) | |
Copy constructor. | |
Array (const Array< T > &a, const Factory &f) | |
Constructor, similar to the copy constructor, but also takes an element factory f as argument. | |
virtual | ~Array () |
Destructor. | |
T & | operator() (const int i) |
Get the i element. | |
const T & | operator() (const int i) const |
Get the i element. | |
const Array< T > | operator() (const int i1, const 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 > & | operator= (const T &e) |
Assignment operator. | |
Array< T > & | operator= (const Array< T > &a) |
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 (const int n, const bool copy=false) |
Resizing an Array<T>. | |
void | set_length (const int n, const bool copy=false) |
Resizing an Array<T>. | |
T | shift_right (const T e) |
Shift in data at position 0. return data at last position. | |
const Array< T > | shift_right (const Array< T > &a) |
Shift in array at position 0. return data at last position. | |
T | shift_left (const T e) |
Shift in data at position Ndata()-1. return data at last position. | |
const Array< T > | shift_left (const Array< T > &a) |
Shift in array at position Ndata()-1. return data at last position. | |
void | swap (const int i, const 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 | |
bool | in_range (const int i) |
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 (set to DEFAULT_FACTORY to use T default constructors only). | |
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 Functions | |
(Note that these are not member functions.) | |
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. |
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
template class Array<type>;
The following example shows how to define an Array of vectors:
vec a = randn(10); vec b = randn(20); vec c = randn(30); Array<vec> my_array(3); my_array(0) = a; my_array(1) = b; my_array(2) = c;
For types T with istream operator>> defined, the set_array functions (see Related Functions) can be used to assign a string literal to an Array, with the same format that is used by the istream/ostream operators:
// Declare an Array of Arrays of vectors Array<Array<ivec> > an_array; // Assign with an Array containing 2 Arrays, // the first Array containing [1 2] and // the second Array containing [3 4 5] and [6 7] set_array(an_array, "{{[1 2]} {[3 4 5] [6 7]}}");
By default, the 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.
Definition at line 97 of file array.h.
itpp::Array< T >::Array | ( | const Factory & | f = DEFAULT_FACTORY |
) | [inline, explicit] |
Default constructor. An element factory f
can be specified.
Definition at line 179 of file array.h.
References itpp::Array< T >::data, and itpp::Array< T >::ndata.
itpp::Array< T >::Array | ( | const int | n, | |
const Factory & | f = DEFAULT_FACTORY | |||
) | [inline] |
itpp::Array< T >::Array | ( | const Array< T > & | a | ) | [inline] |
Copy constructor.
Definition at line 192 of file array.h.
References itpp::Array< T >::data, and itpp::Array< T >::ndata.
itpp::Array< T >::Array | ( | const Array< T > & | a, | |
const Factory & | f | |||
) | [inline] |
Constructor, similar to the copy constructor, but also takes an element factory f
as argument.
Definition at line 200 of file array.h.
References itpp::Array< T >::data, and itpp::Array< T >::ndata.
itpp::Array< T >::~Array | ( | ) | [inline, virtual] |
T& itpp::Array< T >::operator() | ( | const int | i | ) | [inline] |
const T& itpp::Array< T >::operator() | ( | const int | i | ) | const [inline] |
const Array< T > itpp::Array< T >::operator() | ( | const int | i1, | |
const int | i2 | |||
) | const [inline] |
Sub-array from element i1
to element i2
.
Definition at line 237 of file array.h.
References itpp::Array< T >::data, it_assert0, and itpp::Array< T >::ndata.
const Array< T > itpp::Array< T >::operator() | ( | const Array< int > & | indices | ) | const [inline] |
Sub-array with the elements given by the integer Array.
Definition at line 251 of file array.h.
References itpp::Array< T >::data, it_assert0, itpp::Array< T >::ndata, and itpp::Array< T >::size().
Array< T > & itpp::Array< T >::operator= | ( | const T & | e | ) | [inline] |
Assignment operator.
Definition at line 275 of file array.h.
References itpp::Array< T >::data, itpp::Array< T >::ndata, and itpp::Array< T >::set_size().
Array< T > & itpp::Array< T >::operator= | ( | const Array< T > & | a | ) | [inline] |
Assignment operator.
Definition at line 264 of file array.h.
References itpp::Array< T >::data, itpp::Array< T >::ndata, and itpp::Array< T >::set_size().
int itpp::Array< T >::size | ( | ) | const [inline] |
Returns the number of data elements in the array object.
Definition at line 137 of file array.h.
Referenced by itpp::TDL_Channel::calc_frequency_response(), itpp::TDL_Channel::calc_impulse_response(), itpp::concat(), itpp::Parser::init(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read_hi(), itpp::it_ifile::low_level_read_lo(), itpp::it_file::low_level_write(), itpp::lshift_fix(), itpp::Array< T >::operator()(), itpp::Array< T >::operator>>(), itpp::Circular_Buffer< T >::put(), itpp::rshift_fix(), itpp::set_fix(), itpp::to(), and itpp::unfix().
int itpp::Array< T >::length | ( | ) | const [inline] |
Returns the number of data elements in the array object.
Definition at line 139 of file array.h.
Referenced by itpp::gmmtrain(), itpp::kmeans(), itpp::kmeansiter(), itpp::lbg(), and itpp::vqtrain().
void itpp::Array< T >::set_size | ( | const int | n, | |
const bool | copy = false | |||
) | [inline] |
Resizing an Array<T>.
Definition at line 286 of file array.h.
References itpp::Array< T >::data, itpp::min(), and itpp::Array< T >::ndata.
Referenced by itpp::TDL_Channel::calc_frequency_response(), itpp::TDL_Channel::calc_impulse_response(), itpp::Punctured_Convolutional_Code::calculate_spectrum(), itpp::Convolutional_Code::calculate_spectrum(), itpp::Punctured_Convolutional_Code::fast(), itpp::Convolutional_Code::fast(), itpp::TDL_Channel::generate(), itpp::Circular_Buffer< T >::get(), itpp::Selective_Repeat_ARQ_Sender::get_link_packets(), itpp::Parser::init(), itpp::it_ifile::low_level_read(), itpp::it_ifile::low_level_read_hi(), itpp::it_ifile::low_level_read_lo(), itpp::Array< T >::operator=(), itpp::operator>>(), itpp::Array< T >::operator>>(), itpp::Circular_Buffer< T >::peek(), itpp::Circular_Buffer< T >::peek_reverse(), itpp::Newton_Search::search(), itpp::set_fix(), itpp::Convolutional_Code::set_generator_polynomials(), and itpp::Array< itpp::DOPPLER_SPECTRUM >::set_length().
void itpp::Array< T >::set_length | ( | const int | n, | |
const bool | copy = false | |||
) | [inline] |
T itpp::Array< T >::shift_right | ( | const T | e | ) | [inline] |
Shift in data at position 0. return data at last position.
Definition at line 309 of file array.h.
References itpp::Array< T >::data, it_assert1, and itpp::Array< T >::ndata.
const Array< T > itpp::Array< T >::shift_right | ( | const Array< T > & | a | ) | [inline] |
Shift in array at position 0. return data at last position.
Definition at line 324 of file array.h.
References itpp::Array< T >::data, it_assert1, and itpp::Array< T >::ndata.
T itpp::Array< T >::shift_left | ( | const T | e | ) | [inline] |
Shift in data at position Ndata()-1. return data at last position.
Definition at line 341 of file array.h.
References itpp::Array< T >::data, and itpp::Array< T >::ndata.
const Array< T > itpp::Array< T >::shift_left | ( | const Array< T > & | a | ) | [inline] |
Shift in array at position Ndata()-1. return data at last position.
Definition at line 353 of file array.h.
References itpp::Array< T >::data, it_assert1, and itpp::Array< T >::ndata.
void itpp::Array< T >::swap | ( | const int | i, | |
const int | j | |||
) | [inline] |
Swap elements i and j.
Definition at line 372 of file array.h.
References itpp::Array< T >::data, itpp::Array< T >::in_range(), and it_assert1.
void itpp::Array< T >::set_subarray | ( | int | i1, | |
int | i2, | |||
const Array< T > & | a | |||
) | [inline] |
Set the subarray defined by indicies i1 to i2 to Array<T> a.
Definition at line 382 of file array.h.
References itpp::Array< T >::data, itpp::Array< T >::in_range(), it_assert1, and itpp::Array< T >::ndata.
void itpp::Array< T >::set_subarray | ( | int | i1, | |
int | i2, | |||
const T | t | |||
) | [inline] |
Set the subarray defined by indicies i1 to i2 the element value t.
Definition at line 395 of file array.h.
References itpp::Array< T >::data, itpp::Array< T >::in_range(), it_assert1, and itpp::Array< T >::ndata.
bool itpp::Array< T >::in_range | ( | const int | i | ) | [inline, protected] |
Check whether index i
is in the allowed range.
Definition at line 163 of file array.h.
Referenced by itpp::Array< T >::set_subarray(), and itpp::Array< T >::swap().
Append element e
to the end of the Array a
.
Concat element e
to the beginning of the Array a
.
Concat Arrays a1
and a2
.
const Array<T> concat | ( | const Array< T > & | a1, | |
const Array< T > & | a2, | |||
const Array< T > & | a3 | |||
) | [friend] |
Concat Arrays a1
, a2
and a3
.
std::ostream & operator<< | ( | std::ostream & | os, | |
const Array< T > & | a | |||
) | [related] |
std::istream & operator>> | ( | std::istream & | is, | |
Array< T > & | a | |||
) | [related] |
Input stream for Array<T>. T must have istream operator>> defined.
Definition at line 488 of file array.h.
References itpp::Array< T >::set_size(), and itpp::Array< T >::size().
void set_array | ( | Array< T > & | a, | |
const char * | values | |||
) | [related] |
Assign a C-style string to an Array<T>. T must have istream operator>> defined.
Definition at line 524 of file array.h.
Referenced by itpp::Array< T >::set_array().
void set_array | ( | Array< T > & | a, | |
const std::string & | str | |||
) | [related] |
Assign a string to an Array<T>. T must have istream operator>> defined.
Definition at line 535 of file array.h.
References itpp::Array< T >::set_array().
int itpp::Array< T >::ndata [protected] |
The current number of elements in the Array.
Definition at line 165 of file array.h.
Referenced by itpp::Array< T >::Array(), itpp::Array< itpp::DOPPLER_SPECTRUM >::in_range(), itpp::Array< itpp::DOPPLER_SPECTRUM >::length(), itpp::Array< T >::operator()(), itpp::Array< itpp::DOPPLER_SPECTRUM >::operator()(), itpp::Array< T >::operator=(), itpp::Array< T >::set_size(), itpp::Array< T >::set_subarray(), itpp::Array< T >::shift_left(), itpp::Array< T >::shift_right(), and itpp::Array< itpp::DOPPLER_SPECTRUM >::size().
T* itpp::Array< T >::data [protected] |
A pointer to the data area.
Definition at line 167 of file array.h.
Referenced by itpp::Array< T >::Array(), itpp::Array< T >::operator()(), itpp::Array< itpp::DOPPLER_SPECTRUM >::operator()(), itpp::Array< T >::operator=(), itpp::Array< T >::set_size(), itpp::Array< T >::set_subarray(), itpp::Array< T >::shift_left(), itpp::Array< T >::shift_right(), and itpp::Array< T >::swap().
const Factory& itpp::Array< T >::factory [protected] |
Generated on Thu Aug 30 02:47:23 2007 for IT++ by Doxygen 1.5.3