Struct DenseMatrix<T>
Represents a dense matrix with arbitrary elements. Components that are adjacent in a column of the matrix are adjacent in the storage array. The components are said to be stored in column major order.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public readonly struct DenseMatrix<T> : IEquatable<DenseMatrix<T>> where T : struct, IEquatable<T>
Type Parameters
Name | Description |
---|---|
T | The type of elements in the matrix. |
Constructors
| Edit this page View SourceDenseMatrix(int)
Initializes a new instance of the DenseMatrix<T> struct.
Declaration
public DenseMatrix(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | The length of each side in the matrix. |
DenseMatrix(int, int)
Initializes a new instance of the DenseMatrix<T> struct.
Declaration
public DenseMatrix(int columns, int rows)
Parameters
Type | Name | Description |
---|---|---|
int | columns | The number of columns. |
int | rows | The number of rows. |
DenseMatrix(int, int, Span<T>)
Initializes a new instance of the DenseMatrix<T> struct.
Declaration
public DenseMatrix(int columns, int rows, Span<T> data)
Parameters
Type | Name | Description |
---|---|---|
int | columns | The number of columns. |
int | rows | The number of rows. |
Span<T> | data | The array to provide access to. |
DenseMatrix(T[,])
Initializes a new instance of the DenseMatrix<T> struct.
Declaration
public DenseMatrix(T[,] data)
Parameters
Type | Name | Description |
---|---|---|
T[,] | data | The 2D array to provide access to. |
Properties
| Edit this page View SourceColumns
Gets the number of columns in the dense matrix.
Declaration
public int Columns { get; }
Property Value
Type | Description |
---|---|
int |
Count
Gets the number of items in the array.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Data
Gets the 1D representation of the dense matrix.
Declaration
public T[] Data { get; }
Property Value
Type | Description |
---|---|
T[] |
this[int, int]
Gets or sets the item at the specified position.
Declaration
public ref T this[int row, int column] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | row | The row-coordinate of the item. Must be greater than or equal to zero and less than the height of the array. |
int | column | The column-coordinate of the item. Must be greater than or equal to zero and less than the width of the array. |
Property Value
Type | Description |
---|---|
T | The |
Rows
Gets the number of rows in the dense matrix.
Declaration
public int Rows { get; }
Property Value
Type | Description |
---|---|
int |
Size
Gets the size of the dense matrix.
Declaration
public Size Size { get; }
Property Value
Type | Description |
---|---|
Size |
Span
Gets a span wrapping the Data.
Declaration
public Span<T> Span { get; }
Property Value
Type | Description |
---|---|
Span<T> |
Methods
| Edit this page View SourceClear()
Clears the matrix setting each value to the default value for the element type
Declaration
public void Clear()
Equals(DenseMatrix<T>)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(DenseMatrix<T> other)
Parameters
Type | Name | Description |
---|---|---|
DenseMatrix<T> | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
| Edit this page View SourceFill(T)
Fills the matrix with the given value
Declaration
public void Fill(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to fill each item with |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
| Edit this page View SourceTranspose()
Transposes the rows and columns of the dense matrix.
Declaration
public DenseMatrix<T> Transpose()
Returns
Type | Description |
---|---|
DenseMatrix<T> | The DenseMatrix<T>. |
Operators
| Edit this page View Sourceoperator ==(DenseMatrix<T>, DenseMatrix<T>)
Compares the two DenseMatrix<T> instances to determine whether they are unequal.
Declaration
public static bool operator ==(DenseMatrix<T> left, DenseMatrix<T> right)
Parameters
Type | Name | Description |
---|---|---|
DenseMatrix<T> | left | The first source instance. |
DenseMatrix<T> | right | The second source instance. |
Returns
Type | Description |
---|---|
bool | The bool. |
implicit operator T[,](in DenseMatrix<T>)
Performs an implicit conversion from a DenseMatrix<T> to a T[,].
Declaration
public static implicit operator T[,](in DenseMatrix<T> data)
Parameters
Type | Name | Description |
---|---|---|
DenseMatrix<T> | data | The source array. |
Returns
Type | Description |
---|---|
T[,] | The T[,] representation on the source data. |
implicit operator DenseMatrix<T>(T[,])
Performs an implicit conversion from a T[,] to a DenseMatrix<T>.
Declaration
public static implicit operator DenseMatrix<T>(T[,] data)
Parameters
Type | Name | Description |
---|---|---|
T[,] | data | The source array. |
Returns
Type | Description |
---|---|
DenseMatrix<T> | The DenseMatrix<T> representation on the source data. |
operator !=(DenseMatrix<T>, DenseMatrix<T>)
Compares the two DenseMatrix<T> instances to determine whether they are equal.
Declaration
public static bool operator !=(DenseMatrix<T> left, DenseMatrix<T> right)
Parameters
Type | Name | Description |
---|---|---|
DenseMatrix<T> | left | The first source instance. |
DenseMatrix<T> | right | The second source instance. |
Returns
Type | Description |
---|---|
bool | The bool. |