Tensor<T>.GetDiagonal Method

Gets the elements on the diagonal of a 2-dimensional tensor.

Definition

Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.3
C#
public abstract Tensor<T> GetDiagonal(
	int diagonal = 0
)

Parameters

diagonal  Int32  (Optional)
Optional. The diagonal to return. The default value 0 indicates the main diagonal. Values greater than zero indicate diagonals above the main diagonal. Values less than zero indicate diagonals above the main diagonal.

Return Value

Tensor<T>
A tensor of the same element type that contains the elements on the diagonal specified by diagonal.

Exceptions

RankException

The tensor does not have rank 2.

See Also