Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members

util::MatrixUtils Class Reference

`#include <MatrixUtils.h>`

Detailed Description

Methods for non-mathematics related matrix operations.

Public Types

enum  ExtendType {
EXTEND_ZEROPAD, EXTEND_SMOOTH0, EXTEND_SMOOTH1, EXTEND_SYMMETRIC,
EXTEND_PERIODIC
}
Possible types of matrix extensions. More...

Static Public Methods

template<class T> Matrix< T > extend (const Matrix< T > &mat, int amount, ExtendType type=EXTEND_ZEROPAD, int sides=-1)
Extend a matrix by adding data to its sides.

template<class T> void turnAround (Matrix< T > &mat)
Turn a matrix around so that its top left value is moved to the bottom right corner.

template<class T> List< Matrix< T > > split (const Matrix< T > &mat, int rows, int cols, int startr=0, int startc=0)
Split a matrix into sub-matrices.

template<class comparator, class T> Matrix< T > compare (const Matrix< T > &mat, T value, bool setToOne=true)
Compare matrix elements to a value.

template<class comparator, class T> void findCoordinates (const Matrix< T > &mat, T value, List< int > &rows, List< int > &columns)
Collect the coordinates of all items in a matrix meeting a comparison requirement.

template<class T> void copy (const Matrix< T > &source, Matrix< T > &target, int targetR, int targetC)
Copy a matrix on top of another.

Static Public Attributes

int TOP = 1
A constant for the top of a matrix (1).

int BOTTOM = 2
A constant for the bottom of a matrix (2).

int LEFT = 4
A constant for the left side of a matrix (4).

int RIGHT = 8
A constant for the right side of a matrix (8).

Member Enumeration Documentation

 enum util::MatrixUtils::ExtendType
 Possible types of matrix extensions. EXTEND_ZEROPAD - pad with zeros EXTEND_SMOOTH0 - constant value EXTEND_SMOOTH1 - first derivative interpolation EXTEND_SYMMETRIC - replicate boundary values EXTEND_PERIODIC - treat the matrix as periodic

Member Function Documentation

 template Matrix< T > util::MatrixUtils::compare ( const Matrix< T > & mat, T value, bool setToOne = true ) ` [static]`
 Compare matrix elements to a value. All matrix items that meet the comparison requirement are either set to one (setToOne == true) or left intact (setToOne == false). Items that do not meet the requirement are set to zero. The size of the returned matrix is the same as the size of the input matrix. Examples: ``` include ... Matrix test(3,3, 1,2,3, 4,5,6, 7,8,9); //Retain all items that are larger than 5 (set others to 0) Matrix large(MatrixUtils::compare >(test, 5, false); //Set six to one and others to zero Matrix six(MatrixUtils::compare >(test, 6)); ```

 template void util::MatrixUtils::copy ( const Matrix< T > & source, Matrix< T > & target, int targetR, int targetC ) ` [static]`

Copy a matrix on top of another.

The contents of the source matrix replace the values in the target matrix, starting at the given upper left row and column coordinates. If the source matrix is too large to fit inside the target, the parts that fall outside the boundaries of the target are ignored.

Parameters:
 source the matrix to be copied target the matrix on which source is copied targetR the start row at target targetC the start column at target

 template Matrix< T > util::MatrixUtils::extend ( const Matrix< T > & mat, int amount, ExtendType type = EXTEND_ZEROPAD, int sides = -1 ) ` [static]`

Extend a matrix by adding data to its sides.

Parameters:
 mat the matrix to be extended amount the number of items to add to each side type the extension type sides a bit mask that tells which sides of the matrix are extended. Use the constant values TOP, BOTTOM, LEFT and RIGHT. TOP+BOTTOM = top and bottom and so on.

 template void util::MatrixUtils::findCoordinates ( const Matrix< T > & mat, T value, List< int > & rows, List< int > & columns ) ` [static]`
 Collect the coordinates of all items in a matrix meeting a comparison requirement. The values in mat are compared to value with the comparator given as a template parameter. If a match is found, the corresponding row and column indices are placed into the two lists supplied as parameters. Example: ``` include ... Matrix test(3,3, 1,2,3, 4,5,6, 7,8,9); List rows, cols; //Collect the coordinates of all items that are smaller than or equal to three MatrixUtils::findCoordinates >(test, 3, rows, cols); //rows = {0, 0}, cols = {0, 1} ```

 template List< Matrix< T > > util::MatrixUtils::split ( const Matrix< T > & mat, int rows, int cols, int startr = 0, int startc = 0 ) ` [static]`

Split a matrix into sub-matrices.

The maximum number of sub-matrices is taken starting from the given upper left corner. The sub-matrices are stored in a list in horizontal raster-scan order.

Parameters:
 mat the matrix to be split rows the height of the sub-matrices cols the width of the sub-matrices startr the row of the start position (upper left corner) startc the column of the start position (upper left corner)

 template void util::MatrixUtils::turnAround ( Matrix< T > & mat ) ` [static]`
 Turn a matrix around so that its top left value is moved to the bottom right corner. The effect is the same as calling flipud() and fliplr() sequentially. The matrix contents are modified in place.

The documentation for this class was generated from the following files:
• MatrixUtils.h
• MatrixUtils.cc

Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.