Main Page | Modules | Class Hierarchy | Class List | File List | Class Members

ltl::MArray< T, N > Class Template Reference
[The Class MArray]

A dynamic N-dimensional array storing objects of type T. More...

#include <marray.h>

List of all members.

Public Types

STL definitions:

Public Member Functions

Construct an (optionally mapped) array of rank N with ltl::Range size arguments.
Construct an array of rank N with int size arguments.
Index ranges {1..ni, i=1..N}, int arguments, base defaults to 1.

Constructors for pure subarrays (rank preserved)
Other array's data is referenced, NOT copied ( use operator=() for copy)! Missing arguments are treated as Range::all() !

Construct from preexisting data.
The array dims[] holds the lengths of each dimension (The number of dimensions, and hence the length of dims[] is known from the template parameter N.) No checking is performed. The index ranges are {1..dims[i]} along each dimension i.

Operator=, other's data is copied, own data overwritten
Arrays have to have conformable shapes, no automatic resize takes place. Use realloc() instead!

Overloaded X= operators. There is a version for an
 MArray rhs, an expression rhs, and a literal rhs for each operator.
          To have a single implementation of mathematical operations for scalar and 
          vectorized code (where the C language extensions do not define X= ), we 
          transform the \code A x= E 
assignment into
 A = A x E 
and call
 operator= 
.

Elementwise array access (indexing) via operator()
int / ltl::FixedVector arguments, return (reference to) element.

'Cutting' array access (indexing) via operator()
ltl::Range arguments, return (reference to) element.

Change bases:
Change the bases of the array (the bases are the first indices of each dimension)

Array information:
Interfaces ltl::Shape.

Reverse and Transpose:
Reorder array (without copy). Very fast!

Public Attributes

Protected Member Functions

Protected Attributes

Friends

Related Functions

(Note that these are not member functions.)

Detailed Description

template<class T, int N>
class ltl::MArray< T, N >

A dynamic N-dimensional array storing objects of type T.

MArrays feature subarrays (sometimes called views), slices, expression templated evaluation, and other features described below. The memory holding the actual data is reference counted, such that it is not freed until the last reference to the data by views or slices has been removed.


Constructor & Destructor Documentation

template<class T, int N>
ltl::MArray< T, N >::MArray  )  [inline]
 

Construct an array without allocating memory.

This is useful for constructing MArrays whose values are to be read from a file, and thus the dimensions are not known yet.

Warning:
Use this with care! Use this MArray only after being sure that ltl::MArray::realloc() or ltl::MArray::makeReference() has been called.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const Range r3,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const Range r3,
const Range r4,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6,
const Range r7,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const int  r3,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const int  r3,
const int  r4,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const int  r3,
const int  r4,
const int  r5,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const int  r3,
const int  r4,
const int  r5,
const int  r6,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const int  r1,
const int  r2,
const int  r3,
const int  r4,
const int  r5,
const int  r6,
const int  r7,
const bool  map = false
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r0
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
ltl::MArray< T, N >::MArray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6,
const Range r7
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
template<int N2, class R1, class R2, class R3, class R4, class R5, class R6, class R7>
ltl::MArray< T, N >::MArray const MArray< T, N2 > &  other,
R1  r1,
R2  r2,
R3  r3,
R4  r4,
R5  r5,
R6  r6,
R7  r7
[inline]
 

Constructor for mixed slicing (int, rank reducing) and Range arguments.

Other array's data is referenced, NOT copied ( use operator=() for copy)!

template<class T, int N>
ltl::MArray< T, N >::MArray const Shape< N > *  s,
const bool  map = false,
const char *  filename = NULL
 

Construct from shape.

Useful to construct an array having the same geometry as another array. If you have map == true and give a filename the memory map will be saved.

template<class T, int N>
template<class Expr>
ltl::MArray< T, N >::MArray const TExpr< Expr, N > &  e,
const bool  map = false,
const char *  filename = NULL
 

Construct from an array-valued expression.

The new array is allocated with the shape of the expression and its elements are filled with the evaluated expression. If you have map == true and give a filename the memory map will be saved.


Member Function Documentation

template<class T, int N>
T* __restrict__ ltl::MArray< T, N >::beginRA  )  [inline]
 

In case our memory layout is contiguous, we can offer an easy solution to provide random access iterators.

template<class T, int N>
T* __restrict__ ltl::MArray< T, N >::data  )  const [inline]
 

Pointer to first data element.

Warning:
The second data element NEED NOT be at first + 1 since the memeory might be non-contiguous. Use iteators!

template<class T, int N>
void ltl::MArray< T, N >::free  )  [inline]
 

Free associated memory.

Frees the memory used to store the data before the MArray goes out of scope (before the destructor is being called). Can help keeping code cleaner without using pointers to MArray.

template<class T, int N>
IndexIterator ltl::MArray< T, N >::indexBegin  )  const [inline]
 

An iterator-style thing providing indices when dereferenced.

I.e. *i or i() gives a FixedVector holding the indices and and i(int) gives the index in the i-th dimension

template<class T, int N>
MArray<T,1> ltl::MArray< T, N >::operator() const IndexList< N > &  l  )  const [inline]
 

Index with ltl::IndexList (rhs version).

Return ltl::MArray<T,1> object.

template<class T, int N>
ListInitializationSwitch< MArray<T,N> > ltl::MArray< T, N >::operator= x  )  [inline]
 

Assigns x to all elements.

A bit more comlicated since we have to discriminate between

 A = 3; and A = 1, 2, 3, 4;
which is done using ListInitializationSwitch which either calls ListInitializer or MArray::fill().

template<class T, int N>
IndexRef<T,N> ltl::MArray< T, N >::operator[] const IndexList< N > &  l  )  [inline]
 

Index with ltl::IndexList (lhs version).

Assignment to self indexed with IndexList A[l] = Expr<T,1> IndexRef object is needed to carry the operator=( Expr ) method.

template<class T, int N>
void ltl::MArray< T, N >::realloc const Shape< N > &  s,
const bool  map = false,
const char *  filename = NULL
 

Reallocate memory. Data are abolished.

If you have map == true and give a filename the new memory map will be saved.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6,
const Range r7
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5,
const Range r6
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4,
const Range r5
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3,
const Range r4
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2,
const Range r3
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T, int N>
void ltl::MArray< T, N >::subarray const MArray< T, N > &  other,
const Range r1,
const Range r2
[protected]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


Member Data Documentation

template<class T, int N>
Shape<N> ltl::MArray< T, N >::shape_ [protected]
 

Holds shape information.

And zeroOffset_ which is the distance between data_ and the the address of the first element of the array, such that

        first = data_ + sum( base(i) * stride(i) )
              = data_ + shape_.zeroOffset();
always holds.


The documentation for this class was generated from the following files:
Generated on Fri Dec 24 13:32:05 2004 for LTL by doxygen 1.3.4