|
Code Packages
1
Add-on code processing modules
|
Provides a generic matrix data type and common matrices operations. More...
Public Member Functions | |
| Matrix (int rows, int columns) | |
| Initialize a new instance of a 2D Matrix class More... | |
| void | Add (params T[] args) |
| Used internally for initialization upon declaration. More... | |
| void | Clear () |
| Clears all elements of the matrix More... | |
| Matrix< T > | Copy () |
| Copy the current matrix to a new matrix More... | |
| override bool | Equals (object obj) |
| T [] | GetColumn (int index) |
| Gets all matrix elements in the specified column More... | |
| T [] | GetDiagonal () |
| Gets diagonal elements of the matrix More... | |
| IEnumerator | GetEnumerator () |
| Returns an enumerator that iterates through a collection. More... | |
| override int | GetHashCode () |
| T [] | GetRow (int index) |
| Gets all matrix elements in the specified row More... | |
| bool | IsDiagonal () |
| Check if current matrix is a diagonal matrix More... | |
| bool | IsIdentity () |
| Check if current matrix is an Identity matrix More... | |
| bool | IsOne () |
| Check if current matrix consists of all 1s More... | |
| bool | IsScalar () |
| Check if current matrix is a scalar matrix More... | |
| bool | IsSingular () |
| Check if current matrix is singular More... | |
| bool | IsSquare () |
| Check if current matrix is a square matrix More... | |
| bool | IsSymmetric () |
| Check if current matrix is a symmetric matrix More... | |
| bool | IsZero () |
| Check if current matrix is a zero matrix More... | |
| void | SetColumn (int index, params T[] values) |
| Sets matrix elements in the specified column to the given values More... | |
| void | SetRow (int index, params T[] values) |
| Sets matrix elements in the specified row to the given values More... | |
| override string | ToString () |
| Converts the Matrix to its string representation More... | |
Static Public Member Functions | |
| static Matrix< T > | Adjugate< T > (Matrix< T > A) |
| Calculates the Adjugate of a square Matrix (classical adjoint) More... | |
| static Matrix< T > | Cofactor< T > (Matrix< T > A) |
| Calculates the cofactor of a square Matrix More... | |
| static Matrix< T > | Compare< T > (Matrix< T > A, Matrix< T > B) |
| Compares two matrices element by element More... | |
| static T | Determinant< T > (Matrix< T > A) |
| Calculates the determinant of a square matrix More... | |
| static Matrix< T > | Diagonal< T > (params T[] values) |
| Creates an Instance of a diagonal matrix with specified diagonal elements More... | |
| static Matrix< T > | ElementF< T > (Matrix< T > A, Func< T, T > f) |
| Function to perform calculations on each element of a matrix More... | |
| static Matrix< T > | Fill< T > (int rows, int columns, T value) |
| Creates an Instance of an empty matrix and fills all elements with the specified value More... | |
| static Matrix< T > | Identity< T > (int size) |
| Creates an Instance of an Identity matrix More... | |
| static Matrix< T > | Inverse< T > (Matrix< T > A) |
| Calculates the inverse (reciprocal matrix) of a square matrix More... | |
| static T | Minor< T > (Matrix< T > A, int row, int column) |
| Calculates the Minor at specified index of a Matrix More... | |
| static bool | operator!= (Matrix< T > A, Matrix< T > B) |
| Inequality check of two matrices More... | |
| static Matrix< T > | operator* (Matrix< T > A, Matrix< T > B) |
| Performs Matrix multiplication More... | |
| static Matrix< T > | operator* (Matrix< T > A, T value) |
| Performs scalar multiplication More... | |
| static Matrix< T > | operator+ (Matrix< T > A, Matrix< T > B) |
| Performs Matrix addition More... | |
| static Matrix< T > | operator+ (Matrix< T > A, T value) |
| Performs scalar addition More... | |
| static Matrix< T > | operator- (Matrix< T > A, Matrix< T > B) |
| Performs Matrix subtraction More... | |
| static Matrix< T > | operator- (Matrix< T > A, T value) |
| Performs scalar subtraction More... | |
| static Matrix< T > | operator- (Matrix< T > A) |
| Negates (opposite) all elements in the matrix More... | |
| static Matrix< T > | operator/ (Matrix< T > A, T value) |
| Performs scalar division More... | |
| static bool | operator== (Matrix< T > A, Matrix< T > B) |
| Equality check of two matrices More... | |
| static Matrix< T > | Pow< T > (Matrix< T > A, int exponent) |
| Calculates the matrix raised to specified power More... | |
| static Matrix< T > | Remove< T > (Matrix< T > A, int row, int column) |
| Removes the specified row and column More... | |
| static Matrix< T > | RemoveColumn< T > (Matrix< T > A, int index) |
| Removes the specified column More... | |
| static Matrix< T > | RemoveRow< T > (Matrix< T > A, int index) |
| Removes the specified row More... | |
| static Matrix< T > | Round< T > (Matrix< T > A, int decimals) |
| Rounds a matrix to the specified number of fractional digits More... | |
| static T | Trace< T > (Matrix< T > A) |
| Calculates the Trace of a Matrix More... | |
| static Matrix< T > | Transpose< T > (Matrix< T > A) |
| Matrix Transpose More... | |
Properties | |
| int | Columns [get] |
| Gets the number of columns in the Matrix More... | |
| int | Rows [get] |
| Gets the number of rows in the Matrix More... | |
| int | Size [get] |
| Gets the size of the Matrix More... | |
| T | this[int row, int column] [get, set] |
| Provides indexing in Matrix More... | |
Provides a generic matrix data type and common matrices operations.
Provides basic matrix calculations.
Matrix supports many data types such as Matrix<int>, Matrix<double>, Matrix<Complex>, etc.
Note: A class instance is a reference type, not a value type.
| T | specified elements data type |
| dsp.Matrix< T >.Matrix | ( | int | rows, |
| int | columns | ||
| ) |
Initialize a new instance of a 2D Matrix class
| rows | matrix rows |
| columns | matrix columns |
Example 1
The following example creates an empty Matrix with 2 rows and 3 columns.
Each element of a matrix is double data type.
Example 2
The following example instantiates a Matrix (2 rows by 3 columns) with default values.
Element type is double
Example 3
The following example instantiates a column vector (single dimension matrix) with default values.
Element type is double
Example 4
The following example instantiates a row vector (single dimension matrix) with default values.
Element type is double
Example 5
The following example instantiates a complex square Matrix with default values.
Element type is Complex
| void dsp.Matrix< T >.Add | ( | params T [] | args | ) |
Used internally for initialization upon declaration.
Do not use this method!
|
static |
Calculates the Adjugate of a square Matrix (classical adjoint)
The adjugate of matrix A is the transpose of the cofactor matrix of A
| A | input matrix |

