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

The Array2D class template represents a 2D array of arbitrary type. More...

#include <array2D.h>

Inheritance diagram for dlr::numeric::Array2D< Type >:
[legend]
Collaboration diagram for dlr::numeric::Array2D< Type >:
[legend]

List of all members.

Public Types

typedef Type value_type
 Typedef for value_type describes the contents of the array.
typedef Type * iterator
 Typedef for iterator type helps with standard library interface.
typedef const Type * const_iterator
 Typedef for const_iterator type helps with standard library interface.

Public Member Functions

 Array2D ()
 Default constructor initializes to zero size.
 Array2D (size_t arrayRows, size_t arrayColumns)
 Constructs a "arrayRows x arrayColumns" element array.
 Array2D (const std::string &inputString)
 Construct from an initialization string.
 Array2D (const Array2D< Type > &source)
 The copy constructor does a shallow copy.
 Array2D (size_t arrayRows, size_t arrayColumns, Type *const dataPtr)
 Construct an array around external data.
 Array2D (size_t arrayRows, size_t arrayColumns, Type *const dataPtr, size_t *referenceCountPtr)
 Construct an array around external data which was allocated by an Array?D instance.
virtual ~Array2D ()
 Destroys the Array2D instance and deletes the internal data store if no remaining arrays point to it.
iterator begin ()
 Return begin() iterator for Standard Library algorithms.
const_iterator begin () const
 Return begin() const_iterator for Standard Library algorithms.
void clear ()
 Reset the array to zero size, abandoning all contents.
