Matrix.Create Hankel Method
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
Overload List
| Create | Creates a new dense symmetric Hankel matrix from a single span. |
| Create | Creates a new dense Hankel matrix from the first column and last row. |
CreateHankel<T>(ReadOnlySpan<T>, ArrayMutability)
Creates a new dense symmetric Hankel matrix from a single span.
public static DenseMatrix<T> CreateHankel<T>(
ReadOnlySpan<T> values,
ArrayMutability mutability = ArrayMutability.MutableValues
)
Parameters
- values ReadOnlySpan<T>
- A span containing the values for the matrix, starting from the first column and continuing to the last row.
- mutability ArrayMutability (Optional)
- Specifies how the matrix's values may be changed. The default is mutable values.
Type Parameters
- T
- The element type of the matrix.
Return Value
DenseMatrix<T>A new square DenseMatrix<T> with the symmetric Hankel structure.
Remarks
A symmetric Hankel matrix of size n×n requires 2n-1 values.
Example
// Create a 4x4 symmetric Hankel matrix
var values = new double[] { 1, 2, 3, 4, 5, 6, 7 };
var matrix = Matrix.CreateHankel(values);
// Resulting matrix:
// [ 1 2 3 4 ]
// [ 2 3 4 5 ]
// [ 3 4 5 6 ]
// [ 4 5 6 7 ]CreateHankel<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ArrayMutability)
Creates a new dense Hankel matrix from the first column and last row.
public static DenseMatrix<T> CreateHankel<T>(
ReadOnlySpan<T> firstColumn,
ReadOnlySpan<T> lastRow,
ArrayMutability mutability = ArrayMutability.MutableValues
)
Parameters
- firstColumn ReadOnlySpan<T>
- A span containing the elements of the first column.
- lastRow ReadOnlySpan<T>
- A span containing the elements of the last row.
- mutability ArrayMutability (Optional)
- Specifies how the matrix's values may be changed. The default is mutable values.
Type Parameters
- T
- The element type of the matrix.
Return Value
DenseMatrix<T>A new DenseMatrix<T> with the Hankel structure.
Remarks
A Hankel matrix is a matrix in which each ascending anti-diagonal from left to right is constant. The matrix is defined by its first column and last row.
The last element of the first column must equal the first element of the last row.
Example
// Create a 4x5 Hankel matrix
var col = new double[] { 1, 2, 3, 4 };
var row = new double[] { 4, 5, 6, 7, 8 };
var matrix = Matrix.CreateHankel(col, row);
// Resulting matrix:
// [ 1 2 3 4 5 ]
// [ 2 3 4 5 6 ]
// [ 3 4 5 6 7 ]
// [ 4 5 6 7 8 ]Exceptions
| Argument | The last element of firstColumn and the first element of lastRow are not equal. |