OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Array2D< T > Class Template Reference

Two-dimensional array. More...

#include <Array2D.h>

Inheritance diagram for Array2D< T >:
Collaboration diagram for Array2D< T >:

Public Types

typedef T value_type
 The value type of the array.
typedef T * iterator
 The iterator type for sequential access to all elements.
typedef const T * const_iterator
 The iterator type for sequential access to all elements.
typedef T * row_iterator
 The iterator type for access by rows.
typedef const T * const_row_iterator
 The iterator type for access by rows for a constant array.
typedef SliceIterator< T > col_iterator
 The iterator type for access by columns.
typedef ConstSliceIterator< T > const_col_iterator
 The iterator type for access by columns for a constant array.

Public Member Functions

 Array2D ()
 Default constructor.
 Array2D (int rows, int cols)
 Constructor.
 Array2D (int rows, int cols, const T &t)
 Constructor.
 Array2D (const Array2D &)
 ~Array2D ()
Array2D< T > & operator= (const Array2D< T > &)
T & operator() (int r, int c)
 Get element reference.
const T & operator() (int r, int c) const
 Get element value.
int nrows () const
 Get number of rows.
int ncols () const
 Get number of columns.
int size () const
 Get total size (rows times columns).
iterator begin ()
 Get pointer to beginning of data.
iterator end ()
 Get pointer past end of data.
const_iterator begin () const
 Get pointer to beginning of data.
const_iterator end () const
 Get pointer past end of data.
row_iterator row_begin (int r)
 Get row iterator.
row_iterator row_end (int r)
 Get row iterator.
const_row_iterator row_begin (int r) const
 Get row iterator.
const_row_iterator row_end (int r) const
 Get row iterator.
row_iterator operator[] (int r)
 Get row iterator.
const_row_iterator operator[] (int r) const
 Get row iterator.
col_iterator col_begin (int c)
 Get column iterator.
col_iterator col_end (int c)
 Get column iterator.
const_col_iterator col_begin (int c) const
 Get column iterator.
const_col_iterator col_end (int c) const
 Get column iterator.
void getColumn (Array1D< T > &toArray, int c) const
 Fetch column.
void getRow (Array1D< T > &toArray, int r) const
 Fetch row.
void putColumn (const Array1D< T > &fromArray, int c)
 Store column.
void putRow (const Array1D< T > &fromArray, int r)
 Store row.
void swapColumns (int c1, int c2)
 Exchange columns.
void swapRows (int row1, int row2)
 Exchange rows.

Protected Attributes

int rows
int cols
int len
T * data

Detailed Description

template<class T>
class Array2D< T >

Two-dimensional array.

Definition at line 40 of file Array2D.h.

Member Typedef Documentation

◆ col_iterator

template<class T>
typedef SliceIterator<T> Array2D< T >::col_iterator

The iterator type for access by columns.

Definition at line 61 of file Array2D.h.

◆ const_col_iterator

template<class T>
typedef ConstSliceIterator<T> Array2D< T >::const_col_iterator

The iterator type for access by columns for a constant array.

Definition at line 64 of file Array2D.h.

◆ const_iterator

template<class T>
typedef const T* Array2D< T >::const_iterator

The iterator type for sequential access to all elements.

Definition at line 52 of file Array2D.h.

◆ const_row_iterator

template<class T>
typedef const T* Array2D< T >::const_row_iterator

The iterator type for access by rows for a constant array.

Definition at line 58 of file Array2D.h.

◆ iterator

template<class T>
typedef T* Array2D< T >::iterator

The iterator type for sequential access to all elements.

Definition at line 48 of file Array2D.h.

◆ row_iterator

template<class T>
typedef T* Array2D< T >::row_iterator

The iterator type for access by rows.

Definition at line 55 of file Array2D.h.

◆ value_type

template<class T>
typedef T Array2D< T >::value_type

The value type of the array.

Definition at line 45 of file Array2D.h.

Constructor & Destructor Documentation