Example
| void dsp.Matrix< T >.Clear | ( | ) |
Clears all elements of the matrix
Example
|
static |
Calculates the cofactor of a square Matrix
Returns a matrix with elements that are the cofactors, term-by-term, of a given square matrix.
| A | input matrix |

Example
|
static |
Compares two matrices element by element
Provides a way to check for equality of two matrices element by element
Matrixes A and B must be of equal size
| A | first input matrix |
| B | second input matrix |
Example
| Matrix<T> dsp.Matrix< T >.Copy | ( | ) |
Copy the current matrix to a new matrix
Copy method provides direct copy of all elements of the current matrix to a new instance of the matrix class.
Example
|
static |
Calculates the determinant of a square matrix
A single number obtained from a matrix that reveals a variety of the matrix's properties.
Input must be a square matrix.
| A | input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Creates an Instance of a diagonal matrix with specified diagonal elements
A diagonal matrix is a square matrix in which the entries outside the main diagonal (↘) are all zero.
The diagonal entries themselves may or may not be zero.
| values | diagonal elements |
Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Function to perform calculations on each element of a matrix
ElementF can handle input functions that have more than one parameter by using the lamda operator =>
| A | input matrix |
| f | input function which returns a supported type value |
Example 1
The following example calculates the complex conjugate transpose on a complex matrix
Example 2
The following example calculates the cube on each element of a matrix, using the lamda operator
| override bool dsp.Matrix< T >.Equals | ( | object | obj | ) |
|
static |
Creates an Instance of an empty matrix and fills all elements with the specified value
| rows | matrix rows |
| columns | matrix columns |
| value | elements value |
Example 1
Element type is double
Example 2
Element type is Complex
| T [] dsp.Matrix< T >.GetColumn | ( | int | index | ) |
Gets all matrix elements in the specified column
| index | column index (zero based) |
Example
| T [] dsp.Matrix< T >.GetDiagonal | ( | ) |
Gets diagonal elements of the matrix
Example
| IEnumerator dsp.Matrix< T >.GetEnumerator | ( | ) |
Returns an enumerator that iterates through a collection.
| override int dsp.Matrix< T >.GetHashCode | ( | ) |
| T [] dsp.Matrix< T >.GetRow | ( | int | index | ) |
Gets all matrix elements in the specified row
| index | row index (zero based) |
Example
|
static |
Creates an Instance of an Identity matrix
An identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere.
| size | size of one side of the square matrix |
Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Calculates the inverse (reciprocal matrix) of a square matrix
A square matrix A has an inverse iff the determinant is not zero (nonsingular matrix). Non-square matrices do not have inverses.
| A | input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
| bool dsp.Matrix< T >.IsDiagonal | ( | ) |
Check if current matrix is a diagonal matrix
A diagonal matrix is a square matrix in which the entries outside the main diagonal (↘) are all zero.
The diagonal entries themselves may or may not be zero.
Example
| bool dsp.Matrix< T >.IsIdentity | ( | ) |
Check if current matrix is an Identity matrix
An identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere.
Example
| bool dsp.Matrix< T >.IsOne | ( | ) |
Check if current matrix consists of all 1s
Example
| bool dsp.Matrix< T >.IsScalar | ( | ) |
Check if current matrix is a scalar matrix
A diagonal matrix with all its main diagonal entries equal is a scalar matrix.
Example
| bool dsp.Matrix< T >.IsSingular | ( | ) |
Check if current matrix is singular
Singular matrix is a square matrix that does not have a matrix inverse.
A matrix is singular iff its determinant is 0.

