Class Matrix<T>
2-Dimensional generic matrix.
Inheritance
Namespace: Paramdigma.Core.Collections
Assembly: Paramdigma.Core.dll
Syntax
public class Matrix<T> : object
Type Parameters
Name | Description |
---|---|
T | Type of the objects in the matrix. |
Constructors
| Improve this Doc View SourceMatrix(T[,])
Initializes a new instance of the Matrix<T> class from a 2D array.
Declaration
public Matrix(T[, ] data)
Parameters
Type | Name | Description |
---|---|---|
T[,] | data | 2D array of data. |
Matrix(Int32)
Initializes a new instance of the Matrix<T> class.
Declaration
public Matrix(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | Size of the square Matrix. |
Matrix(Int32, Int32)
Initializes a new instance of the Matrix<T> class of the specified size.
Declaration
public Matrix(int n, int m)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | Column size. |
System.Int32 | m | Row size. |
Properties
| Improve this Doc View SourceCount
Gets the amount of items in this matrix.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Int32, Int32]
Gets a specific item in the matrix.
Declaration
public T this[int row, int column] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | Row. |
System.Int32 | column | Column. |
Property Value
Type | Description |
---|---|
T |
M
Gets rows.
Declaration
public int M { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Number of rows on the Matrix. |
N
Gets columns.
Declaration
public int N { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Number of columns on the Matrix. |
Methods
| Improve this Doc View SourceColumn(Int32)
Get the column of a matrix at the specified index.
Declaration
public T[] Column(int m)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | m | Column index. |
Returns
Type | Description |
---|---|
T[] | Matrix column as list. |
FlipMatrix()
Turns columns into rows and rows into columns.
Declaration
public void FlipMatrix()
GetAllNeighboursAt(Int32, Int32)
Obtains all neighbour entities surrounding the specified matrix coordinates.
Declaration
public List<T> GetAllNeighboursAt(int column, int row)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | column | Column location. |
System.Int32 | row | Row location. |
Returns
Type | Description |
---|---|
List<T> | List of all neighbour entities. |
GetContiguousNeighboursAt(Int32, Int32)
Obtains contiguous neighbour entities surrounding the specified matrix coordinates.
Declaration
public List<T> GetContiguousNeighboursAt(int column, int row)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | column | Column location. |
System.Int32 | row | Row location. |
Returns
Type | Description |
---|---|
List<T> | List of contiguous neighbours ( Up / Left / Down / Right ). |
GetCornerNeighboursAt(Int32, Int32)
Obtains corner neighbour entities surrounding the specified matrix coordinates.
Declaration
public List<T> GetCornerNeighboursAt(int column, int row)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | column | Column location. |
System.Int32 | row | Row location. |
Returns
Type | Description |
---|---|
List<T> | List of corner neighbours (Diagonally connected). |
IncrementColumns(Int32)
Increment Matrix column size by a specified amount. It accepts both increasing and decreasing the size.
Declaration
public void IncrementColumns(int incrementN)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | incrementN | Positive or negative increment. |
IncrementMatrixSize(Int32)
Increase or decrease the matrix size symetrically.
Declaration
public void IncrementMatrixSize(int symetricIncrement)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | symetricIncrement | Symetric increase/decrease. |
IncrementMatrixSize(Int32, Int32)
Increase or decrease the column size of the matrix.
Declaration
public void IncrementMatrixSize(int columnIncrement, int rowIncrement)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | columnIncrement | Column increment. |
System.Int32 | rowIncrement | Row increment. |
IncrementRows(Int32)
Increment Matrix row size by a specified amount. It accepts both increasing and decreasing the size.
Declaration
public void IncrementRows(int incrementM)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | incrementM | Positive or negative increment. |
Row(Int32)
Get the row of a matrix at the specified index.
Declaration
public T[] Row(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | Row index. |
Returns
Type | Description |
---|---|
T[] | Matrix row as list. |