dlr::numeric::SubArray2D< Type > Class Template Reference

Header file defining a simple SubArray class to work with Array2D.h The goal here is simplicity. More...

#include <subArray2D.h>

List of all members.

Public Member Functions

 SubArray2D (const Array2D< Type > &source)
 The single argument constructs a subarray referencing every element of the source array.
 SubArray2D (const Array2D< Type > &source, const Slice &rowSlice, const Slice &columnSlice)
 This constructor permits slicing of the source array.
 SubArray2D (const SubArray2D< Type > &other)
 This is the copy constructor.
virtual ~SubArray2D ()
 Destroys the SubArray2D instance.
 operator Array2D< Type > () const
 This conversion operator generates an Array2D instance from a SubArray2D.
size_t rows () const
 This member function returns the number of rows referenced by *this.
size_t columns () const
 This member function returns the number of columns referenced by *this.
size_t startRow () const
 This member function returns the index of the first row referenced by *this.
size_t startColumn () const
 This member function returns the index of the first column referenced by *this.
size_t rowStride () const
 This member function returns the spacing of the rows referenced by *this.
size_t columnStride () const
 This member function returns the spacing of the columns referenced by *this.
Array2D< Type > getArray () const
 This method returns an Array2D instance referencing the same memory as the Array2D instance from which *this was constructed.
SubArray2D< Type > & operator= (const SubArray2D< Type > &other)
 This assignment operator performs a deep copy, copying each element from other into *this.
SubArray2D< Type > & operator= (Type value)
 This assignment operator sets each element reference by *this to the specified value.
SubArray2D< Type > & operator+= (const SubArray2D< Type > &other)
 This operator increments each element of *this by the corresponding element of its argument.
SubArray2D< Type > & operator-= (const SubArray2D< Type > &other)
 This operator decrements each element of *this by the corresponding element of its argument.


Detailed Description

template<class Type>
class dlr::numeric::SubArray2D< Type >

Header file defining a simple SubArray class to work with Array2D.h The goal here is simplicity.

This is not intended to be a full interface. Just enough to let you select and copy subArrays. Use this class via the function subArray(), like this:

subArray(array0) = subArray(array1, Slice(0, 6, 2), Slice(1, 4));

or

Array2D<double> array0 = subArray(array1, Slice(0, 6, 2), Slice(1, 4));

Note that this class has deep copy semantics.

Definition at line 40 of file subArray2D.h.


Constructor & Destructor Documentation

template<class Type >
dlr::numeric::SubArray2D< Type >::SubArray2D ( const Array2D< Type > &  source  )  [inline]

The single argument constructs a subarray referencing every element of the source array.

Parameters:
source This argument specifies the Array2D into which to index.

Definition at line 406 of file subArray2D.h.

template<class Type >
dlr::numeric::SubArray2D< Type >::SubArray2D ( const Array2D< Type > &  source,
const Slice rowSlice,
const Slice columnSlice 
) [inline]

This constructor permits slicing of the source array.

The resulting subarray references only those elements of the source array which lie in rows indicated by rowSlice and also in columns indicated by columnSlice.

Parameters:
source This argument specifies the Array2D into which to index.
rowSlice This argument specifies which rows to include in the subArray.
columnSlice This argument specifies which columns to include in the subArray.

Definition at line 422 of file subArray2D.h.

References dlr::numeric::Array2D< Type >::columns(), and dlr::numeric::Array2D< Type >::rows().

template<class Type >
dlr::numeric::SubArray2D< Type >::SubArray2D ( const SubArray2D< Type > &  other  )  [inline]

This is the copy constructor.

After construction, *this will reference the same elements (of the same source array) as the copied SubArray2D instance.

Parameters:
other This argument specifies the SubArray2D instance to be copied

Definition at line 487 of file subArray2D.h.

template<class Type>
virtual dlr::numeric::SubArray2D< Type >::~SubArray2D (  )  [inline, virtual]

Destroys the SubArray2D instance.

Definition at line 82 of file subArray2D.h.


Member Function Documentation

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::columns (  )  const [inline]

This member function returns the number of columns referenced by *this.

For example, if a SubArray2D references every third column of an 18 column Array2D, then its columns() method will return 6.

Returns:
The number of columns referenced by *this.

Definition at line 113 of file subArray2D.h.

Referenced by dlr::numeric::SubArray2D< Type >::operator Array2D< Type >(), dlr::numeric::SubArray2D< Type >::operator+=(), dlr::numeric::SubArray2D< Type >::operator-=(), dlr::numeric::operator<<(), and dlr::numeric::SubArray2D< Type >::operator=().

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::columnStride (  )  const [inline]

This member function returns the spacing of the columns referenced by *this.

For example, if a SubArray2D references every third column of an Array2D, then its columnStride() method will return 3.

Returns:
The spacing of the columns referenced by *this.

Definition at line 156 of file subArray2D.h.

template<class Type>
Array2D<Type> dlr::numeric::SubArray2D< Type >::getArray (  )  const [inline]