◆ Array2D() [1/4]

template<class T>
Array2D< T >::Array2D ( )
inline

◆ Array2D() [2/4]

template<class T>
Array2D< T >::Array2D ( int rows,
int cols )
inline

Constructor.

Definition at line 246 of file Array2D.h.

References c, cols, data, len, and rows.

◆ Array2D() [3/4]

template<class T>
Array2D< T >::Array2D ( int rows,
int cols,
const T & t )
inline

Constructor.

Definition at line 252 of file Array2D.h.

References begin(), c, cols, data, end(), len, and rows.

Here is the call graph for this function:

◆ Array2D() [4/4]

template<class T>
Array2D< T >::Array2D ( const Array2D< T > & array)
inline

Definition at line 239 of file Array2D.h.

References Array2D(), begin(), cols, data, end(), len, and rows.

Here is the call graph for this function:

◆ ~Array2D()

template<class T>
Array2D< T >::~Array2D ( )
inline

Definition at line 259 of file Array2D.h.

References data.

Member Function Documentation

◆ begin() [1/2]

template<class T>
Array2D< T >::iterator Array2D< T >::begin ( )
inline

Get pointer to beginning of data.

Definition at line 319 of file Array2D.h.

References data.

Referenced by Array2D(), Array2D(), Matrix< T >::operator+=(), operator-(), Matrix< T >::operator-=(), and operator=().

◆ begin() [2/2]

template<class T>
Array2D< T >::const_iterator Array2D< T >::begin ( ) const
inline

Get pointer to beginning of data.

Definition at line 331 of file Array2D.h.

References data.

◆ col_begin() [1/2]

template<class T>
Array2D< T >::col_iterator Array2D< T >::col_begin ( int c)

Get column iterator.

Definition at line 391 of file Array2D.h.

References c, cols, and data.

Referenced by LUMatrix< T >::backSubstitute(), Matrix< T >::dotm(), getColumn(), Matrix< T >::operator+=(), Matrix< T >::operator-=(), putColumn(), and swapColumns().

◆ col_begin() [2/2]

template<class T>
Array2D< T >::const_col_iterator Array2D< T >::col_begin ( int c) const

Get column iterator.

Definition at line 409 of file Array2D.h.

References c, cols, and data.

◆ col_end() [1/2]

template<class T>
Array2D< T >::col_iterator Array2D< T >::col_end ( int c)

Get column iterator.

Definition at line 400 of file Array2D.h.

References c, cols, data, and len.

Referenced by getColumn(), and swapColumns().

◆ col_end() [2/2]

template<class T>
Array2D< T >::const_col_iterator Array2D< T >::col_end ( int c) const

Get column iterator.

Definition at line 418 of file Array2D.h.

References c, cols, data, and len.

◆ end() [1/2]

template<class T>
Array2D< T >::iterator Array2D< T >::end ( )
inline

Get pointer past end of data.

Definition at line 325 of file Array2D.h.

References data, and len.

Referenced by Array2D(), Array2D(), and operator=().

◆ end() [2/2]

template<class T>
Array2D< T >::const_iterator Array2D< T >::end ( ) const
inline

Get pointer past end of data.

Definition at line 337 of file Array2D.h.

References data, and len.

◆ getColumn()

template<class T>
void Array2D< T >::getColumn ( Array1D< T > & toArray,
int c ) const

Fetch column.

Definition at line 427 of file Array2D.h.

References Array1D< T >::begin(), c, col_begin(), col_end(), rows, and Array1D< T >::size().

Here is the call graph for this function:

◆ getRow()

template<class T>
void Array2D< T >::getRow ( Array1D< T > & toArray,
int r ) const

Fetch row.

Definition at line 434 of file Array2D.h.

References Array1D< T >::begin(), cols, row_begin(), row_end(), and Array1D< T >::size().

Here is the call graph for this function:

◆ ncols()

◆ nrows()

◆ operator()() [1/2]

