#include <MatrixUtils.h>
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). | |
|
|
Possible types of matrix extensions.
|
|
||||||||||||||||||||
|
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 <functional> ... Matrix<int> 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<int> large(MatrixUtils::compare<std::greater<int> >(test, 5, false); //Set six to one and others to zero Matrix<int> six(MatrixUtils::compare<std::equal_to<int> >(test, 6)); |
|
||||||||||||||||||||||||
|
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.
|
|
||||||||||||||||||||||||
|
Extend a matrix by adding data to its sides.
|
|
||||||||||||||||||||||||
|
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 <functional> ... Matrix<int> test(3,3, 1,2,3, 4,5,6, 7,8,9); List<int> rows, cols; //Collect the coordinates of all items that are smaller than or equal to three MatrixUtils::findCoordinates<std::less_equal<int> >(test, 3, rows, cols); //rows = {0, 0}, cols = {0, 1} |
|
||||||||||||||||||||||||||||
|
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.
|
|
||||||||||
|
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. |