This method returns an Array2D instance referencing the same memory as the Array2D instance from which *this was constructed.

Returns:
An Array2D instance which references the same memory as the Array2D instance from which *this was constructed.

Definition at line 167 of file subArray2D.h.

template<class Type >
dlr::numeric::SubArray2D< Type >::operator Array2D< Type > (  )  const [inline]

This conversion operator generates an Array2D instance from a SubArray2D.

The element values from the *this are copied into the newly created Array2D instance.

Returns:
An Array2D instance containing copies of the elements referenced by *this.

Definition at line 502 of file subArray2D.h.

References dlr::numeric::SubArray2D< Type >::columns(), dlr::numeric::SubArray2D< Type >::rows(), and dlr::numeric::subArray().

template<class Type >
SubArray2D< Type > & dlr::numeric::SubArray2D< Type >::operator+= ( const SubArray2D< Type > &  other  )  [inline]

This operator increments each element of *this by the corresponding element of its argument.

Note that this modifies the corresponding elements of the array from which *this was created.

Parameters:
other This argument specifies a SubArray2D instance, the elements of which will be added to the elements of *this.
Returns:
A reference to *this.

Definition at line 540 of file subArray2D.h.

References dlr::numeric::SubArray2D< Type >::columns(), dlr::numeric::SubArray2D< Type >::m_columnStride, dlr::numeric::SubArray2D< Type >::m_rowStride, dlr::numeric::SubArray2D< Type >::m_source, dlr::numeric::SubArray2D< Type >::m_startColumn, dlr::numeric::SubArray2D< Type >::m_startRow, and dlr::numeric::SubArray2D< Type >::m_stopRow.

template<class Type >
SubArray2D< Type > & dlr::numeric::SubArray2D< Type >::operator-= ( const SubArray2D< Type > &  other  )  [inline]

This operator decrements each element of *this by the corresponding element of its argument.

Note that this modifies the corresponding elements of the array from which *this was created.

Parameters:
other This argument specifies a SubArray2D instance, the elements of which will be subtracted from the elements of *this.
Returns:
A reference to *this.

Definition at line 563 of file subArray2D.h.

References dlr::numeric::SubArray2D< Type >::columns(), dlr::numeric::SubArray2D< Type >::m_columnStride, dlr::numeric::SubArray2D< Type >::m_rowStride, dlr::numeric::SubArray2D< Type >::m_source, dlr::numeric::SubArray2D< Type >::m_startColumn, dlr::numeric::SubArray2D< Type >::m_startRow, and dlr::numeric::SubArray2D< Type >::m_stopRow.

template<class Type >
SubArray2D< Type > & dlr::numeric::SubArray2D< Type >::operator= ( Type  value  )  [inline]

This assignment operator sets each element reference by *this to the specified value.

Note that this modifies the corresponding elements of the array from which *this was created.

Parameters:
value This argument specifies the value to which the array elements should be set.
Returns:
A reference to *this.

Definition at line 524 of file subArray2D.h.

References dlr::numeric::SubArray2D< Type >::columns().

template<class Type >
SubArray2D< Type > & dlr::numeric::SubArray2D< Type >::operator= ( const SubArray2D< Type > &  other  )  [inline]

This assignment operator performs a deep copy, copying each element from other into *this.

Note that this modifies the corresponding elements of the array from which *this was created.

Parameters:
other This argument specifies the SubArray2D instance to be copied
Returns:
A reference to *this.

Definition at line 511 of file subArray2D.h.

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::rows (  )  const [inline]

This member function returns the number of rows referenced by *this.

For example, if a SubArray2D references every third row of an 18 row Array2D, then its rows() method will return 6.

Returns:
The number of rows referenced by *this.

Definition at line 102 of file subArray2D.h.

Referenced by dlr::numeric::SubArray2D< Type >::operator Array2D< Type >(), and dlr::numeric::operator<<().

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::rowStride (  )  const [inline]

This member function returns the spacing of the rows referenced by *this.

For example, if a SubArray2D references every third row of an Array2D, then its rowStride() method will return 3.

Returns:
The spacing of the rows referenced by *this.

Definition at line 145 of file subArray2D.h.

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::startColumn (  )  const [inline]

This member function returns the index of the first column referenced by *this.

For example, if a SubArray2D references every third column of an 18 column Array2D, starting from column 4, then its startColumn() method will return 4.

Returns:
The index of the first column referenced by *this.

Definition at line 135 of file subArray2D.h.

template<class Type>
size_t dlr::numeric::SubArray2D< Type >::startRow (  )  const [inline]

This member function returns the index of the first row referenced by *this.

For example, if a SubArray2D references every third row of an 18 row Array2D, starting from row 4, then its startRow() method will return 4.

Returns:
The index of the first row referenced by *this.

Definition at line 124 of file subArray2D.h.


The documentation for this class was generated from the following file:

Generated on Wed Nov 25 00:42:50 2009 for dlrUtilities Utility Library by  doxygen 1.5.8