A multi-array of type T in N dimensions. More...
#include <Array.h>
Public Types | |
typedef types::value_type | value_type |
The element type of the array. | |
typedef types::parameter_type | parameter_type |
The parameter type. | |
typedef types::unqualified_value_type | unqualified_value_type |
The unqualified value type. | |
typedef types::pointer | pointer |
A pointer to an array element. | |
typedef types::const_pointer | const_pointer |
A const pointer to an array element. | |
typedef types::iterator | iterator |
An iterator in the array. | |
typedef types::const_iterator | const_iterator |
A const iterator in the array. | |
typedef types::reference | reference |
A reference to an array element. | |
typedef types::const_reference | const_reference |
A const reference to an array element. | |
typedef types::size_type | size_type |
The size type is a signed integer. | |
typedef types::difference_type | difference_type |
Pointer difference type. | |
typedef Loki::Select< A||Loki::TypeTraits < value_type >::isConst, const void *, void * >::Result | void_pointer |
A void pointer. | |
typedef indexing_base::index_type | index_type |
An index into the array. | |
typedef indexing_base::range_type | range_type |
A range of multi-indices. | |
Public Member Functions | |
Constructors etc. | |
Array () | |
Default constructor. | |
Array (const Array &x) | |
Copy constructor. | |
template<typename T2 , bool A2> | |
Array (const Array< N, T2, A2 > &x) | |
Array & | operator= (const Array &other) |
Assignment operator. | |
template<typename T2 , bool A2> | |
Array & | operator= (const Array< N, T2, A2 > &x) |
Assignment operator for an array of different type or allocation policy. | |
Array (const size_type extent0, const size_type extent1) | |
Construct a 2-D multi-array from the index extents. | |
Array (const size_type extent0, const size_type extent1, const size_type extent2) | |
Construct a 3-D multi-array from the index extents. | |
Array (const index_type &extents) | |
Construct from array extents. Leave the elements uninitialized. | |
Array (const index_type &extents, parameter_type value) | |
Construct from array extents and an initial value. | |
template<typename InputIterator > | |
Array (const index_type &extents, InputIterator first, InputIterator last) | |
Construct from array extents and a range of initial values. | |
Array (const range_type &ranges) | |
Construct from index ranges. Leave the elements uninitialized. | |
Array (const range_type &ranges, const value_type value) | |
Construct from index ranges and an initial value. | |
template<typename InputIterator > | |
Array (const range_type &ranges, InputIterator first, InputIterator last) | |
Construct from index ranges and a range of initial values. | |
Array (const index_type &extents, const void_pointer data) | |
Construct given the extents and a pointer to the data . | |
void | rebuild (const index_type &extents, const void_pointer data) |
Rebuild given the extents and a pointer to the data . | |
Array (const range_type &ranges, const void_pointer data) | |
Construct given the index ranges and a pointer to the data . | |
void | rebuild (const range_type &ranges, const void_pointer data) |
Rebuild given the index ranges and a pointer to the data . | |
~Array () | |
Destructor. Delete memory if it was allocated. | |
Accessors: Convert iterators to multi-indices. | |
void | iterator_to_indices (const const_iterator iter, int &i, int &j) const |
Convert an iterator to indices in a 2-D array. | |
void | iterator_to_indices (const const_iterator iter, int &i, int &j, int &k) const |
Convert an iterator to indices in a 3-D array. | |
void | iterator_to_indices (const const_iterator iter, ads::FixedArray< 2, int > &multi_index) const |
Convert an iterator to indices in a 2-D array. | |
void | iterator_to_indices (const const_iterator iter, ads::FixedArray< 3, int > &multi_index) const |
Convert an iterator to indices in a 3-D array. | |
Accesors: Memory. | |
size_type | getMemoryUsage () const |
Return the memory size. | |
Manipulators. | |
void | swap (Array &x) |
Swaps data with another Array. | |
void | resize (const index_type &ext) |
Resize the array. Allocate new memory if needed. | |
void | resize (const range_type &rng) |
Resize the array. Allocate new memory if needed. | |
Assignment operators with scalar operand. | |
Array & | operator= (parameter_type x) |
Set each component to x . | |
File I/O. | |
void | put (std::ostream &out) const |
Write the array to a file stream in ascii format. | |
void | get (std::istream &in) |
Read from a file stream in ascii format. | |
void | write (std::ostream &out) const |
Write to a file stream in binary format. | |
void | read (std::istream &in) |
Read from a file stream in binary format. | |
void | write_elements_ascii (std::ostream &out) const |
Write the elements in ascii format. Do not write the array size. | |
void | write_elements_binary (std::ostream &out) const |
Write the elements in binary format. Do not write the array size. | |
void | read_elements_ascii (std::istream &in) |
Read the elements in ascii format. Do not read the array size. | |
void | read_elements_binary (std::istream &in) |
Read the elements in binary format. Do not read the array size. | |
Equality. | |
template<typename T2 , bool A2> | |
bool | operator== (const Array< N, T2, A2 > &x) const |
Related Functions | |
(Note that these are not member functions.) | |
template<int N, typename T1 , typename T2 , bool A1, bool A2> | |
bool | operator!= (const Array< N, T1, A1 > &x, const Array< N, T2, A2 > &y) |
Return true if the arrays do not have the same index ranges and elements. | |
template<int N, typename T , bool A> | |
std::istream & | operator>> (std::istream &in, Array< N, T, A > &x) |
Read a Array in ascii format. Resize the array to the correct size. | |
template<int N, typename T , bool A> | |
std::ostream & | operator<< (std::ostream &out, const Array< N, T, A > &x) |
Write to a file stream in ascii format. | |
template<typename T , bool A> | |
T | computeSum (const ArrayContainer< T, A > &x) |
Return the sum of the components. | |
template<typename T , bool A> | |
T | computeProduct (const ArrayContainer< T, A > &x) |
Return the product of the components. | |
template<typename T , bool A> | |
T | computeMinimum (const ArrayContainer< T, A > &x) |
Return the minimum component. Use < for comparison. | |
template<typename T , bool A> | |
T | computeMaximum (const ArrayContainer< T, A > &x) |
Return the maximum component. Use > for comparison. | |
template<typename T , bool A> | |
void | applyAbs (ArrayContainer< T, A > *x) |
Apply the absolute value () to each array element. | |
template<typename T , bool A> | |
void | applyAcos (ArrayContainer< T, A > *x) |
Apply the inverse cosine () to each array element. | |
template<typename T , bool A> | |
void | applyAsin (ArrayContainer< T, A > *x) |
Apply the inverse sine () to each array element. | |
template<typename T , bool A> | |
void | applyAtan (ArrayContainer< T, A > *x) |
Apply the inverse tangent () to each array element. | |
template<typename T , bool A> | |
void | applyCeil (ArrayContainer< T, A > *x) |
Apply the ceiling function () to each array element. | |
template<typename T , bool A> | |
void | applyCos (ArrayContainer< T, A > *x) |
Apply the cosine () to each array element. | |
template<typename T , bool A> | |
void | applyCosh (ArrayContainer< T, A > *x) |
Apply the hyperbolic cosine () to each array element. | |
template<typename T , bool A> | |
void | applyExp (ArrayContainer< T, A > *x) |
Apply the exponential function () to each array element. | |
template<typename T , bool A> | |
void | applyFloor (ArrayContainer< T, A > *x) |
Apply the floor function () to each array element. | |
template<typename T , bool A> | |
void | applyLog (ArrayContainer< T, A > *x) |
Apply the natural logarithm () to each array element. | |
template<typename T , bool A> | |
void | applyLog10 (ArrayContainer< T, A > *x) |
Apply the logarithm base 10 () to each array element. | |
template<typename T , bool A> | |
void | applySin (ArrayContainer< T, A > *x) |
Apply the sine () to each array element. | |
template<typename T , bool A> | |
void | applySinh (ArrayContainer< T, A > *x) |
Apply the hyperbolic sine () to each array element. | |
template<typename T , bool A> | |
void | applySqrt (ArrayContainer< T, A > *x) |
Apply the square root () to each array element. | |
template<typename T , bool A> | |
void | applyTan (ArrayContainer< T, A > *x) |
Apply the tangent () to each array element. | |
template<typename T , bool A> | |
void | applyTanh (ArrayContainer< T, A > *x) |
Apply the hyperbolic tangent () to each array element. |
A multi-array of type T in N dimensions.
N | is the dimension. | |
T | is the value type. By default it is double. | |
A | determines whether the array will allocate memory for the elements or use externally allocated memory. By default A is true. |
typedef types::parameter_type Array< N, T, A >::parameter_type |
The parameter type.
This is used for passing the value type as an argument or returning the value type.
Reimplemented from ArrayContainer< T, A >.
typedef types::size_type Array< N, T, A >::size_type |
The size type is a signed integer.
Having std::size_t
(which is an unsigned integer) as the size type causes minor problems. Consult "Large Scale C++ Software Design" by John Lakos for a discussion of using unsigned integers in a class interface.
Reimplemented from ArrayContainer< T, A >.
typedef types::unqualified_value_type Array< N, T, A >::unqualified_value_type |
The unqualified value type.
The value type with top level const
and volatile
qualifiers removed.
Reimplemented from ArrayContainer< T, A >.
typedef Loki::Select< A || Loki::TypeTraits<value_type>::isConst, const void*, void* >::Result Array< N, T, A >::void_pointer |
A void pointer.
If we allocate our own memory or if the value type has a top level const qualifier, this is const void*
. Otherwise it is void*
.
Copy constructor.
If A
is true, allocate memory and copy the elements. Otherwise, reference the data in x
.
Array< N, T, A >::Array | ( | const Array< N, T2, A2 > & | x | ) | [inline] |
If A
is true, allocate memory and copy the elements. Otherwise, reference the data in x
.
Array< N, T, A >::Array | ( | const size_type | extent0, | |
const size_type | extent1 | |||
) | [inline, explicit] |
Construct a 2-D multi-array from the index extents.
Leave the elements uninitialized.
Array< N, T, A >::Array | ( | const size_type | extent0, | |
const size_type | extent1, | |||
const size_type | extent2 | |||
) | [inline, explicit] |
Construct a 3-D multi-array from the index extents.
Leave the elements uninitialized.
Array< N, T, A >::Array | ( | const index_type & | extents, | |
InputIterator | first, | |||
InputIterator | last | |||
) | [inline, explicit] |
Construct from array extents and a range of initial values.
Space is allocated for the data and the initial values are copied.
Array< N, T, A >::Array | ( | const range_type & | ranges, | |
InputIterator | first, | |||
InputIterator | last | |||
) | [inline, explicit] |
Construct from index ranges and a range of initial values.
Space is allocated for the data and the initial values are copied.
void Array< N, T, A >::iterator_to_indices | ( | const const_iterator | iter, | |
ads::FixedArray< 3, int > & | multi_index | |||
) | const [inline] |
Convert an iterator to indices in a 3-D array.
void Array< N, T, A >::iterator_to_indices | ( | const const_iterator | iter, | |
ads::FixedArray< 2, int > & | multi_index | |||
) | const [inline] |
Convert an iterator to indices in a 2-D array.
void Array< N, T, A >::iterator_to_indices | ( | const const_iterator | iter, | |
int & | i, | |||
int & | j, | |||
int & | k | |||
) | const [inline] |
Convert an iterator to indices in a 3-D array.
void Array< N, T, A >::iterator_to_indices | ( | const const_iterator | iter, | |
int & | i, | |||
int & | j | |||
) | const [inline] |
Convert an iterator to indices in a 2-D array.
Array& Array< N, T, A >::operator= | ( | const Array< N, T2, A2 > & | x | ) | [inline] |
Assignment operator for an array of different type or allocation policy.
If A
is true, allocate memory and copy the elements. Otherwise, reference the data in x
.
Array& Array< N, T, A >::operator= | ( | const Array< N, T, A > & | other | ) | [inline] |
Assignment operator.
If A
is true, allocate memory and copy the elements. Otherwise, reference the data in x
.
void Array< N, T, A >::read | ( | std::istream & | in | ) | [inline] |
Read from a file stream in binary format.
File format:
lbound_0 ... lbound_N-1 ubound_0 ... ubound_N-1 element_0 element_1 element_2 ...
Reimplemented from ArrayContainer< T, A >.
Referenced by Array< 1, T, A >::read(), and Array< 1, container_type >::write_elements_binary().
void Array< N, T, A >::write | ( | std::ostream & | out | ) | const [inline] |
Write to a file stream in binary format.
File format:
lbound_0 ... lbound_N-1 ubound_0 ... ubound_N-1 element_0 element_1 element_2 ...
Reimplemented from ArrayContainer< T, A >.
bool operator!= | ( | const Array< N, T1, A1 > & | x, | |
const Array< N, T2, A2 > & | y | |||
) | [related] |
Return true if the arrays do not have the same index ranges and elements.
std::ostream & operator<< | ( | std::ostream & | out, | |
const Array< N, T, A > & | x | |||
) | [related] |
Write to a file stream in ascii format.
File format:
lbound_0 ... lbound_N-1 ubound_0 ... ubound_N-1 element_0 element_1 element_2 ...
std::istream & operator>> | ( | std::istream & | in, | |
Array< N, T, A > & | x | |||
) | [related] |
Read a Array in ascii format. Resize the array to the correct size.
File format:
lbound_0 ... lbound_N-1 ubound_0 ... ubound_N-1 element_0 element_1 element_2 ...
References Array< N, T, A >::get().