Class Matrix
A matrix is just like a mathematical matrix where it is similar to essentially a 2d array of of the given type
Template parameters are the type, how many rows, and how many columns
class Matrix(T, uint rows, uint columns)
;
Constructors
Name | Description |
this
|
Constructs a matrix from a two-dimensional array of elements
|
this
|
Constructs a matrix that is identically one value
|
this
|
Constructs a matrix as an identity matrix
|
this
|
Copy constructor for a matrix; creates a copy of the given matrix
|
Fields
Name | Type | Description |
elements
|
T[columns][rows] | The elements of the matrix; stored as an array of rows (i.e. row vectors)
|
Properties
Name | Type | Description |
determinant [get]
|
T | Recursively finds the determinant of the matrix if the matrix is square
Task is done in O(n!) for an nxn matrix, so determinants of matrices of at most size 3x3 are already defined to be more efficient
Not very efficient for large matrices
|
inverse [get]
|
Matrix!(T,rows,columns) | Returns the inverse of a square matrix, which should give the identity if they are multiplied.
|
reducedRowEchelon [get]
|
Matrix!(T,rows,columns) | Returns the matrix in row-echelon form
In reduced row-echelon form, the diagonal elements are equal to one
and all elements below and above the diagonal are zero
This method uses the Gauss-Jordan algorithm, which has arithmetic complexity O(n^3)
Be wary of truncation for integer matrices
|
rowEchelon [get]
|
Matrix!(T,rows,columns) | Returns the matrix in row-echelon form
In row-echelon form, the diagonal elements are equal to one
and all elements below the diagonal are zero
This method uses the Gauss-Jordan algorithm, which has arithmetic complexity O(n^3)
Be wary of truncation for integer matrices
|
transpose [get]
|
Matrix!(T,columns,rows) | The transpose operation returns the matrix 'flipped' about its diagonal -
That is, rows and columns are switched
|
Methods
Name | Description |
getColumn
|
Returns the nth column of the matrix
|
getRow
|
Returns the nth row of the matrix
|
getSlice
|
Returns a rectangular slice of the matrix with the upper left corner at the specified location
and a specified size
Usable to get rows and columns; just set the height or width to 1
|
opAssign
|
Allows assigning the matrix to a static two-dimensional array to set all components of the matrix
|
opAssign
|
Allows assigning the matrix to a single value to set all elements of the matrix to such a value
|
opBinary
|
Multiplication of a matrix by a vector
This is essentially a matrix multiplication, but is handled separately for convenience
If Vector is made to extend Matrix in the future, this will become obsolete
|
opBinary
|
Pairwise operations on matrices
|
opBinary
|
Pairwise operations on matrices with a constant
|
setColumn
|
Sets the nth column of the matrix
|
setRow
|
Sets the nth row of the matrix
|
toString
|
Returns the matrix as a string
|
TODO
frustums, transformations, speed everything up with parallelism