#include <Matrix.h>
Inheritance diagram for util::Matrix< T >:

The Matrix class performs the usual matrix operations including addition, subtraction, multiplication, inversion, transpose etc.
Public Methods | |
| Matrix (int size=1, bool clear=true) | |
| Create a size-by-size matrix. | |
| Matrix (int rows, int columns, bool clear=true) | |
| Create a rows-by-columns size matrix. | |
| Matrix (const Matrix &other) | |
| Create a matrix that is an exact copy of another matrix. | |
| template<class U> | Matrix (const Matrix< U > &other) |
| Create a matrix that is holds the contents of another matrix typecasted to the type of this matrix. | |
| Matrix (int rows, int columns, T *data, bool release=false) | |
| Create a matrix that reads its data from the given array. | |
| Matrix (int rows, int columns, T firstElement,...) | |
| Create a matrix with the given number of rows and columns. | |
| Matrix (const List< T > &vector, bool row=true) | |
| Create a row or column matrix. | |
| virtual | ~Matrix () |
| T * | getData () |
| Get the data array for this matrix. | |
| const T * | getData () const |
| Get the data array. | |
| T * | releaseData () |
| Take the ownership of the data in the matrix. | |
| void | setSize (int rows, int columns) |
| Set the size of this matrix. | |
| int | getRows () const |
| Get the number of rows in a matrix. | |
| int | getColumns () const |
| Get the number of colums in a matrix. | |
| List< T > | getRow (int index) const throw (MatrixException&) |
| Get the row vector at index. | |
| List< T > | getColumn (int index) const throw (MatrixException&) |
| Get the column vector at index. | |
| void | setRow (int index, List< T > &row) throw (MatrixException&) |
| Set the row vector to index. | |
| void | setColumn (int index, List< T > &col) throw (MatrixException&) |
| Set the column vector to index. | |
| void | removeRow (int index) throw (MatrixException&) |
| Remove the row from the matrix at index. | |
| void | removeColumn (int index) throw (MatrixException&) |
| Remove the column from the matrix at index. | |
| Matrix & | fliplr () |
| Flip the matrix in horizontal direction (columns). | |
| Matrix & | flipud () |
| Flip the matrix in vertical direction (rows). | |
| Matrix | getTranspose () const |
| Transpose the matrix. | |
| Matrix & | transpose () |
| Transpose the matrix in place. | |
| Matrix | getDotProduct (const Matrix &other) const throw (MatrixException&) |
| Multiply two matrices item-wise. | |
| Matrix & | dotProduct (const Matrix &other) throw (MatrixException&) |
| Multiply two matrices item-wise. | |
| double | determinant (void) const throw (MatrixException&) |
| Determinant of the matrix. | |
| Matrix< double > | inverse (void) const throw (MatrixException&) |
| Makes the inversion for the matrix. | |
| double | cofactor (int row, int col) const throw (MatrixException&) |
| Takes the Cofactor from the matrix at place row,col. | |
| bool | isSingular (void) |
| Tests if matrix is singular. | |
| bool | isDiagonal (void) |
| Tests if matrix is diagonal. | |
| bool | isSymmetric (void) |
| Tests if matrix is symmetric. | |
| bool | isSkewSymmetric (void) |
| Tests if matrix is skew summetric. | |
| void | diagonal (void) |
| Makes this matrix to identitymatrix. | |
| T | sum (void) const |
| Calculate a sum over all matrix entries. | |
| T | max (void) const |
| Get the maximum value. | |
| T | min (void) const |
| Get the minimum value. | |
| void | operator+= (const Matrix &other) throw (MatrixException&) |
| Add a matrix to this matrix. | |
| void | operator-= (const Matrix &other) throw (MatrixException&) |
| Subtract a matrix from this matrix. | |
| void | operator *= (const Matrix &other) throw (MatrixException&) |
| Multiply this matrix with another matrix. | |
| void | operator+= (T value) |
| Add a constant value to this matrix. | |
| void | operator-= (T value) |
| Subtract a constant value to this matrix. | |
| void | operator *= (T value) |
| Multiply this matrix by a constant value. | |
| void | operator/= (T value) |
| Divide this matrix by a constant value. | |
| Matrix & | operator= (const Matrix &other) |
| Set the contents of this matrix to those of another matrix. | |
| template<class U> Matrix & | operator= (const Matrix< U > &other) |
| Set the contents of this matrix to those of another matrix. | |
| Matrix & | operator= (T value) |
| Set all entries in this matrix to the given value. | |
| Matrix & | operator= (const T *contents) |
| Set the contents of this matrix to those stored in the given array. | |
| T & | operator() (int row, int column) |
| Get an item from the matrix. | |
| T | operator() (int row, int column) const |
| Get an item from the matrix. | |
| Matrix | operator() (int row, int column, int rows, int columns) const |
| Get a sub-matrix from this matrix. | |
| template<class U> | operator Matrix () |
| Cast the contents of a matrix to another type. | |
| int | pivot (int row) throw (MatrixException&) |
| Make pivoting starting at the given row. | |
Protected Methods | |
| void | allocate (bool clear=true) |
| Allocate memory for a matrix. | |
| template<class U> void | copy (const Matrix< U > &other) |
| Make a copy of an existing matrix. | |
Protected Attributes | |
| int | _iRows |
| The matrix dimensions. | |
| int | _iColumns |
| The matrix dimensions. | |
| T * | _pData |
| The data array. | |
Friends | |
| template<class U> Matrix< U > | operator+ (const Matrix< U > &m1, const Matrix< U > &m2) throw (MatrixException&) |
| Perform a matrix addition operation. | |
| template<class U> Matrix< U > | operator- (const Matrix< U > &m1, const Matrix< U > &m2) throw (MatrixException&) |
| Perform a matrix subtraction operation. | |
| template<class U> Matrix< U > | operator * (const Matrix< U > &m1, const Matrix< U > &m2) throw (MatrixException&) |
| Perform a matrix multiplication operation. | |
| template<class U> bool | operator== (const Matrix< U > &m1, const Matrix< U > &m2) |
| Compare two matrices. | |
| template<class U> Matrix< U > | operator+ (const Matrix< U > &mat, U value) |
| Perform a constant value addition operation. | |
| template<class U> Matrix< U > | operator- (const Matrix< U > &mat, U value) |
| Perform a constant value subtraction operation. | |
| template<class U> Matrix< U > | operator * (const Matrix< U > &mat, U value) |
| Perform a constant value multiplication operation. | |
| template<class U> Matrix< U > | operator/ (const Matrix< U > &mat, U value) |
| Perform a constant value division operation. | |
| template<class U> std::ostream & | operator<< (std::ostream &sout, const Matrix< U > &m) |
| Write a matrix to an output stream. | |
| template<class U> std::istream & | operator>> (std::istream &sin, Matrix< U > &m) |
| Read a written matrix from an input stream. | |
|
||||||||||||||||
|
Create a size-by-size matrix.
If size is omitted, a 1-by-1 matrix will be created. Note that the initial contents of a a matrix are always set to zero. This is made by using the = operator with an integer argument of zero. For this reason, the = operator for an integer argument must be defined for the content class of the matrix. Note also that if a matrix is to hold objects of any class type, and if matrix atrithmetic is performed on the matrix, then the =, +, +=, -, -=, *, *=, / and /= operators of the content class must be defined for arguments of the same class type.
class MyClass
{
...
public:
MyClass& operator=(const MyClass &o1);
MyClass& operator=(int value);
void operator+=(const MyClass &o1);
void operator-=(const MyClass &o1);
void operator *=(const MyClass &o1);
void operator/=(const MyClass &o1);
friend MyClass operator+(const MyClass &o1, const MyClass &o2);
friend MyClass operator-(const MyClass &o1, const MyClass &o2);
friend MyClass operator *(const MyClass &o1, const MyClass &o2);
friend MyClass operator/(const MyClass &o1, const MyClass &o2);
...
};
...
Matrix<MyClass> mat; //invokes operator=(int) with a zero argument
MyClass mc(123);
mat(0,0) = mc;
mat *= mc;
|
|
||||||||||||||||||||
|
Create a rows-by-columns size matrix.
|
|
||||||||||
|
Create a matrix that is an exact copy of another matrix. (Copy constructor)
|
|
||||||||||||||
|
Create a matrix that is holds the contents of another matrix typecasted to the type of this matrix.
If the matrix to be cloned contains items of any other than the elementary data types, then typecast operator for the wanted type must be defined. Matrix<int> a(2,2); a = 1; Matrix<float> b(a); This will result in b(0,0) holding 1.0f.
|
|
||||||||||||||||||||||||
|
Create a matrix that reads its data from the given array. The size of the resulting matrix will be rows x columns. Among other things, this constructor can be used in efficiently transforming a List into a Matrix: List<int> lst(5); lst.addElements(5,1,2,3,4,5); Matrix<int> rowVector(1, 5, lst.releaseData(), true); Note that in the example, lst will be empty after the releaseData() call. Once can create a column matrix by exchanging the number of rows and columns.
|
|
||||||||||||||||||||||||
|
Create a matrix with the given number of rows and columns. Matrix contents are given as a variable-length parameter list in horizontal raster-scan order. Pay attention that the elements really are of the type you think them to be.
|
|
||||||||||||||||
|
Create a row or column matrix. Take the data for the single column from vector.
|
|
||||||||||
|
Allocate memory for a matrix. The protected variables rows and columns must be set prior to calling this method.
|
|
||||||||||||||||
|
Takes the Cofactor from the matrix at place row,col.
|
|
||||||||||
|
Determinant of the matrix.
|
|
||||||||||
|
Makes this matrix to identitymatrix. (has ones in diagonal and zeros other places). The size of matrix will be minimum of rows or columns, of course square matrix. |
|
||||||||||
|
Multiply two matrices item-wise. The result is stored in this matrix. |
|
||||||||||
|
Get the column vector at index.
|
|
|||||||||
|
Get the data array. The actual contents of the matrix are stored in a one-dimensional array of size rows*columns. The data is ordered so that rows can be read sequentially one after another.
|
|
|||||||||
|
Get the data array for this matrix. The array holds the contens of the matrix from its upper left corner to the lower right one. The data is stored in a horizontal raster-scan manner.
|
|
||||||||||
|
Multiply two matrices item-wise. Return the result. |
|
||||||||||
|
Get the row vector at index.
|
|
|||||||||
|
Transpose the matrix.
|
|
||||||||||
|
Makes the inversion for the matrix.
|
|
||||||||||
|
Multiply this matrix by a constant value.
|
|
||||||||||
|
Multiply this matrix with another matrix.
|
|
|||||||||||||
|
Cast the contents of a matrix to another type. If the contents of the original matrix are not of any elementary type, then an appropriate typecast operator for the content class must be defined. |
|
||||||||||||||||||||||||
|
Get a sub-matrix from this matrix. Take care that the dimensions of the matrix are not exceeded.
|
|
||||||||||||||||
|
Get an item from the matrix.
|
|
||||||||||||||||
|
Get an item from the matrix.
|
|
||||||||||
|
Add a constant value to this matrix.
|
|
||||||||||
|
Add a matrix to this matrix.
|
|
||||||||||
|
Subtract a constant value to this matrix.
|
|
||||||||||
|
Subtract a matrix from this matrix.
|
|
||||||||||
|
Divide this matrix by a constant value.
|
|
||||||||||
|
Set the contents of this matrix to those stored in the given array. The size of the array must be equal to rows*columns, and rows must be stored sequentially one after another.
|
|
||||||||||
|
Set all entries in this matrix to the given value.
Reimplemented in ConvolutionMask< T >. |
|
||||||||||||||
|
Set the contents of this matrix to those of another matrix.
|
|
||||||||||
|
Set the contents of this matrix to those of another matrix.
|
|
||||||||||
|
Make pivoting starting at the given row.
|
|
||||||||||
|
Take the ownership of the data in the matrix. The size of the matrix will be set to zero, and the internal pointer to NULL. A pointer to the data array is returned. |
|
||||||||||
|
Remove the column from the matrix at index.
|
|
||||||||||
|
Remove the row from the matrix at index.
|
|
||||||||||||||||
|
Set the column vector to index.
|
|
||||||||||||||||
|
Set the row vector to index.
|
|
||||||||||||||||
|
Set the size of this matrix. The initial contents of the newly allocated data array are undefined.
|
|
||||||||||
|
Calculate a sum over all matrix entries.
|
|
||||||||||||||||||||
|
Perform a matrix multiplication operation.
|
|
||||||||||||||||||||
|
Perform a matrix addition operation.
|
|
||||||||||||||||||||
|
Perform a matrix subtraction operation.
|