size_t columns () const
 Returns the array dimension along the "second" axis (the number of columns in the array.
void checkDimension (size_t arrayRows, size_t arrayColumns) const
 Optionally throw an exception if the shape of *this is different than specified.
Array2D< Type > copy () const
 Allocates a new array and deep copies the contents of *this.
template<class Type2 >
void copy (const Array2D< Type2 > &source)
 Deep copies the contents of source.
template<class Type2 >
void copy (const Type2 *dataPtr)
 Copies elements from dataPtr.
Type * data ()
 Returns a pointer to the internal data store.
const Type * data () const
 This version of data(void) is appropriate for const Array2D, and returns a pointer-to-const.
Type * data (size_t index)
 Just like data(void), which is documented above, but returns a pointer to the (index)th element instead of the first element.
const Type * data (size_t index) const
 This version of data(size_t) is appropriate for const Array2D, and returns a pointer-to-const.
Type * data (size_t rowIndex, size_t columnIndex)
 Just like data(void), which is documented above, but returns a pointer to the element indexed by (row, column).
const Type * data (size_t rowIndex, size_t columnIndex) const
 This version of data(size_t, size_t) is appropriate for const Array2D, and returns a pointer-to-const.
bool empty () const
 This member function returns true if the array instance contains no elements.
iterator end ()
 Return end() iterator for Standard Library algorithms.
const_iterator end () const
 Return end() const_iterator for Standard Library algorithms.
Type getElement (size_t index0) const
 This member function returns a specific element of the array by value.
Type getElement (size_t rowIndex, size_t columnIndex) const
 This member function returns a specific element of the array by value.
Array1D< Type > getRow (size_t index)
 Returns an Array1D<Type> which addresses an entire row of *this.
const Array1D< Type > getRow (size_t index) const
 Returns a const Array1D<Type> which addresses an entire row of *this.
bool isAllocated () const
 Indicates whether the internal data array is being managed (and reference counted) by *this.
Array1D< Type > ravel ()
 Returns an Array1D, with size equal to this->size(), which references the same data as *this.
const Array1D< Type > ravel () const
 Returns a const Array1D, with size equal to this->size(), which references the same data as *this.
std::istream & readFromStream (std::istream &inputStream)
 This member function sets the value of the array from an input stream.
size_t * refCountPtr () const
 Temporary function to ease porting of code from early versions of dlr_libs.
void reinit (size_t arrayRows, size_t arrayColumns)
 Changes the shape of the array and reallocates storage.
void reinitIfNecessary (size_t arrayRows, size_t arrayColumns)
 Behaves just like member function reinit() unless *this already has the requested shape, in which case this member function does nothing, or *this has the requested size (but a different shape), in which case this member function behaves just like member function resize().
void reshape (int arrayRows, int arrayColumns)
 Changes the shape of the array.
Array1D< Type > row (size_t index)
 This function is an alias for member function getRow().
const Array1D< Type > row (size_t index) const
 This function is an alias for member function getRow() const.
iterator rowBegin (size_t rowIndex)
 Return a Standard Library style iterator which points to the beginning of the specified row.
const_iterator rowBegin (size_t rowIndex) const
 Return a Standard Library style ocnst iterator which points to the beginning of the specified row.
iterator rowEnd (size_t rowIndex)
 Return a Standard Library style iterator which points one element past the end of the specified row.
const_iterator rowEnd (size_t rowIndex) const
 Return a Standard Library style const iterator which points one element past the end of the specified row.
size_t rows () const
 Returns the array dimension along the "first" axis (the number of rows in the array.
Type & setElement (size_t index0, const Type &value)
 This member function sets the value of a specific element of the array.
Type & setElement (size_t rowIndex, size_t columnIndex, const Type &value)
 This member function sets the value of a specific element of the array.
Array1D< size_t > shape () const
 Returns a 2 element Array1D containing the dimensions of *this along each axis.
size_t shape (size_t axis) const
 Returns the array dimension along the the axis indicated by index.
size_t size () const
 Returns the number of elements in the array.
Array2D< Type > transpose () const
 Compute matrix transpose.
Array2D< Type > & operator= (const Array2D< Type > &source)
 Assignment operator shallow copies the contents of source.
Array2D< Type > & operator= (Type value)
 Assign value to every element in the array.
Type & operator() (size_t index)
 Returns the (index)th element of the array by reference.
Type operator() (size_t index) const
 Returns the (index)th element of the array by value.
Type & operator() (size_t rowIndex, size_t columnIndex)
 Returns a specific element of the array by reference.
Type operator() (size_t rowIndex, size_t columnIndex) const
 Returns a specific element of the array by value.
Type & operator[] (size_t index)
 Returns the (index)th element of the array by reference.
Type operator[] (size_t index) const
 Returns the (index)th element of the array by value.
template<class Type2 >
Array2D< Type > & operator+= (const Array2D< Type2 > &arg)
 Increments each element of *this by the value of the corresponding element of arg.
template<class Type2 >
Array2D< Type > & operator-= (const Array2D< Type2 > &arg)
 Decrements each element of *this by the value of the corresponding element of arg.
template<class Type2 >
Array2D< Type > & operator*= (const Array2D< Type2 > &arg)
 Multiplies each element of *this by the value of the corresponding element of arg.
template<class Type2 >
Array2D< Type > & operator/= (const Array2D< Type2 > &arg)
 Divides each element of *this by the value of the corresponding element of arg.
Array2D< Type > & operator+= (Type arg)
 Increments each element of *this by a constant.
Array2D< Type > & operator-= (Type arg)
 Decrements each element of *this by a constant.
Array2D< Type > & operator*= (Type arg)
 Multiplies each element of *this by a constant.
Array2D< Type > & operator/= (Type arg)
 Divides each element of *this by a constant.


Detailed Description

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

The Array2D class template represents a 2D array of arbitrary type.

This class has internal reference counting.

IMPORTANT: This class does _shallow_ copies by default. If you type:

array1 = array2;

then array1 and array2 point to the same data. To do a deep copy, type

array1.copy(array2);

or

array1 = array2.copy();

The advantage of the first form is that it doesn't involve allocating memory. The advantage of the second form is that there's no error if array1 and array2 have different shapes.

Definition at line 52 of file array2D.h.


Member Typedef Documentation

template<class Type>
typedef const Type* dlr::numeric::Array2D< Type >::const_iterator

Typedef for const_iterator type helps with standard library interface.

Definition at line 71 of file array2D.h.

template<class Type>
typedef Type* dlr::numeric::Array2D< Type >::iterator

Typedef for iterator type helps with standard library interface.

Definition at line 65 of file array2D.h.

template<class Type>
typedef Type dlr::numeric::Array2D< Type >::value_type

Typedef for value_type describes the contents of the array.

Definition at line 60 of file array2D.h.


Constructor & Destructor Documentation

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

Default constructor initializes to zero size.

Definition at line 1350 of file array2D.h.

template<class Type >
dlr::numeric::Array2D< Type >::Array2D ( size_t  arrayRows,
size_t  arrayColumns 
) [inline]

Constructs a "arrayRows x arrayColumns" element array.

Parameters:
arrayRows Number of rows in the array after successful construction.
arrayColumns Number of columns in the array after successful construction.

Definition at line 1364 of file array2D.h.

template<class Type >
dlr::numeric::Array2D< Type >::Array2D ( const std::string &  inputString  )  [inline, explicit]

Construct from an initialization string.

The idea is to make constructor very flexible about interpreting string syntax. For now, though, the input string must have the format:

"[[#, #, #, ...], [#, #, #, ...], [#, #, #, ...], ...]"

Where "#" indicates text which can be converted to the element type of the array using the stream input operator.

Parameters:
inputString The argument specifies the string from which the array will be constructed.

Definition at line 1379 of file array2D.h.

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

The copy constructor does a shallow copy.

The newly created array points to the same data as copied array.

Parameters:
source The Array2D<> instance to be copied.

Definition at line 1410 of file array2D.h.

template<class Type>
dlr::numeric::Array2D< Type >::Array2D ( size_t  arrayRows,
size_t  arrayColumns,
Type *const   dataPtr 
) [inline]

Construct an array around external data.

Arrays constructed in this way will not implement reference counting, and will not delete dataPtr when done. The elements of the Array are organized in row-major order.

Parameters:
arrayRows Number of rows in the array after successful construction.
arrayColumns Number of columns in the array after successful construction.
dataPtr A C-style array of Type into which the newly constructed Array2D should index.

Definition at line 1428 of file array2D.h.

template<class Type>
dlr::numeric::Array2D< Type >::Array2D ( size_t  arrayRows,
size_t  arrayColumns,
Type *const   dataPtr,
size_t *  referenceCountPtr 
) [inline]

Construct an array around external data which was allocated by an Array?D instance.

Arrays constructed in this way _do_ implement reference counting, and will delete dataPtr when done. This constructor is provided primarily so that other dimensionality array classes can return Array2D instances which reference their data without being friend classes. Caveat emptor.

Parameters:
arrayRows This argument specifies the number of rows in the array.
arrayColumns This argument specifies the number of columns in the array.
dataPtr This argument is a C-style array containing the data to which the new Array2D instance should refer.
referenceCountPtr This argument is a pointer to a pre-existing reference count for *dataPtr.

Definition at line 1444 of file array2D.h.

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

Destroys the Array2D instance and deletes the internal data store if no remaining arrays point to it.

Definition at line 1459 of file array2D.h.


Member Function Documentation

template<class Type>
const_iterator dlr::numeric::Array2D< Type >::begin (  )  const [inline]

Return begin() const_iterator for Standard Library algorithms.

Returns:
Const iterator pointing to the first element of the array.

Definition at line 181 of file array2D.h.

template<class Type>
iterator dlr::numeric::Array2D< Type >::begin (  )  [inline]

template<class Type >
void dlr::numeric::Array2D< Type >::checkDimension ( size_t  arrayRows,
size_t  arrayColumns 
) const [inline]

Optionally throw an exception if the shape of *this is different than specified.

Parameters:
arrayRows The required number of rows.
arrayColumns The required number of columns.

Definition at line 1467 of file array2D.h.

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

Referenced by dlr::numeric::operator==().

template<class Type>
void dlr::numeric::Array2D< Type >::clear (  )  [inline]

Reset the array to zero size, abandoning all contents.

This is equivalent to this->reinit(0, 0);

Definition at line 188 of file array2D.h.

Referenced by dlr::numeric::Array3D< Type >::readFromStream().

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

template<class Type >
template<class Type2 >
void dlr::numeric::Array2D< Type >::copy ( const Type2 *  dataPtr  )  [inline]

Copies elements from dataPtr.

There must be valid data at all addresses from dataPtr to (dataPtr + this->size());

Parameters:
dataPtr Pointer to the data to be copied.

Definition at line 1514 of file array2D.h.

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

Deep copies the contents of source.

It is an error if source does not have the same size as *this. Note that source need not have exactly the same number of rows and columns as *this, as long as their product is right.

Parameters:
source The array to be copied.
Exceptions:
ValueException thrown when array sizes do not match.

Definition at line 1496 of file array2D.h.

References dlr::numeric::Array2D< Type >::copy(), dlr::numeric::Array2D< Type >::data(), and dlr::numeric::Array2D< Type >::size().

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

Allocates a new array and deep copies the contents of *this.

Returns:
A new array which is a (deep) copy of *this.

Definition at line 1486 of file array2D.h.

References dlr::numeric::Array2D< Type >::copy().

Referenced by dlr::numeric::Array2D< Type >::copy(), dlr::numeric::Array2D< Type >::readFromStream(), and dlr::numeric::BSpline2D< Type >::setControlPoints().

template<class Type>
const Type* dlr::numeric::Array2D< Type >::data ( size_t  rowIndex,
size_t  columnIndex 
) const [inline]

This version of data(size_t, size_t) is appropriate for const Array2D, and returns a pointer-to-const.

Parameters:
rowIndex The row of the element to which the return value should point.
columnIndex The column of the element to which the return value should point.
Returns:
Const pointer to the selected element of the array.

Definition at line 325 of file array2D.h.

template<class Type>
Type* dlr::numeric::Array2D< Type >::data ( size_t  rowIndex,
size_t  columnIndex 
) [inline]

Just like data(void), which is documented above, but returns a pointer to the element indexed by (row, column).

Parameters:
rowIndex The row of the element to which the return value should point.
columnIndex The column of the element to which the return value should point.
Returns:
Pointer to the selected element of the array.

Definition at line 308 of file array2D.h.

template<class Type>
const Type* dlr::numeric::Array2D< Type >::data ( size_t  index  )  const [inline]

This version of data(size_t) is appropriate for const Array2D, and returns a pointer-to-const.

Parameters:
index Indicates to which element of the array the return value should point.
Returns:
Const pointer to the (index)th element of the array.

Definition at line 290 of file array2D.h.

template<class Type>
Type* dlr::numeric::Array2D< Type >::data ( size_t  index  )  [inline]

Just like data(void), which is documented above, but returns a pointer to the (index)th element instead of the first element.

Note that "data(index)" is synonymous with "data() + index" .

Parameters:
index Indicates to which element of the array the return value should point.
Returns:
Pointer to the (index)th element of the array.

Definition at line 275 of file array2D.h.

template<class Type>
const Type* dlr::numeric::Array2D< Type >::data ( void   )  const [inline]

This version of data(void) is appropriate for const Array2D, and returns a pointer-to-const.

Returns:
Const pointer to the internal data store.

Definition at line 262 of file array2D.h.

template<class Type>
Type* dlr::numeric::Array2D< Type >::data ( void   )  [inline]

Returns a pointer to the internal data store.

This is ugly but often necessary for interfacing with external libraries. Data is stored contiguously in raster order. The first element corresponds to indices (0, 0), the second to (0, 1), the (columns + 1)th element corresponds to index (1, 0), and so on.

Returns:
Pointer to the internal data store.

Definition at line 253 of file array2D.h.

Referenced by dlr::numeric::Array2D< Type >::copy(), dlr::numeric::Array2D< Type >::operator*=(), dlr::numeric::Array2D< Type >::operator+=(), dlr::numeric::Array2D< Type >::operator-=(), dlr::numeric::Array2D< Type >::operator/=(), dlr::numeric::Stencil2D< Type, Size >::setTarget(), and dlr::numeric::Array2D< Type >::transpose().

template<class Type>
bool dlr::numeric::Array2D< Type >::empty (  )  const [inline]

This member function returns true if the array instance contains no elements.

It has complexity O(1).

Returns:
The return value indicates whether or not the array is empty.

Definition at line 339 of file array2D.h.

template<class Type>
const_iterator dlr::numeric::Array2D< Type >::end (  )  const [inline]

Return end() const_iterator for Standard Library algorithms.

Returns:
Const iterator pointing just past the last element of the array.

Definition at line 359 of file array2D.h.

template<class Type>
iterator dlr::numeric::Array2D< Type >::end (  )  [inline]

Return end() iterator for Standard Library algorithms.

Returns:
Iterator pointing just past the last element of the array.

Definition at line 349 of file array2D.h.

Referenced by dlr::numeric::operator*(), dlr::numeric::operator+(), dlr::numeric::operator-(), dlr::numeric::operator/(), dlr::numeric::operator==(), dlr::numeric::operator>(), dlr::numeric::operator>=(), dlr::numeric::Array2D< Type >::readFromStream(), and dlr::numeric::squareRoot().

template<class Type>
Type dlr::numeric::Array2D< Type >::getElement ( size_t  rowIndex,
size_t  columnIndex 
) const [inline]

This member function returns a specific element of the array by value.

Parameters:
rowIndex This argument and the next specify which element value should be returned.
columnIndex This argument and the previous specify which element value should be returned.
Returns:
The return value is a copy of the requested element.

Definition at line 388 of file array2D.h.

template<class Type>
Type dlr::numeric::Array2D< Type >::getElement ( size_t  index0  )  const [inline]

This member function returns a specific element of the array by value.

Parameters:
index0 This argument specifies which element value should be returned.
Returns:
The return value is a copy of the requested element.

Definition at line 372 of file array2D.h.

template<class Type >
const Array1D< Type > dlr::numeric::Array2D< Type >::getRow ( size_t  index  )  const [inline]

Returns a const Array1D<Type> which addresses an entire row of *this.

The returned Array1D references the same data as the selected row of *this, and is valid only as long as *this is valid.

Parameters:
index Specifies which row to reference.
Returns:
An Array1D instance referencing the selected row.

Definition at line 1537 of file array2D.h.

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

template<class Type >
Array1D< Type > dlr::numeric::Array2D< Type >::getRow ( size_t  index  )  [inline]

Returns an Array1D<Type> which addresses an entire row of *this.

The returned Array1D references the same data as the selected row of *this, and is valid only as long as *this is valid.

Parameters:
index Specifies which row to reference.
Returns:
An Array1D instance referencing the selected row.

Definition at line 1527 of file array2D.h.

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

Referenced by dlr::numeric::Array2D< Type1 >::row().

template<class Type>
bool dlr::numeric::Array2D< Type >::isAllocated (  )  const [inline]

Indicates whether the internal data array is being managed (and reference counted) by *this.

This member function is only needed in very unusual circumstances.

Returns:
The return value is a bool indicating whether the internal data is being managed by *this.

Definition at line 429 of file array2D.h.

template<class Type>
Type dlr::numeric::Array2D< Type >::operator() ( size_t  rowIndex,
size_t  columnIndex 
) const [inline]

Returns a specific element of the array by value.

Parameters:
rowIndex Row of the selected element.
column Column of the selected element.
Returns:
Value of the array element.

Definition at line 775 of file array2D.h.

template<class Type>
Type& dlr::numeric::Array2D< Type >::operator() ( size_t  rowIndex,
size_t  columnIndex 
) [inline]

Returns a specific element of the array by reference.

Parameters:
rowIndex Row of the selected element.
columnIndex Column of the selected element.
Returns:
Reference to the array element.

Definition at line 760 of file array2D.h.

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

Returns the (index)th element of the array by value.

Elements are indexed in row-major order.

Returns:
Value of the (index)th element of the array.

Definition at line 745 of file array2D.h.

template<class Type>
Type& dlr::numeric::Array2D< Type >::operator() ( size_t  index  )  [inline]

Returns the (index)th element of the array by reference.

Elements are indexed in row-major order.

Parameters:
index Indicates the selected element.
Returns:
Reference to the (index)th element of the array.

Definition at line 734 of file array2D.h.

Referenced by dlr::numeric::Array2D< Type1 >::getElement(), dlr::numeric::Array2D< Type1 >::operator[](), and dlr::numeric::Array2D< Type1 >::setElement().

template<class Type>
Array2D< Type > & dlr::numeric::Array2D< Type >::operator*= ( Type  arg  )  [inline]

Multiplies each element of *this by a constant.

Parameters:
arg Value by which array elements will be multiplied.
Returns:
Reference to *this.

Definition at line 1858 of file array2D.h.

template<class Type >
template<class Type2 >
Array2D< Type > & dlr::numeric::Array2D< Type >::operator*= ( const Array2D< Type2 > &  arg  )  [inline]

Multiplies each element of *this by the value of the corresponding element of arg.

Parameters:
arg Array2D of values by which the elements of *this are to be multiplied.
Exceptions:
ValueException thrown when array sizes differ.
Returns:
Reference to *this.

Definition at line 1818 of file array2D.h.

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

template<class Type>
Array2D< Type > & dlr::numeric::Array2D< Type >::operator+= ( Type  arg  )  [inline]

Increments each element of *this by a constant.

Parameters:
arg Value by which array elements will be incremented.
Returns:
Reference to *this.

Definition at line 1880 of file array2D.h.

template<class Type >
template<class Type2 >
Array2D< Type > & dlr::numeric::Array2D< Type >::operator+= ( const Array2D< Type2 > &  arg  )  [inline]

Increments each element of *this by the value of the corresponding element of arg.

Parameters:
arg Array2D of values to be added to the elements of *this.
Exceptions:
ValueException thrown when array sizes differ.
Returns:
Reference to *this.

Definition at line 1778 of file array2D.h.

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

template<class Type>
Array2D< Type > & dlr::numeric::Array2D< Type >::operator-= ( Type  arg  )  [inline]

Decrements each element of *this by a constant.

Parameters:
arg Value by which array elements will be decremented.
Returns:
Reference to *this.

Definition at line 1891 of file array2D.h.

template<class Type >
template<class Type2 >
Array2D< Type > & dlr::numeric::Array2D< Type >::operator-= ( const Array2D< Type2 > &  arg  )  [inline]

Decrements each element of *this by the value of the corresponding element of arg.

Parameters:
arg Array2D of values to be subtracted from the elements of *this.
Exceptions:
ValueException thrown when array sizes differ.
Returns:
Reference to *this.

Definition at line 1798 of file array2D.h.

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

template<class Type>
Array2D< Type > & dlr::numeric::Array2D< Type >::operator/= ( Type  arg  )  [inline]

Divides each element of *this by a constant.

Parameters:
arg Value by which array elements will be divided.
Returns:
Reference to *this.

Definition at line 1869 of file array2D.h.

template<class Type >
template<class Type2 >
Array2D< Type > & dlr::numeric::Array2D< Type >::operator/= ( const Array2D< Type2 > &  arg  )  [inline]

Divides each element of *this by the value of the corresponding element of arg.

Parameters:
arg Array2D of values by which the elements of *this are to be divided.
Exceptions:
ValueException thrown when array sizes differ.
Returns:
Reference to *this.

Definition at line 1838 of file array2D.h.

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

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

Assign value to every element in the array.

Parameters:
value The value to be copied.
Returns:
Reference to *this.

Definition at line 1747 of file array2D.h.

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

Assignment operator shallow copies the contents of source.

After the copy, both arrays reference the same data.

Parameters:
source The Array2D instance to be copied.
Returns:
Reference to *this.

Definition at line 1756 of file array2D.h.

References dlr::numeric::Array2D< Type >::m_columns, dlr::numeric::Array2D< Type >::m_dataPtr, dlr::numeric::Array2D< Type >::m_isAllocated, dlr::numeric::Array2D< Type >::m_refCountPtr, dlr::numeric::Array2D< Type >::m_rows, and dlr::numeric::Array2D< Type >::m_size.

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

Returns the (index)th element of the array by value.

Synonymous with operator()(size_t) const.

Parameters:
index Indicates the selected element.
Returns:
Value of the (index)th element of the array.

Definition at line 800 of file array2D.h.

template<class Type>
Type& dlr::numeric::Array2D< Type >::operator[] ( size_t  index  )  [inline]

Returns the (index)th element of the array by reference.

Synonymous with operator()(size_t).

Parameters:
index Indicates the selected element.
Returns:
Reference to the (index)th element of the array.

Definition at line 789 of file array2D.h.

template<class Type >
const Array1D< Type > dlr::numeric::Array2D< Type >::ravel (  )  const [inline]

Returns a const Array1D, with size equal to this->size(), which references the same data as *this.

In other words, ravel() returns a flattened version of *this.

Returns:
Array1D referencing the same data as *this.

Definition at line 1547 of file array2D.h.

template<class Type >
Array1D< Type > dlr::numeric::Array2D< Type >::ravel (  )  [inline]

Returns an Array1D, with size equal to this->size(), which references the same data as *this.

In other words, ravel() returns a flattened version of *this.

Returns:
Array1D referencing the same data as *this.

Definition at line 1557 of file array2D.h.

template<class Type >
std::istream & dlr::numeric::Array2D< Type >::readFromStream ( std::istream &  inputStream  )  [inline]

This member function sets the value of the array from an input stream.

The array is modified only if the read was successful, otherwise the array is not modified, and failbit is set in the stream state. Because of this nice behavior, readFromStream is quite slow.

Parameters:
inputStream This is the stream from which to read the array.
Returns:
The return value is a reference to inputStream.

Definition at line 1569 of file array2D.h.

References dlr::numeric::Array2D< Type >::begin(), dlr::numeric::Array1D< Type >::clear(), dlr::numeric::Array2D< Type >::copy(), dlr::numeric::Array2D< Type >::end(), dlr::numeric::Array2D< Type >::reinit(), and dlr::numeric::Array2D< Type >::size().

Referenced by dlr::numeric::operator>>().

template<class Type>
size_t* dlr::numeric::Array2D< Type >::refCountPtr (  )  const [inline]

Temporary function to ease porting of code from early versions of dlr_libs.

The use of this function is discouraged.

Returns:
The return value is a pointer to the internal reference count.

Definition at line 476 of file array2D.h.

template<class Type >
void dlr::numeric::Array2D< Type >::reinit ( size_t  arrayRows,
size_t  arrayColumns 
) [inline]

Changes the shape of the array and reallocates storage.

The current array contents are lost. After a successful call to reinit(), the array will be arrayRows x arrayColumns.

Parameters:
arrayRows Requested row dimension.
arrayColumns Requested column dimension.

Definition at line 1662 of file array2D.h.

Referenced by dlr::numeric::Array2D< Type1 >::clear(), dlr::numeric::BoxIntegrator2D< Type0, Type1 >::fillCache(), dlr::numeric::Array2D< Type >::readFromStream(), and dlr::numeric::Array2D< Type >::reinitIfNecessary().

template<class Type >
void dlr::numeric::Array2D< Type >::reinitIfNecessary ( size_t  arrayRows,
size_t  arrayColumns 
) [inline]

Behaves just like member function reinit() unless *this already has the requested shape, in which case this member function does nothing, or *this has the requested size (but a different shape), in which case this member function behaves just like member function resize().

Parameters:
arrayRows Requested row dimension.
arrayColumns Requested column dimension.

Definition at line 1673 of file array2D.h.

References dlr::numeric::Array2D< Type >::reinit(), dlr::numeric::Array2D< Type >::reshape(), dlr::numeric::Array2D< Type >::rows(), and dlr::numeric::Array2D< Type >::size().

template<class Type >
void dlr::numeric::Array2D< Type >::reshape ( int  arrayRows,
int  arrayColumns 
) [inline]

Changes the shape of the array.

It is an error if (arrayRows * arrayColumns) is not equal to this->size(). Either arrayRows or arrayColumns may be specified as -1, but not both. If one of the arguments is -1, its value will be calculated based on the total size of the array and the value of the other argument.

Parameters:
arrayRows Requested row dimension.
arrayColumns Requested column dimension.
Exceptions:
ValueException thrown when old and new array sizes do not match.

Definition at line 1688 of file array2D.h.

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

Referenced by dlr::numeric::Array2D< Type >::reinitIfNecessary().

template<class Type>
const Array1D<Type> dlr::numeric::Array2D< Type >::row ( size_t  index  )  const [inline]

This function is an alias for member function getRow() const.

Parameters:
index Specifies which row to reference.
Returns:
An Array1D instance referencing the selected row.

Definition at line 544 of file array2D.h.

template<class Type>
Array1D<Type> dlr::numeric::Array2D< Type >::row ( size_t  index  )  [inline]

This function is an alias for member function getRow().

Parameters:
index Specifies which row to reference.
Returns:
An Array1D instance referencing the selected row.

Definition at line 533 of file array2D.h.

Referenced by dlr::numeric::BSpline< Type >::operator()().

template<class Type>
const_iterator dlr::numeric::Array2D< Type >::rowBegin ( size_t  rowIndex  )  const [inline]

Return a Standard Library style ocnst iterator which points to the beginning of the specified row.

Parameters:
rowIndex Specifies which row if the array should be referenced. Row 0 is the top row.
Returns:
Const iterator pointing to the first element of the specified row of the Array2D instance.

Definition at line 572 of file array2D.h.

template<class Type>
iterator dlr::numeric::Array2D< Type >::rowBegin ( size_t  rowIndex  )  [inline]

Return a Standard Library style iterator which points to the beginning of the specified row.

Parameters:
rowIndex Specifies which row if the array should be referenced. Row 0 is the top row.
Returns:
Iterator pointing to the first element of the specified row of the Array2D instance.

Definition at line 558 of file array2D.h.

Referenced by dlr::numeric::BoxIntegrator2D< Type0, Type1 >::fillCache().

template<class Type>
const_iterator dlr::numeric::Array2D< Type >::rowEnd ( size_t  rowIndex  )  const [inline]

Return a Standard Library style const iterator which points one element past the end of the specified row.

Parameters:
rowIndex Specifies which row if the array should be referenced. Row 0 is the top row.
Returns:
Const iterator pointing one element past the end of the specified row.

Definition at line 604 of file array2D.h.

template<class Type>
iterator dlr::numeric::Array2D< Type >::rowEnd ( size_t  rowIndex  )  [inline]

Return a Standard Library style iterator which points one element past the end of the specified row.

Parameters:
rowIndex Specifies which row if the array should be referenced. Row 0 is the top row.
Returns:
Iterator pointing one element past the end of the specified row.

Definition at line 588 of file array2D.h.

Referenced by dlr::numeric::BoxIntegrator2D< Type0, Type1 >::fillCache().

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

template<class Type>
Type& dlr::numeric::Array2D< Type >::setElement ( size_t  rowIndex,
size_t  columnIndex,
const Type &  value 
) [inline]

This member function sets the value of a specific element of the array.

Parameters:
row This argument and the next specify which element value should be set.
column This argument and the previous specify which element value should be set.
value This argument will be copied into the selected array element.
Returns:
The return value is a reference to the newly created array element.

Definition at line 656 of file array2D.h.

template<class Type>
Type& dlr::numeric::Array2D< Type >::setElement ( size_t  index0,
const Type &  value 
) [inline]

This member function sets the value of a specific element of the array.

Parameters:
index0 This argument specifies which element value should be set.
value This argument will be copied into the selected array element.
Returns:
The return value is a reference to the newly set array element.

Definition at line 634 of file array2D.h.

template<class Type >
size_t dlr::numeric::Array2D< Type >::shape ( size_t  axis  )  const [inline]

Returns the array dimension along the the axis indicated by index.

This is synonymous with shape()[axis], but may execute faster.

Parameters:
axis Selected axis.
Exceptions:
ValueException thrown on invalid axis parameter.
Returns:
Dimension along the selected axis.

Definition at line 1723 of file array2D.h.

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

template<class Type >
Array1D< size_t > dlr::numeric::Array2D< Type >::shape (  )  const [inline]

Returns a 2 element Array1D containing the dimensions of *this along each axis.

That is, the first element of the returned array will be this->rows(), and the second element will be this->columns().

Returns:
Array describing the shape of *this.

Definition at line 1712 of file array2D.h.

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

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

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

Compute matrix transpose.

The resulting array does not reference the same memory as *this.

Returns:
Transposed copy of *this.

Definition at line 1901 of file array2D.h.

References dlr::numeric::Array2D< Type >::data(), and dlr::numeric::Array2D< Type >::m_dataPtr.


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

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