#include <array.h>
Collaboration diagram for SPUC::array< T >:

Public Member Functions | |
| array () | |
| Default constructor. | |
| array (int n) | |
Create an array of size n. | |
| array (const array< T > &a) | |
Create a copy of a. | |
| virtual | ~array () |
| Default destructor. | |
| T & | operator() (int i) |
Get the i element. | |
| T | operator() (int i) const |
Get the i element. | |
| array< T > | operator() (int i1, int i2) const |
Sub-array from element i1 to element i2. | |
| array< T > | operator() (const array< int > &indices) const |
| Sub-array with the elements given by the integer array. | |
| void | operator= (T e) |
| Assignment operator. | |
| void | 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 (int n, bool copy=false) |
| Resizing an array<T>. | |
| void | set_length (int n, bool copy=false) |
| Resizing an array<T>. | |
| T | shift_right (T e) |
| Shift in data at position 0. return data at last position. | |
| array< T > | shift_right (const array< T > &a) |
| Shift in array at position 0. return data at last position. | |
| T | shift_left (T e) |
| Shift in data at position Ndata()-1. return data at last position. | |
| array< T > | shift_left (const array< T > &a) |
| Shift in array at position Ndata()-1. return data at last position. | |
| 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. | |
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;
| SPUC::array< T >::array | ( | ) |
Default constructor.
| SPUC::array< T >::array | ( | int | n | ) |
Create an array of size n.
| SPUC::array< T >::array | ( | const array< T > & | a | ) |
Create a copy of a.
| SPUC::array< T >::~array | ( | ) | [virtual] |
Default destructor.
| int SPUC::array< T >::length | ( | ) | const [inline] |
Returns the number of data elements in the array object.
| array< T > SPUC::array< T >::operator() | ( | const array< int > & | indices | ) | const |
Sub-array with the elements given by the integer array.
| array< T > SPUC::array< T >::operator() | ( | int | i1, | |
| int | i2 | |||
| ) | const |
Sub-array from element i1 to element i2.
| T SPUC::array< T >::operator() | ( | int | i | ) | const [inline] |
Get the i element.
| T& SPUC::array< T >::operator() | ( | int | i | ) | [inline] |
Get the i element.
| void SPUC::array< T >::operator= | ( | const array< T > & | a | ) |
Assignment operator.
| void SPUC::array< T >::operator= | ( | T | e | ) |
Assignment operator.
| void SPUC::array< T >::set_length | ( | int | n, | |
| bool | copy = false | |||
| ) | [inline] |
Resizing an array<T>.
| void SPUC::array< T >::set_size | ( | int | n, | |
| bool | copy = false | |||
| ) |
Resizing an array<T>.
| void SPUC::array< T >::set_subarray | ( | int | i1, | |
| int | i2, | |||
| const T | t | |||
| ) |
Set the subarray defined by indicies i1 to i2 the element value t.
| void SPUC::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.
| array< T > SPUC::array< T >::shift_left | ( | const array< T > & | a | ) |
Shift in array at position Ndata()-1. return data at last position.
| T SPUC::array< T >::shift_left | ( | T | e | ) |
Shift in data at position Ndata()-1. return data at last position.
| array< T > SPUC::array< T >::shift_right | ( | const array< T > & | a | ) |
Shift in array at position 0. return data at last position.
| T SPUC::array< T >::shift_right | ( | T | e | ) |
Shift in data at position 0. return data at last position.
| int SPUC::array< T >::size | ( | ) | const [inline] |
Returns the number of data elements in the array object.
| void SPUC::array< T >::swap | ( | int | i, | |
| int | j | |||
| ) |
Swap elements i and j.
1.4.7