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

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

#include <subArray1D.h>

List of all members.

Public Member Functions

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


Detailed Description

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

Header file defining a simple SubArray class to work with Array1D.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));

Note that this class has deep copy semantics.

Definition at line 37 of file subArray1D.h.


Constructor & Destructor Documentation

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

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

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

Definition at line 313 of file subArray1D.h.

template<class Type >
dlr::numeric::SubArray1D< Type >::SubArray1D ( const Array1D< Type > &  source,
const Slice slice0 
) [inline]

This constructor permits slicing of the source array.

The resulting subarray references only those elements of the source array indicated by slice0.

Parameters:
source This argument specifies the Array1D into which to index.
slice0 This argument specifies which elements to include in the subArray.

Definition at line 325 of file subArray1D.h.

References dlr::numeric::Array1D< Type >::size().

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

This is the copy constructor.

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

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

Definition at line 367 of file subArray1D.h.

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

Destroys the SubArray1D instance.

Definition at line 78 of file subArray1D.h.


Member Function Documentation

template<class Type>
Array1D<Type> dlr::numeric::SubArray1D< Type >::getArray (  )  const [inline]

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

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

Definition at line 136 of file subArray1D.h.

template<class Type >
dlr::numeric::SubArray1D< Type >::operator Array1D< Type > (  )  const [inline]

This conversion operator generates an Array1D instance from a SubArray1D.

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

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

Definition at line 379 of file subArray1D.h.

References dlr::numeric::SubArray1D< Type >::size(), and dlr::numeric::subArray().

template<class Type >
SubArray1D< Type > & dlr::numeric::SubArray1D< Type >::operator+= ( const SubArray1D< 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 SubArray1D instance, the elements of which will be added to the elements of *this.
Returns:
A reference to *this.

Definition at line 409 of file subArray1D.h.

References dlr::numeric::SubArray1D< Type >::m_source, dlr::numeric::SubArray1D< Type >::m_start, dlr::numeric::SubArray1D< Type >::m_stride, and dlr::numeric::SubArray1D< Type >::size().

template<class Type >
SubArray1D< Type > & dlr::numeric::SubArray1D< Type >::operator-= ( const SubArray1D< 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 SubArray1D instance, the elements of which will be subtracted from the elements of *this.
Returns:
A reference to *this.

Definition at line 425 of file subArray1D.h.

References dlr::numeric::SubArray1D< Type >::m_source, dlr::numeric::SubArray1D< Type >::m_start, dlr::numeric::SubArray1D< Type >::m_stride, and dlr::numeric::SubArray1D< Type >::size().

template<class Type >
SubArray1D< Type > & dlr::numeric::SubArray1D< 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 398 of file subArray1D.h.

References dlr::numeric::SubArray1D< Type >::size().

template<class Type >
SubArray1D< Type > & dlr::numeric::SubArray1D< Type >::operator= ( const SubArray1D< 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 SubArray1D instance to be copied
Returns:
A reference to *this.

Definition at line 389 of file subArray1D.h.

template<class Type>
size_t dlr::numeric::SubArray1D< Type >::size (  )  const [inline]

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

For example, if a SubArray1D references every third element of an 18 element Array1D, then its size() method will return 6.

Returns:
The number of elements referenced by *this.

Definition at line 100 of file subArray1D.h.

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

template<class Type>
size_t dlr::numeric::SubArray1D< Type >::start (  )  const [inline]

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

For example, if a SubArray1D references every third element of an 18 element Array1D, starting from element 4, then its start() method will return 4.

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

Definition at line 112 of file subArray1D.h.

template<class Type>
size_t dlr::numeric::SubArray1D< Type >::stride (  )  const [inline]

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

For example, if a SubArray1D references every third element of an Array1D, then its stride() method will return 3.

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

Definition at line 124 of file subArray1D.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