Base Framework
|
#include <base/math/Matrix.h>
Inherits Object.
Classes | |
class | ElementReference |
Reference to an element within a matrix. More... | |
class | IncompatibleMatrices |
Raised if an operation is given incompatible matrices to work on. More... | |
class | MatrixException |
Exception raised by the Matrix class. More... | |
class | NotSquare |
Raised by some operations if matrix is non-square. More... | |
class | Row |
class | RowReference |
Reference to a row within a matrix. More... | |
class | Singular |
Raised by some operations if matrix is singular. More... | |
Public Member Functions | |
Matrix () noexcept | |
Matrix (const Dimension &dimension) | |
Matrix (const TYPE elements[], const Dimension &dimension) | |
Matrix (Enumerator< ReadEnumeratorTraits< TYPE > > &diagonal, const Dimension &dimension) | |
Matrix (const Matrix ©) noexcept | |
Matrix & | operator= (const Matrix &assign) |
Dimension | getDimension () const noexcept |
unsigned int | getRows () const noexcept |
unsigned int | getColumns () const noexcept |
bool | isEmpty () const noexcept |
bool | isSquare () const noexcept |
bool | isEqual (const Matrix &value) const noexcept |
bool | isZero () const noexcept |
bool | isDiagonal () const noexcept |
bool | isLowerTriangular () const noexcept |
bool | isUpperTriangular () const noexcept |
bool | isSymmetric () const noexcept |
TYPE | getNorm () const noexcept |
TYPE | getDeterminant () const |
Matrix | getMinor (unsigned int row, unsigned int column) const |
TYPE | getCofactor (unsigned int row, unsigned int column) const |
Matrix | getAdjoint () const |
Matrix | solve (const Matrix< TYPE > &value) const |
const TYPE & | getAt (unsigned int row, unsigned int colum) const |
void | setAt (unsigned int row, unsigned int column, const TYPE &value) |
const TYPE & | operator() (unsigned int row, unsigned int column) const |
RowReference | operator[] (unsigned int row) |
Matrix | plus () const noexcept |
Matrix | minus () const noexcept |
Matrix | invert () const |
Matrix | transpose () const noexcept |
Matrix & | clear () |
Matrix & | identity () |
Matrix & | zeroAdjust (const TYPE &zero) |
Matrix & | rowEchelon () |
Matrix & | pivot (unsigned int row, unsigned int column) |
Matrix & | clip (unsigned int rows, unsigned int columns) |
Matrix & | negate () |
Matrix & | add (const Matrix &value) |
Matrix & | subtract (const Matrix &value) |
Matrix & | multiply (const TYPE &value) |
Matrix & | divide (const TYPE &value) |
Matrix & | negate (const Matrix &value) |
Matrix & | add (const Matrix &left, const Matrix &right) |
Matrix & | subtract (const Matrix &left, const Matrix &right) |
Matrix & | multiply (const Matrix< TYPE > &left, const Matrix< TYPE > &right) |
Matrix & | multiply (const Matrix &left, const TYPE &right) |
Matrix & | multiply (const TYPE &left, const Matrix &right) |
Matrix & | divide (const Matrix &left, const TYPE &right) |
Matrix & | transpose (const Matrix &matrix) |
bool | operator== (const Matrix &value) const noexcept |
Matrix & | operator+= (const Matrix &value) |
Matrix & | operator-= (const Matrix &value) |
Matrix & | operator*= (const TYPE &value) |
Matrix & | operator/= (const TYPE &value) |
Matrix | operator+ () const |
Matrix | operator- () const |
Protected Member Functions | |
TYPE * | getMutableElements () |
TYPE * | getElements () |
const TYPE * | getReadOnlyElements () const noexcept |
const TYPE * | getElements () const noexcept |
bool | isCompatible (const Matrix &value) const noexcept |
void | setSize (unsigned int rows, unsigned int columns) |
void | setDimension (const Matrix &value) |
MemorySize | getSize () const noexcept |
void | validateElement (unsigned int row, unsigned int column) const |
void | validateRow (unsigned int row) const |
void | validateColumn (unsigned int column) const |
unsigned int | getIndexOfElement (unsigned int row, unsigned int column) const noexcept |
Protected Attributes | |
Reference< ReferenceCountedAllocator< TYPE > > | elements |
unsigned int | rows = 0 |
unsigned int | columns = 0 |
Related Functions | |
(Note that these are not member functions.) | |
template<class TYPE > | |
bool | operator== (const Matrix< TYPE > &left, const Matrix< TYPE > &right) noexcept |
template<class TYPE > | |
Matrix< TYPE > | operator+ (const Matrix< TYPE > &left, const Matrix< TYPE > &right) |
template<class TYPE > | |
Matrix< TYPE > | operator- (const Matrix< TYPE > &left, const Matrix< TYPE > &right) |
template<class TYPE > | |
Matrix< TYPE > | operator* (const Matrix< TYPE > &left, const Matrix< TYPE > &right) |
template<class TYPE > | |
Matrix< TYPE > | operator* (const Matrix< TYPE > &left, const TYPE &right) |
template<class TYPE > | |
Matrix< TYPE > | operator* (const TYPE &left, const Matrix< TYPE > &right) |
template<class TYPE > | |
Matrix< TYPE > | operator/ (const Matrix< TYPE > &left, const Matrix< TYPE > &right) |
template<class TYPE > | |
Matrix< TYPE > | operator/ (const Matrix< TYPE > &left, const TYPE &right) |
template<class TYPE > | |
Matrix< TYPE > | operator/ (const TYPE &left, const Matrix< TYPE > &right) |
Initializes a matrix with no elements.
Initializes matrix with the specified dimension.
dimension | The desired dimension of the matrix. |
Initializes matrix using the elements of an array. The elements are expected to be ordered from left to right and top to bottom.
elements | The desired elements of the matrix. |
dimension | The desired dimension of the matrix. |
Matrix< TYPE >::Matrix | ( | Enumerator< ReadEnumeratorTraits< TYPE > > & | diagonal, |
const Dimension & | dimension | ||
) |
Initializes matrix as a diagonal matrix with the diagonal elements provided by the specified enumerator. Raises OutOfDomain if enumeration is empty.
diagonal | The enumerator containing the desired diagonal elements. |
dimension | The desired dimension of the matrix. |
Initializes matrix from other matrix.
matrix | The matrix to be copied. |
Adds the specified matrix to this matrix.
value | The matrix to be added. |
Throws away any elements that exceed the specified dimension.
rows | The desired number of row. |
columns | The desired number of columns. |
Matrix& Matrix< TYPE >::divide | ( | const Matrix< TYPE > & | left, |
const TYPE & | right | ||
) |
Sets this matrix to the result of the division of the left by right operand.
left | The left operand. |
right | The right operand. |
Divides this matrix with the specified value.
value | The divisor. |
Returns the adjoint of this matrix.
const TYPE& Matrix< TYPE >::getAt | ( | unsigned int | row, |
unsigned int | colum | ||
) | const |
Returns an enumeration of all the elements in the specified row.
row | The desired row to enumerate. Returns a read-only enumeration of all the elements in the specified row. |
row | The desired row to enumerate. Returns an enumeration of all the elements in the specified column. |
column | The desired column to enumerate. Returns a read-only enumeration of all the elements in the specified column. |
column | The desired column to enumerate. Returns an enumeration of all the elements of the diagonal. Returns a read-only enumeration of all the elements of the diagonal. Returns the element at the specified position. |
row | The row of the element. |
column | The column of the element. |
TYPE Matrix< TYPE >::getCofactor | ( | unsigned int | row, |
unsigned int | column | ||
) | const |
Returns the cofactor of this matrix for the specified element.
row | The row of the element. |
column | The column of the element. |
|
inlinenoexcept |
Returns the number of columns of this matrix.
TYPE Matrix< TYPE >::getDeterminant | ( | ) | const |
Returns the determinant of this matrix.
Returns the dimension of the matrix.
|
inlineprotectednoexcept |
Converts 2D index to 1D index in the element array. Does NOT check boundaries.
Matrix Matrix< TYPE >::getMinor | ( | unsigned int | row, |
unsigned int | column | ||
) | const |
Returns the minor of this matrix.
row | The row to be discarded. |
column | The column to be discarded. |
|
inlineprotected |
Returns the elements of the matrix for modification. May copy all elements of the matrix.
|
noexcept |
Returns the Hilbert-Schmidt norm of the matrix.
|
inlineprotectednoexcept |
Returns the elements of the matrix for read-only.
|
inlinenoexcept |
Returns the number of rows of this matrix.
|
inlineprotectednoexcept |
Gets the number of elements in the matrix.
|
inlineprotectednoexcept |
Returns true if this matrix and the specified matrix have identical dimensions.
|
noexcept |
Returns true if this matrix is a diagonal matrix.
|
inlinenoexcept |
Returns true if the matrix is empty (i.e. has no elements).
Returns true if the matrices are equal.
|
noexcept |
Returns true if this matrix is lower triangular (i.e. the matrix has no non-zero values above the diagonal line).
|
inlinenoexcept |
Returns true if the matrix is a square matrix.
|
noexcept |
Returns true if this matrix is symmetric.
|
noexcept |
Returns true if this matrix is upper triangular (i.e. the matrix has no non-zero values below the diagonal line).
|
noexcept |
Returns true if the matrix is the zero matrix.
Matrix& Matrix< TYPE >::multiply | ( | const Matrix< TYPE > & | left, |
const TYPE & | right | ||
) |
Sets this matrix to the product of the operands.
left | The left operand. |
right | The right operand. |
Matrix& Matrix< TYPE >::multiply | ( | const TYPE & | left, |
const Matrix< TYPE > & | right | ||
) |
Sets this matrix to the product of the operands.
left | The left operand. |
right | The right operand. |
Multiplies this matrix with the specified value.
value | The multiplicator. |
Negates the specified matrix and stores the result in this matrix.
|
inline |
Returns the element at the specified position.
Multiplies this matrix with the specified value.
value | The multiplicator. |
Adds the specified matrix from this matrix.
value | The value to be added. |
Subtracts the specified matrix from this matrix.
value | The value to be subtracted. |
Divides this matrix with the specified value.
value | The divisor. |
Assigns matrix to this matrix.
eq | The matrix containing the desired elements. |
|
inlinenoexcept |
Returns true if the matrices are equal element by element. This member should only be used for integer types.
value | Matrix to be compared. |
|
inline |
Returns a reference to the specified row.
Does a reduced row echelon transformation of this matrix for the specified element. The element value is transformed to 1 and the other values of the column are transformed to 0.
row | The row of the element. |
column | The column of the element. |
Does a row echelon transformation of this matrix.
void Matrix< TYPE >::setAt | ( | unsigned int | row, |
unsigned int | column, | ||
const TYPE & | value | ||
) |
Sets the element at the specified position.
row | The row of the element. |
column | The column of the element. |
value | The desired value. |
|
inlineprotected |
Sets the dimension of this matrix to the dimension of the specified matrix.
|
inlineprotected |
Sets the size of the matrix. Only invocated by constructors.
Returns the solution(s) for the linear system(s).
value | The constant column vector(s). |
Subtracts the specified matrix from this matrix.
value | The matrix to be subtracted. |
Returns a new matrix that is the transpose of this matrix.
Sets this matrix to the transpose of the specified matrix.
matrix | The matrix to be transposed. |
|
inlineprotected |
Raises OutOfRange if column is invalid.
|
inlineprotected |
Raises OutOfRange if element coordinate (row, column) is invalid.
|
inlineprotected |
Raises OutOfRange if row is invalid.
Pivot transformation of this matrix. Solves the equations. Sets the values of this matrix that exceed the specified value to zero (0).
zero | Specifies the zero limit. |
|
protected |
The number of columns in the matrix.
|
protected |
The elements of the matrix stored in an array. The array is guarantied to be non-empty when the matrix object has been initialized.
|
protected |
The number of rows in the matrix.