SCPPNT::Region2D< Array2D > Class Template Reference

A rectangular subset of a matrix. More...

#include <region2d.h>

List of all members.

Public Types

typedef Array2D array_type
 Type of matrix underlying region.
typedef Array2D::size_type size_type
 Subscript type.
typedef Array2D::value_type value_type
 Type of elements stored in matrix.
typedef Array2D::element_type element_type
 Type of elements stored in matrix.
typedef Array2D::pointer pointer
 Pointer to type stored in matrix.
typedef Array2D::reference reference
 Reference to type stored in matrix.
typedef Array2D::const_reference const_reference
 Reference to type stored in constant matrix.
typedef Array2D::row_iterator row_iterator
 Iterator over elements of a row.
typedef Array2D::const_row_iterator const_row_iterator
 Iterator over constant elements of a row.
typedef Array2D::column_iterator column_iterator
 Iterator over elements of a column.
typedef
Array2D::const_column_iterator 
const_column_iterator
 Iterator over constant elements of a column.
typedef row_iteratorrows_iterator
 Iterator over row iterators (points to row_iterator object for a row).
typedef const_row_iteratorconst_rows_iterator
 Iterator over row iterators (points to const_row_iterator object for a row).
typedef column_iteratorcolumns_iterator
 Iterator over column iterators (points to column_iterator object for a column).
typedef const_column_iteratorconst_columns_iterator
 Iterator over column iterators (points to const_column_iterator object for a column).
typedef Region2D_iterator
< value_type, typename
Region2D< Array2D >
::rows_iterator
iterator
 Iterator over all elements ("typename" keyword added on next two lines, ww, 12-6-2007).
typedef Region2D_iterator
< value_type, typename
Region2D< Array2D >
::const_rows_iterator
const_iterator
 Iterator over all constant elements.
typedef Array2D::diag_iterator diag_iterator
 Iterator over elements of a matrix diagonal.
typedef
Array2D::const_diag_iterator 
const_diag_iterator
 Iterator over constant elements of a matrix diagonal.

Public Member Functions

const array_typearray () const
 Return matrix that is the basis of the view.
Subscript num_rows () const
 Return number of rows in matrix.
Subscript num_columns () const
 Return number of columns in matrix.
Subscript lbound () const
 Returns lower bound of subscript.
Subscript dim (Subscript i) const
 Return number of rows if argument is 1, number of columns if argument is 2.
