Array< N, T, A > Class Template Reference

A multi-array of type T in N dimensions. More...

#include <Array.h>

Inheritance diagram for Array< N, T, A >:
ArrayContainer< T, A > ArrayIndexing< N, T > ArrayIndexingBase< N >

List of all members.

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)
Arrayoperator= (const Array &other)
 Assignment operator.
template<typename T2 , bool A2>
Arrayoperator= (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.

Arrayoperator= (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>
computeSum (const ArrayContainer< T, A > &x)
 Return the sum of the components.
template<typename T , bool A>
computeProduct (const ArrayContainer< T, A > &x)
 Return the product of the components.
template<typename T , bool A>
computeMinimum (const ArrayContainer< T, A > &x)
 Return the minimum component. Use < for comparison.
template<typename T , bool A>
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 ($|x|$) to each array element.
template<typename T , bool A>
void applyAcos (ArrayContainer< T, A > *x)
 Apply the inverse cosine ($ \cos^{-1}(x) $) to each array element.
template<typename T , bool A>
void applyAsin (ArrayContainer< T, A > *x)
 Apply the inverse sine ($ \sin^{-1}(x) $) to each array element.
template<typename T , bool A>
void applyAtan (ArrayContainer< T, A > *x)
 Apply the inverse tangent ($ \tan^{-1}(x) $) to each array element.
template<typename T , bool A>
void applyCeil (ArrayContainer< T, A > *x)
 Apply the ceiling function ($ \lceil x \rceil $) to each array element.
template<typename T , bool A>
void applyCos (ArrayContainer< T, A > *x)
 Apply the cosine ($ \cos(x) $) to each array element.
template<typename T , bool A>
void applyCosh (ArrayContainer< T, A > *x)
 Apply the hyperbolic cosine ($ \cosh(x) $) to each array element.
template<typename T , bool A>
void applyExp (ArrayContainer< T, A > *x)
 Apply the exponential function ($ \mathrm{e}^x $) to each array element.
template<typename T , bool A>
void applyFloor (ArrayContainer< T, A > *x)
 Apply the floor function ($ \lfloor x \rfloor $) to each array element.
template<typename T , bool A>
void applyLog (ArrayContainer< T, A > *x)
 Apply the natural logarithm ($ \ln(x) $) to each array element.
template<typename T , bool A>
void applyLog10 (ArrayContainer< T, A > *x)
 Apply the logarithm base 10 ($ \log_{10}(x) $) to each array element.
template<typename T , bool A>
void applySin (ArrayContainer< T, A > *x)
 Apply the sine ($ \sin(x) $) to each array element.
template<typename T , bool A>
void applySinh (ArrayContainer< T, A > *x)
 Apply the hyperbolic sine ($ \sinh(x) $) to each array element.
template<typename T , bool A>
void applySqrt (ArrayContainer< T, A > *x)
 Apply the square root ($ \sqrt{x} $) to each array element.
template<typename T , bool A>
void applyTan (ArrayContainer< T, A > *x)
 Apply the tangent ($ \tan(x) $) to each array element.
template<typename T , bool A>
void applyTanh (ArrayContainer< T, A > *x)
 Apply the hyperbolic tangent ($ \tanh(x) $) to each array element.

Detailed Description

template<int N, typename T, bool A>
class Array< N, T, A >

A multi-array of type T in N dimensions.

Parameters:
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.

Member Typedef Documentation

template<int N, typename T, bool A>
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 >.

template<int N, typename T, bool 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 >.

template<int N, typename T, bool 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 >.

template<int N, typename T, bool 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*.


Constructor & Destructor Documentation

template<int N, typename T, bool A>
Array< N, T, A >::Array ( const Array< N, T, A > &  x  )  [inline]

Copy constructor.

If A is true, allocate memory and copy the elements. Otherwise, reference the data in x.

template<int N, typename T, bool A>
template<typename T2 , bool A2>
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.

template<int N, typename T, bool A>
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.

template<int N, typename T, bool A>
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.

template<int N, typename T, bool A>
template<typename InputIterator >
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.

template<int N, typename T, bool A>
template<typename InputIterator >
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.


Member Function Documentation

template<int N, typename T, bool A>
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.

Precondition:
This must be a 3-D array.
template<int N, typename T, bool A>
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.

Precondition:
This must be a 2-D array.
template<int N, typename T, bool A>
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.

Precondition:
This must be a 3-D array.
template<int N, typename T, bool A>
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.

Precondition:
This must be a 2-D array.
template<int N, typename T, bool A>
template<typename T2 , bool A2>
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.

template<int N, typename T, bool A>
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.

template<int N, typename T, bool A>
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().

template<int N, typename T, bool A>
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 >.


Friends And Related Function Documentation

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 
) [related]

Return true if the arrays do not have the same index ranges and elements.

template<int N, typename T , bool A>
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
  ... 
template<int N, typename T , bool A>
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().


The documentation for this class was generated from the following files:
Generated on Thu Jun 30 02:14:51 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3