ArrayIndexing< N, T > Class Template Reference

The indexing interface to N-D arrays. More...

#include <ArrayIndexing.h>

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

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 pointer to a constant array element.
typedef types::reference reference
 A reference to an array element.
typedef types::const_reference const_reference
 A reference to a constant 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 FixedArray< N, int > index_type
 A multi-index. Index in N dimensions.
typedef IndexRange< N, int > range_type
 A range of multi-indices.
typedef ArrayIndexIterator< N > index_iterator
 A multi-index iterator.

Public Member Functions

Accessors

const index_typeextents () const
 Return the extents of the array.
size_type extent (const int i) const
 Return the $ i^{th} $ extent of the array.
const range_typeranges () const
 Return the index ranges of the array.
const index_typelbounds () const
 Return the index lower bounds.
const index_typeubounds () const
 Return the index upper bounds.
int lbound (const int i) const
 Return the $ i^{th} $ lower bound.
int ubound (const int i) const
 Return the $ i^{th} $ upper bound.
const index_typestrides () const
 Return the strides between elements in each dimension.
index_iterator indices_begin () const
 Return an index iterator to the beginning of the indices.
index_iterator indices_end () const
 Return an index iterator to the end of the indices.
const_pointer root () const
 Return the root for indexing, i.e., the location of (*this)(lbounds()).
Accessors: Indexing.

parameter_type operator() (const index_type &mi) const
 Return the specified element.
parameter_type operator() (const int i0, const int i1) const
 Return the specified the element.
parameter_type operator() (const int i0, const int i1, const int i2) const
 Return the specified the element.
parameter_type operator() (const ads::FixedArray< 1, int > &index, const ads::FixedArray< 1, int > &offset) const
 Return the element specified by the index and offset.
parameter_type operator() (const ads::FixedArray< 2, int > &index, const ads::FixedArray< 2, int > &offset) const
 Return the element specified by the index and offset.
parameter_type operator() (const ads::FixedArray< 3, int > &index, const ads::FixedArray< 3, int > &offset) const
 Return the element specified by the index and offset.
Accessors: Convert between a container index and a multi-index.

int index (const index_type &mi) const
 Convert a multi-index to a container index.
int index (const int i0, const int i1) const
 Convert a multi-index to a container index.
int index (const int i0, const int i1, const int i2) const
 Convert a multi-index to a container index.
void index_to_indices (const int index, int &i, int &j) const
 Convert a container index to indices in a 2-D array.
void index_to_indices (int index, int &i, int &j, int &k) const
 Convert a container index to indices in a 3-D array.
void index_to_indices (const int index, ads::FixedArray< 2, int > &multi_index) const
 Convert a container index to indices in a 2-D array.
void index_to_indices (const int index, ads::FixedArray< 3, int > &multi_index) const
 Convert a container index to indices in a 3-D array.
Manipulators.

pointer root ()
 Return the root for indexing.
Manipulators: Array indexing.

reference operator() (const index_type &mi)
 Return a reference to the element.
reference operator() (const int i0, const int i1)
 Return a reference to the element.
reference operator() (const int i0, const int i1, const int i2)
 Return a reference to the element.
File I/O.

void put (std::ostream &out) const
 Write the ranges to a file stream in ascii format.
void write (std::ostream &out) const
 Write to a file stream in binary format.
void pretty_print (std::ostream &out) const
 Write to a file stream in a tabular format.
Equality.

template<typename T2 >
bool operator== (const ArrayIndexing< N, T2 > &x) const
 Return true if the ranges are the same.

Static Public Member Functions

Static members.

static int rank ()
 Return the rank (number of dimensions) of the array.

Protected Member Functions

Constructors etc.

 ArrayIndexing ()
 Default constructor. Empty array.
 ArrayIndexing (const ArrayIndexing &x)
 Copy constructor. Shallow copy.
ArrayIndexingoperator= (const ArrayIndexing &x)
 Assignment operator. Shallow assignment.
template<typename Type >
 ArrayIndexing (const index_type &extents, Type *data)
 Construct given the extents and a pointer to the data.
template<typename Type >
void rebuild (const index_type &extents, Type *data)
 Rebuild given the extents and a pointer to the data.
template<typename Type >
 ArrayIndexing (const range_type &ranges, Type *data)
 Construct given the index ranges and a pointer to the data.
template<typename Type >
void rebuild (const range_type &ranges, Type *data)
 Rebuild given the index ranges and a pointer to the data.
void swap (ArrayIndexing &x)
 Swaps data with another ArrayIndexing.
 ~ArrayIndexing ()
 Destructor. Do nothing. Leave memory management to derived classes.

