Matrix.Get Diagonal View Method
Definition
Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.5.0
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.5.0
Overload List
| Get | Returns a view that exposes only the diagonal elements of a matrix. |
| Get | Returns a view that exposes only the diagonal elements of a matrix with explicit dimensions. |
GetDiagonalView<T>(Matrix<T>, ArrayMutability)
Returns a view that exposes only the diagonal elements of a matrix.
public static Matrix<T> GetDiagonalView<T>(
Matrix<T> source,
ArrayMutability mutability = ArrayMutability.Inherit
)
Parameters
- source Matrix<T>
- The source matrix.
- mutability ArrayMutability (Optional)
- The desired mutability of the view. Must not exceed the mutability of source. The default is Inherit.
Type Parameters
- T
- The element type of the matrix.
Return Value
Matrix<T>A matrix that represents the diagonal part of source. Off-diagonal elements read as zero.
Remarks
The returned view aliases the storage of source: no copy is made. Writes to diagonal elements are forwarded to the source; writes to off-diagonal positions throw a ComponentReadOnlyException.
Exceptions
| Argument | source is null. |
| Invalid | mutability is more permissive than the mutability of source. |
GetDiagonalView<T>(Matrix<T>, Int32, Int32, ArrayMutability)
Returns a view that exposes only the diagonal elements of a matrix with explicit dimensions.
public static Matrix<T> GetDiagonalView<T>(
Matrix<T> source,
int rowCount,
int columnCount,
ArrayMutability mutability = ArrayMutability.Inherit
)
Parameters
- source Matrix<T>
- The source matrix.
- rowCount Int32
- The number of rows of the view. Must be between 0 and the row count of source (inclusive).
- columnCount Int32
- The number of columns of the view. Must be between 0 and the column count of source (inclusive).
- mutability ArrayMutability (Optional)
- The desired mutability of the view. Must not exceed the mutability of source. The default is Inherit.
Type Parameters
- T
- The element type of the matrix.
Return Value
Matrix<T>A rowCount×columnCount matrix that represents the diagonal part of the leading submatrix of source. Off-diagonal elements read as zero.
Exceptions
| Argument | source is null. |
| Argument | rowCount is less than 0 or greater than the row count of source. -or- columnCount is less than 0 or greater than the column count of source. |