Example
| bool dsp.Matrix< T >.IsSquare | ( | ) |
Check if current matrix is a square matrix
Example
| bool dsp.Matrix< T >.IsSymmetric | ( | ) |
Check if current matrix is a symmetric matrix
A symmetric matrix is a square matrix that is equal to its transpose. The entries of a symmetric matrix are symmetric with respect to the main diagonal.
Example
| bool dsp.Matrix< T >.IsZero | ( | ) |
Check if current matrix is a zero matrix
Example
|
static |
Calculates the Minor at specified index of a Matrix
A minor is the reduced determinant of a determinant expansion that is formed by omitting the ith row and jth column of a square matrix A
| A | input matrix |
| row | row index (zero based) |
| column | column index (zero based) |

Example
|
static |
Inequality check of two matrices
| A | first input matrix |
| B | second input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs Matrix multiplication
If A is an n×m matrix and B is an m×p matrix,the result is an n×p matrix.
| A | matrix |
| B | matrix |
Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs scalar multiplication
| A | input matrix |
| value | scalar value |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs Matrix addition
A and B should be of same dimension
| A | first input matrix |
| B | second input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs scalar addition
| A | input matrix |
| value | scalar value |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs Matrix subtraction
A and B should be of same dimension
| A | first input matrix |
| B | second input matrix |

Example
|
static |
Performs scalar subtraction
| A | input matrix |
| value | scalar value |

Example
|
static |
Negates (opposite) all elements in the matrix
| A | input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Performs scalar division
| A | input matrix |
| value | scalar value |

Example
|
static |
Equality check of two matrices
| A | first input matrixr |
| B | second input matrix |

Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Calculates the matrix raised to specified power
Square matrices can be multiplied by themselves repeatedly in the same way as ordinary numbers, because they always have the same number of rows and columns.
This repeated multiplication can be described as a power of the matrix, a special case of the ordinary matrix product.
| A | input matrix |
| exponent | exponent value |
Example 1
Element type is double
Example 2
Element type is Complex
|
static |
Removes the specified row and column
Returns a new matrix instance with row and column removed
| A | input matrix |
| row | row to be removed (zero index) |
| column | column to be removed (zero index) |
Example
|
static |
Removes the specified column
Returns a new matrix instance with column removed
| A | input matrix |
| index | column to be removed (zero index) |
Example
|
static |
Removes the specified row
Returns a new matrix instance with row removed
| A | input matrix |
| index | row to be removed (zero index) |
Example
|
static |
Rounds a matrix to the specified number of fractional digits
Rounding applies on all matrix elements using an away from zero mode.
| A | input matrix |
| decimals | number of fractional digits |
Example 1
Element type is double
Example 2
Element type is Complex
| void dsp.Matrix< T >.SetColumn | ( | int | index, |
| params T [] | values | ||
| ) |
Sets matrix elements in the specified column to the given values
It replace values from up to down. Maximum row count is based on the number of supplied values
| index | column index (zero based) |
| values | column elements |
Example
| void dsp.Matrix< T >.SetRow | ( | int | index, |
| params T [] | values | ||
| ) |
Sets matrix elements in the specified row to the given values
It replace values from left to right. Maximum column count is based on the number of supplied values
| index | row index (zero based) |
| values | row elements |
Example
| override string dsp.Matrix< T >.ToString | ( | ) |
Converts the Matrix to its string representation
Converted string is in clear and printable form.
The function Matrix.Round can be used to aid clarity
Example
|
static |
|
static |
Matrix Transpose
A matrix which is formed by turning all the rows of a given matrix into columns and vice-versa.
| A | input matrix |

Example
|
get |
Gets the number of columns in the Matrix
Example
|
get |
Gets the number of rows in the Matrix
Example
|
get |
Gets the size of the Matrix
Example
|
getset |
Provides indexing in Matrix
Can be used to get and set an element
| row | element row index (zero based) |
| column | element column index (zero based) |
Example 1 Element type is double
Example 2 Element type is Complex