Subscript size () const
 Return total number of elements in matrix.
 Region2D (Array2D &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
 Constructor from lower and upper limits for rows and columns.
 Region2D (Array2D &A, const Index1D &I, const Index1D &J)
 Constructor using row and column index ranges.
 Region2D (Array2D &A)
 Create a region containing entire matrix (convertion of matrix to region).
 Region2D (Region2D< Array2D > &A, Subscript i1, Subscript i2, Subscript j1, Subscript j2)
 Constructor from region.
 Region2D (const Region2D< Array2D > &A)
 Copy constructor.
 ~Region2D ()
 Destructor.
row_iterator operator[] (Subscript i)
 Return iterator to elements in row i+1 (0-based subscripting).
const_row_iterator operator[] (Subscript i) const
 Return iterator to constant elements in row i+1 (0-based subscripting).
reference operator() (Subscript i, Subscript j)
 Return element in row i and column j, where i and j are 1-based indices.
const_reference operator() (Subscript i, Subscript j) const
 Return constant element in row i and column j, where i and j are 1-based indices.
Region2D< Array2D > operator() (Subscript i1, Subscript i2, Subscript j1, Subscript j2)
 Return new region that is subregion of this region.
Region2D< Array2D > operator() (const Index1D &I, const Index1D &J)
 Return new region that is subregion of this region.
rows_iterator begin_rows ()
 Return iterator pointing to row iterator for first row (iterator over row iterators).
const_rows_iterator begin_rows () const
 Return iterator pointing to row iterator for first row (constant version).
columns_iterator begin_columns ()
 Return iterator pointing to column iterator for first column (iterator over column iterators).
const_columns_iterator begin_columns () const
 Return iterator pointing to column iterator for first column (constant version).
rows_iterator end_rows ()
 Return iterator pointing to row iterator for one past last row (iterator over row iterators).
const_rows_iterator end_rows () const
 Return iterator pointing to row iterator for one past last row (constant version).
columns_iterator end_columns ()
 Return iterator pointing to column iterator for one past last column (iterator over column iterators).
const_columns_iterator end_columns () const
 Return iterator pointing to column iterator for one past last column (constant version).
row_iterator begin_row (Subscript index)
 Return iterator pointing to first element in row 'index' (1-offset).
const_row_iterator begin_row (Subscript index) const
 Return iterator pointing to first element in row 'index' (1-offset).
column_iterator begin_column (Subscript index)
 Return iterator pointing to first element in column 'index' (1-offset).
const_column_iterator begin_column (Subscript index) const
 Return iterator pointing to first element in column 'index' (1-offset).
row_iterator end_row (Subscript index)
 Return iterator pointing to one past last element in row 'index' (1-offset).
const_row_iterator end_row (Subscript index) const
 Return iterator pointing to one past last element in row 'index' (1-offset).
column_iterator end_column (Subscript index)
 Return iterator pointing to one past last element in column 'index' (1-offset).
const_column_iterator end_column (Subscript index) const
 Return iterator pointing to one past last element in column 'index' (1-offset).
iterator begin ()
 Return iterator pointing to first element of matrix.
const_iterator begin () const
 Return iterator pointing to first element of matrix (constant version).
iterator end ()
 Return iterator pointing to one past last element of matrix.
const_iterator end () const
 Return iterator pointing to one past last element of matrix (constant version).
diag_iterator begin_diagonal (Subscript row, Subscript column)
 Returns iterator pointing to first element of a matrix diagonal.
const_diag_iterator begin_diagonal (Subscript row, Subscript column) const
 Returns iterator pointing to first element of matrix diagonal.
diag_iterator end_diagonal (Subscript row, Subscript column)
 Returns iterator pointing to one past the last element of a matrix diagonal.
const_diag_iterator end_diagonal (Subscript row, Subscript column) const
 Returns iterator pointing to one past the last element of matrix diagonal.
Region2D< Array2D > & operator= (const value_type &scalar)
 Scalar assignment.
Region2D< Array2D > & operator= (const Region2D< Array2D > &R)
 Assignment operator.
template<class MAT>
Region2D< Array2D > & operator+= (const MAT &rhs)
 Add matrix rhs to matrix.
template<class MAT>
Region2D< Array2D > & operator-= (const MAT &rhs)
 Subtract matrix rhs from matrix.
template<class MAT>
Region2D< Array2D > & operator *= (const MAT &rhs)
 Matrix multiply of matrix times rhs (rhs must be square).
Region2D< Array2D > & operator+= (const value_type &value)
 Add scalar to all elements of the matrix.
Region2D< Array2D > & operator-= (const value_type &value)
 Subtract scalar from all elements of the matrix.
Region2D< Array2D > & operator *= (const value_type &value)
 Multiply each element of matrix by scalar value.
Region2D< Array2D > & operator/= (const value_type &value)
 Divide each element of matrix by scalar value.


Detailed Description

template<class Array2D>
class SCPPNT::Region2D< Array2D >

A rectangular subset of a matrix.

View of a rectangular subset of a matrix. All operations that can be done with a SCPPNT::Matrix can be done with a Region2D. Note this is a view of the original matrix so all operations take place on elements of the original matrix, not copies.

Parameters:
Array2D Matrix type that forms the basis of the view. Requires interface consistent with SCPPNT::Matrix.

Definition at line 241 of file region2d.h.


Constructor & Destructor Documentation

template<class Array2D>
SCPPNT::Region2D< Array2D >::Region2D ( Array2D &  A,
Subscript  i1,
Subscript  i2,
Subscript  j1,
Subscript  j2 
) [inline]

Constructor from lower and upper limits for rows and columns.

Parameters:
A Matrix to use as basis of region.
i1 Index in original matrix of first row in region (1-based).
i2 Index in original matrix of last row in region (1-based).
j1 Index in original matrix of first column in region (1-based).
j2 Index in original matrix of last column in region (1-based).

Definition at line 354 of file region2d.h.

00354                                                                                  : A_(A)
00355     {
00356       initialize(i1, i2, j1, j2);
00357     }

template<class Array2D>
SCPPNT::Region2D< Array2D >::Region2D ( Array2D &  A,
const Index1D I,
const Index1D J 
) [inline]

Constructor using row and column index ranges.

Parameters:
A Matrix to use as basis of region
I Gives first and last rows of original matrix to use in region.
J Gives first and last columns of original matrix to use in region.

Definition at line 365 of file region2d.h.

References SCPPNT::Index1D::lbound(), and SCPPNT::Index1D::ubound().

00365                                                              : A_(A)
00366     {
00367       initialize(I.lbound(), I.ubound(), J.lbound(), J.ubound());
00368     }

Here is the call graph for this function:

template<class Array2D>
SCPPNT::Region2D< Array2D >::Region2D ( Region2D< Array2D > &  A,
Subscript  i1,
Subscript  i2,
Subscript  j1,
Subscript  j2 
) [inline]

Constructor from region.

Parameters:
A Region to use as basis of region.
i1 Index in original region of first row in new region (1-based).
i2 Index in original region of last row in new region (1-based).
j1 Index in original region of first column in new region (1-based).
j2 Index in original region of last column in new region (1-based).

Definition at line 384 of file region2d.h.

References SCPPNT::Region2D< Array2D >::offset_.

00385     : A_(A.A_)
00386     {
00387       initialize(i1 + A.offset_[0], i2 + A.offset_[0], j1 + A.offset_[1], j2 + A.offset_[1]);
00388     }


Member Function Documentation

template<class Array2D>
Region2D<Array2D> SCPPNT::Region2D< Array2D >::operator() ( Subscript  i1,
Subscript  i2,
Subscript  j1,
Subscript  j2 
) [inline]

Return new region that is subregion of this region.

Parameters:
i1 Smallest row in current region to be contained in subregion (1-based)
i2 Largest row in current region to be contained in subregion (1-based)
j1 Smallest column in current region to be contained in subregion (1-based)
j2 Largest column in current region to be contained in subregion (1-based)

Definition at line 438 of file region2d.h.

00440     {
00441       return Region2D<Array2D>(A_,
00442           i1+offset_[0], offset_[0] + i2,
00443           j1+offset_[1], offset_[1] + j2);
00444     }

template<class Array2D>
Region2D<Array2D> SCPPNT::Region2D< Array2D >::operator() ( const Index1D I,
const Index1D J 
) [inline]

Return new region that is subregion of this region.

Parameters:
I Smallest and largest rows of current retion to be contained in subregion (1-based)
J Smallest and largest columns of current retion to be contained in subregion (1-based)

Definition at line 451 of file region2d.h.

References SCPPNT::Index1D::lbound(), and SCPPNT::Index1D::ubound().

00453     {
00454       return Region2D<Array2D>(A_, I.lbound()+offset_[0],
00455           offset_[0] + I.ubound(), offset_[1]+J.lbound(),
00456           offset_[1] + J.ubound());
00457     }

Here is the call graph for this function:

template<class Array2D>
Region2D< Array2D >::diag_iterator SCPPNT::Region2D< Array2D >::begin_diagonal ( Subscript  row,
Subscript  column 
) [inline]

Returns iterator pointing to first element of a matrix diagonal.

Returns iterator pointing to the first element of the matrix diagonal given by (row, column), (row+1, column+1), (row+2, column+2), ... For example, if row=1 and column=1 then an iterator pointing to the first element of the main diagnonal is returned.

Parameters:
row 1-based row number for initial element of diagonal.
column 1-based column number for initial element of diagonal.

Definition at line 853 of file region2d.h.

Referenced by SCPPNT::Region2D< Array2D >::end_diagonal().

00854   {
00855 
00856     diag_iterator it = A_.begin_diagonal(row + offset_[0], column + offset_[1]);
00857 
00858 #ifdef SCPPNT_BOUNDS_CHECK
00859     it.set_size(diagonal_size(row, column));
00860 #endif
00861 
00862     return it;
00863   }

Here is the caller graph for this function:

template<class Array2D>
Region2D< Array2D >::const_diag_iterator SCPPNT::Region2D< Array2D >::begin_diagonal ( Subscript  row,
Subscript  column 
) const [inline]

Returns iterator pointing to first element of matrix diagonal.

Returns iterator pointing to the first element of the matrix diagonal given by (row, column), (row+1, column+1), (row+2, column+2), ... For example, if row=1 and column=1 then an iterator pointing to the first element of the main diagnonal is returned.

Parameters:
row 1-based row number for initial element of diagonal.
column 1-based column number for initial element of diagonal.

Definition at line 876 of file region2d.h.

00877   {
00878     const_diag_iterator it = A_.begin_diagonal(row + offset_[0], column + offset_[1]);
00879 
00880 #ifdef SCPPNT_BOUNDS_CHECK
00881     it.set_size(diagonal_size(row, column));
00882 #endif
00883 
00884     return it;
00885   }

template<class Array2D>
Region2D< Array2D >::diag_iterator SCPPNT::Region2D< Array2D >::end_diagonal ( Subscript  row,
Subscript  column 
) [inline]

Returns iterator pointing to one past the last element of a matrix diagonal.

Returns iterator pointing to the one past last element of the matrix diagonal given by (row, column), (row+1, column+1), (row+2, column+2), ... For example, for a square matrix with n rows and columns end_diagonal(1, 1) returns an iterator pointing to the element (row+n, column+n), which is one past the last element of the main diagonal.

Parameters:
row 1-based row number for initial element of diagonal.
column 1-based column number for initial element of diagonal.

Definition at line 899 of file region2d.h.

References SCPPNT::Region2D< Array2D >::begin_diagonal().

00900   {
00901     diag_iterator it = begin_diagonal(row, column);
00902     return it + diagonal_size(row, column);
00903   }

Here is the call graph for this function:

template<class Array2D>
Region2D< Array2D >::const_diag_iterator SCPPNT::Region2D< Array2D >::end_diagonal ( Subscript  row,
Subscript  column 
) const [inline]

Returns iterator pointing to one past the last element of matrix diagonal.

Returns iterator pointing to the one past last element of the matrix diagonal given by (row, column), (row+1, column+1), (row+2, column+2), ... For example, for a square matrix with n rows and columns end_diagonal(1, 1) returns an iterator pointing to the element (row+n, column+n), which is one past the last element of the main diagonal.

Parameters:
row 1-based row number for initial element of diagonal.
column 1-based column number for initial element of diagonal.

Definition at line 917 of file region2d.h.

References SCPPNT::Region2D< Array2D >::begin_diagonal().

00918   {
00919     const_diag_iterator it = begin_diagonal(row, column);
00920     return it + diagonal_size(row, column);
00921   }

Here is the call graph for this function:

template<class Array2D>
Region2D< Array2D > & SCPPNT::Region2D< Array2D >::operator= ( const Region2D< Array2D > &  R  )  [inline]

Assignment operator.

Assign contents of this region to those of region R.

Definition at line 930 of file region2d.h.

References SCPPNT::Region2D< Array2D >::begin(), SCPPNT::Region2D< Array2D >::num_columns(), and SCPPNT::Region2D< Array2D >::num_rows().

00931   {
00932     Subscript M = num_rows();
00933     Subscript N = num_columns();
00934 
00935     if (M != R.num_rows() || N != R.num_columns())
00936     {
00937       throw BadDimension("Region2D<Array2D>::operator=(const Region2D)");
00938     }
00939 
00940     const_iterator ir = R.begin();
00941     iterator ithis = begin();
00942     for (int i = M*N; i--; ++ir, ++ithis)
00943     {
00944       *ithis = *ir;
00945     }
00946     return *this;
00947   }

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Tue Dec 18 23:34:37 2007 for SCPPNT by  doxygen 1.5.4