template<class T>
T & Array2D< T >::operator() ( int r,
int c )
inline

Get element reference.

Definition at line 283 of file Array2D.h.

References c, cols, data, ncols(), and rows.

Here is the call graph for this function:

◆ operator()() [2/2]

template<class T>
const T & Array2D< T >::operator() ( int r,
int c ) const
inline

Get element value.

Definition at line 292 of file Array2D.h.

References c, cols, data, ncols(), and rows.

Here is the call graph for this function:

◆ operator=()

template<class T>
Array2D< T > & Array2D< T >::operator= ( const Array2D< T > & rhs)
inline

Definition at line 265 of file Array2D.h.

References Array2D(), begin(), cols, data, end(), len, and rows.

Referenced by Matrix< T >::operator=(), and Matrix< T >::operator=().

Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T>
Array2D< T >::row_iterator Array2D< T >::operator[] ( int r)

Get row iterator.

Definition at line 379 of file Array2D.h.

References cols, and data.

◆ operator[]() [2/2]

template<class T>
Array2D< T >::const_row_iterator Array2D< T >::operator[] ( int r) const

Get row iterator.

Definition at line 385 of file Array2D.h.

References cols, and data.

◆ putColumn()

template<class T>
void Array2D< T >::putColumn ( const Array1D< T > & fromArray,
int c )

Store column.

Definition at line 441 of file Array2D.h.

References Array1D< T >::begin(), c, col_begin(), Array1D< T >::end(), rows, and Array1D< T >::size().

Here is the call graph for this function:

◆ putRow()

template<class T>
void Array2D< T >::putRow ( const Array1D< T > & fromArray,
int r )

Store row.

Definition at line 450 of file Array2D.h.

References Array1D< T >::begin(), cols, Array1D< T >::end(), row_begin(), and Array1D< T >::size().

Here is the call graph for this function:

◆ row_begin() [1/2]

template<class T>
Array2D< T >::row_iterator Array2D< T >::row_begin ( int r)

Get row iterator.

Definition at line 343 of file Array2D.h.

References cols, data, and rows.

Referenced by Matrix< T >::dotcv(), Matrix< T >::dotm(), getRow(), putRow(), swapRows(), and Matrix< T >::transpose().

◆ row_begin() [2/2]

template<class T>
Array2D< T >::const_row_iterator Array2D< T >::row_begin ( int r) const

Get row iterator.

Definition at line 361 of file Array2D.h.

References cols, data, and rows.

◆ row_end() [1/2]

template<class T>
Array2D< T >::row_iterator Array2D< T >::row_end ( int r)

Get row iterator.

Definition at line 352 of file Array2D.h.

References cols, data, and rows.

Referenced by Matrix< T >::dotcv(), Matrix< T >::dotm(), getRow(), swapRows(), and Matrix< T >::transpose().

◆ row_end() [2/2]

template<class T>
Array2D< T >::const_row_iterator Array2D< T >::row_end ( int r) const

Get row iterator.

Definition at line 370 of file Array2D.h.

References cols, data, and rows.

◆ size()

template<class T>
int Array2D< T >::size ( ) const
inline

Get total size (rows times columns).

Definition at line 313 of file Array2D.h.

References len.

◆ swapColumns()

template<class T>
void Array2D< T >::swapColumns ( int c1,
int c2 )

Exchange columns.

Definition at line 459 of file Array2D.h.

References col_begin(), and col_end().

Here is the call graph for this function:

◆ swapRows()

template<class T>
void Array2D< T >::swapRows ( int row1,
int row2 )

Exchange rows.

Definition at line 465 of file Array2D.h.

References row_begin(), and row_end().

Here is the call graph for this function:

Member Data Documentation

◆ cols

◆ data

◆ len

template<class T>
int Array2D< T >::len
protected

Definition at line 222 of file Array2D.h.

Referenced by Array2D(), Array2D(), Array2D(), Array2D(), col_end(), col_end(), end(), end(), operator=(), and size().

◆ rows


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