Struct DenseMatrix<T>
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
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.
public readonly struct DenseMatrix<T> : IEquatable<DenseMatrix<T>> where T : struct, IEquatable<T>
Type Parameters
T
The type of elements in the matrix.
- Implements
- Inherited Members
Constructors
DenseMatrix(int)
Initializes a new instance of the DenseMatrix<T> struct.
public DenseMatrix(int length)
Parameters
length
intThe length of each side in the matrix.
DenseMatrix(int, int)
Initializes a new instance of the DenseMatrix<T> struct.
public DenseMatrix(int columns, int rows)
Parameters
DenseMatrix(int, int, Span<T>)
Initializes a new instance of the DenseMatrix<T> struct.
public DenseMatrix(int columns, int rows, Span<T> data)
Parameters
columns
intThe number of columns.
rows
intThe number of rows.
data
Span<T>The array to provide access to.
DenseMatrix(T[,])
Initializes a new instance of the DenseMatrix<T> struct.
public DenseMatrix(T[,] data)
Parameters
data
T[,]The 2D array to provide access to.
Properties
Columns
Gets the number of columns in the dense matrix.
public int Columns { get; }
Property Value
Count
Gets the number of items in the array.
public int Count { get; }
Property Value
Data
Gets the 1D representation of the dense matrix.
public T[] Data { get; }
Property Value
- T[]
this[int, int]
Gets or sets the item at the specified position.
public ref T this[int row, int column] { get; }
Parameters
row
intThe row-coordinate of the item. Must be greater than or equal to zero and less than the height of the array.
column
intThe column-coordinate of the item. Must be greater than or equal to zero and less than the width of the array.
Property Value
- T
The
at the specified position.
Rows
Gets the number of rows in the dense matrix.
public int Rows { get; }
Property Value
Size
Gets the size of the dense matrix.
public Size Size { get; }
Property Value
Span
Gets a span wrapping the Data.
public Span<T> Span { get; }
Property Value
- Span<T>
Methods
Clear()
Clears the matrix setting each value to the default value for the element type
public void Clear()
Equals(DenseMatrix<T>)
public bool Equals(DenseMatrix<T> other)
Parameters
other
DenseMatrix<T>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
Fill(T)
Fills the matrix with the given value
public void Fill(T value)
Parameters
value
TThe value to fill each item with
GetHashCode()
public override int GetHashCode()
Returns
Transpose()
Transposes the rows and columns of the dense matrix.
public DenseMatrix<T> Transpose()
Returns
- DenseMatrix<T>
The DenseMatrix<T>.
Operators
operator ==(DenseMatrix<T>, DenseMatrix<T>)
Compares the two DenseMatrix<T> instances to determine whether they are unequal.
public static bool operator ==(DenseMatrix<T> left, DenseMatrix<T> right)
Parameters
left
DenseMatrix<T>The first source instance.
right
DenseMatrix<T>The second source instance.
Returns
implicit operator T[,](in DenseMatrix<T>)
Performs an implicit conversion from a DenseMatrix<T> to a T[,].
public static implicit operator T[,](in DenseMatrix<T> data)
Parameters
data
DenseMatrix<T>The source array.
Returns
- T[,]
The T[,] representation on the source data.
implicit operator DenseMatrix<T>(T[,])
Performs an implicit conversion from a T[,] to a DenseMatrix<T>.
public static implicit operator DenseMatrix<T>(T[,] data)
Parameters
data
T[,]The source array.
Returns
- 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.
public static bool operator !=(DenseMatrix<T> left, DenseMatrix<T> right)
Parameters
left
DenseMatrix<T>The first source instance.
right
DenseMatrix<T>The second source instance.