Matrix<T>.GetDiagonal Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.9.0

Overload List

GetDiagonal() Gets a vector view of the diagonal elements of this instance.
GetDiagonal(Int32) Gets a vector view of the specified diagonal of this instance.
GetDiagonal(Int32, Intent) Gets a vector view of the specified diagonal of this instance.

GetDiagonal

Gets a vector view of the diagonal elements of this instance.
C#
public Vector<T> GetDiagonal()

Return Value

Vector<T>
A vector representing the main diagonal of this instance.

Remarks

The default inherited intent returns a writable live vector for a mutable matrix, a read-only live vector for a live read-only matrix, and an immutable vector for an immutable matrix.

The main diagonal of a matrix with zero rows or zero columns is a valid length-zero vector.

GetDiagonal(Int32)

Gets a vector view of the specified diagonal of this instance.
C#
public Vector<T> GetDiagonal(
	int index
)

Parameters

index  Int32
The index of the diagonal. A value of zero indicates the main diagonal. A value greater than zero indicates a super-diagonal. A value less than zero indicates a sub-diagonal.

Return Value

Vector<T>
A vector representing the specified diagonal of this instance.

Remarks

The default inherited intent returns a live vector unless the source is immutable. Use the overload that accepts Intent to request an explicit live view or detached copy.

Index zero is valid for every matrix shape. A positive index is valid when it is less than ColumnCount; a negative index is valid when its magnitude is less than RowCount.

Exceptions

ArgumentOutOfRangeException

index is nonzero and less than or equal to -RowCount, or greater than or equal to ColumnCount.

GetDiagonal(Int32, Intent)

Gets a vector view of the specified diagonal of this instance.
C#
public virtual Vector<T> GetDiagonal(
	int index,
	Intent intent
)

Parameters

index  Int32
The index of the diagonal. A value of zero indicates the main diagonal. A value greater than zero indicates a super-diagonal. A value less than zero indicates a sub-diagonal.
intent  Intent
An Intent value that specifies the intended use of the diagonal vector.

Return Value

Vector<T>
A vector representing the specified diagonal of this instance.

Remarks

View intents return vectors backed by this matrix. Copy intents return detached vectors. Inherit follows the mutability and live-sharing state of this matrix.

Index zero is valid for every matrix shape, including matrices with a zero dimension. A positive index is valid when it is less than ColumnCount; a negative index is valid when its magnitude is less than RowCount.

Exceptions

ArgumentOutOfRangeException

index is nonzero and less than or equal to -RowCount, or greater than or equal to ColumnCount.

See Also