Detailed Description

template<int N, typename T = double>
class ArrayIndexing< N, T >

The indexing interface to N-D arrays.

Parameters:
N is the dimension.
T is the value type. By default it is double.

Member Typedef Documentation

template<int N, typename T = double>
typedef types::parameter_type ArrayIndexing< N, T >::parameter_type

The parameter type.

This is used for passing the value type as an argument.

Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.

template<int N, typename T = double>
typedef types::size_type ArrayIndexing< N, T >::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 ArrayIndexingBase< N >.

Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.

template<int N, typename T = double>
typedef types::unqualified_value_type ArrayIndexing< N, T >::unqualified_value_type

The unqualified value type.

The value type with top level const and volatile qualifiers removed.

Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.


Member Function Documentation

template<int N, typename T = double>
int ArrayIndexing< N, T >::index ( const int  i0,
const int  i1,
const int  i2 
) const [inline]

Convert a multi-index to a container index.

Precondition:
This must be a 3-D array.

Reimplemented from ArrayIndexingBase< N >.

template<int N, typename T = double>
int ArrayIndexing< N, T >::index ( const int  i0,
const int  i1 
) const [inline]

Convert a multi-index to a container index.

Precondition:
This must be a 2-D array.

Reimplemented from ArrayIndexingBase< N >.

template<int N, typename T = double>
void ArrayIndexing< N, T >::index_to_indices ( const int  index,
ads::FixedArray< 3, int > &  multi_index 
) const [inline]

Convert a container index to indices in a 3-D array.

Precondition:
This must be a 3-D array.

Reimplemented from ArrayIndexingBase< N >.

template<int N, typename T = double>
void ArrayIndexing< N, T >::index_to_indices ( const int  index,
ads::FixedArray< 2, int > &  multi_index 
) const [inline]

Convert a container index to indices in a 2-D array.

Precondition:
This must be a 2-D array.

Reimplemented from ArrayIndexingBase< N >.

template<int N, typename T = double>
void ArrayIndexing< N, T >::index_to_indices ( int  index,
int &  i,
int &  j,
int &  k 
) const [inline]

Convert a container index to indices in a 3-D array.

Precondition:
This must be a 3-D array.

Reimplemented from ArrayIndexingBase< N >.

template<int N, typename T = double>
void ArrayIndexing< N, T >::index_to_indices ( const int  index,
int &  i,
int &  j 
) const [inline]

Convert a container index to indices in a 2-D array.

Precondition:
This must be a 2-D array.

Reimplemented from ArrayIndexingBase< N >.

Referenced by Array< 1, container_type >::getMemoryUsage(), and Array< 1, container_type >::iterator_to_indices().

template<int N, typename T = double>
reference ArrayIndexing< N, T >::operator() ( const int  i0,
const int  i1,
const int  i2 
) [inline]

Return a reference to the element.

Precondition:
This must be a 3-D array.
template<int N, typename T = double>
reference ArrayIndexing< N, T >::operator() ( const int  i0,
const int  i1 
) [inline]

Return a reference to the element.

Precondition:
This must be a 2-D array.
template<int N, typename T = double>
parameter_type ArrayIndexing< N, T >::operator() ( const ads::FixedArray< 3, int > &  index,
const ads::FixedArray< 3, int > &  offset 
) const [inline]

Return the element specified by the index and offset.

This function avoids constructing an index.

template<int N, typename T = double>
parameter_type ArrayIndexing< N, T >::operator() ( const ads::FixedArray< 2, int > &  index,
const ads::FixedArray< 2, int > &  offset 
) const [inline]

Return the element specified by the index and offset.

This function avoids constructing an index.

template<int N, typename T = double>
parameter_type ArrayIndexing< N, T >::operator() ( const ads::FixedArray< 1, int > &  index,
const ads::FixedArray< 1, int > &  offset 
) const [inline]

Return the element specified by the index and offset.

This function avoids constructing an index.

template<int N, typename T = double>
parameter_type ArrayIndexing< N, T >::operator() ( const int  i0,
const int  i1,
const int  i2 
) const [inline]

Return the specified the element.

Precondition:
This must be a 3-D array.
template<int N, typename T = double>
parameter_type ArrayIndexing< N, T >::operator() ( const int  i0,
const int  i1 
) const [inline]

Return the specified the element.

Precondition:
This must be a 2-D array.
template<int N, typename T = double>
void ArrayIndexing< N, T >::pretty_print ( std::ostream &  out  )  const

Write to a file stream in a tabular format.

Precondition:
Must be 1-D, 2-D or 3-D.

In 1-D, write one element per line. In 2-D, write by rows. In 3-D, write by z-slices.


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