Tensor.Identity Method
Definition
Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.3
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.3
Creates an identity tensor with a specified size and order.
Overload List
Identity<T>(Int32, Int32, TensorElementOrder) | Returns a 2D tensor that is 1 on the specified diagonal and zero everywhere else. |
Identity<T>(Int32, Int32, Int32, TensorElementOrder) | Returns a 2D tensor that is 1 on the specified diagonal and zero everywhere else. |
Identity<T>(Int32, Int32, TensorElementOrder)
Returns a 2D tensor that is 1 on the specified diagonal
and zero everywhere else.
public static Tensor<T> Identity<T>(
int size,
int diagonal = 0,
TensorElementOrder order = TensorElementOrder.CStyle
)
Parameters
- size Int32
- The number of rows and columns of the tensor.
- diagonal Int32 (Optional)
- Optional. The diagonal that contains the unit elements. The default (0) indicates the main diagonal. Positive values indicate a diagonal above the main diagonal. Negative values indicate a diagonal below the main diagonal.
- order TensorElementOrder (Optional)
- Optional. The order of the elements in the tensor.
Type Parameters
- T
- The type of the elements of the tensor.
Return Value
Tensor<T>A tensor with size rows and columns with ones on the diagonal specified by diagonal.
Exceptions
Argument | size is less than zero. |
Identity<T>(Int32, Int32, Int32, TensorElementOrder)
Returns a 2D tensor that is 1 on the specified diagonal
and zero everywhere else.
public static Tensor<T> Identity<T>(
int rowCount,
int columnCount,
int diagonal = 0,
TensorElementOrder order = TensorElementOrder.CStyle
)
Parameters
- rowCount Int32
- The number of rows of the tensor.
- columnCount Int32
- The number of columns of the tensor.
- diagonal Int32 (Optional)
- Optional. The diagonal that contains the unit elements. The default (0) indicates the main diagonal. Positive values indicate a diagonal above the main diagonal. Negative values indicate a diagonal below the main diagonal.
- order TensorElementOrder (Optional)
- Optional. Specifies the element order of the result. By default, elements are stored in C-style (row-major) order.
Type Parameters
- T
- The type of the elements of the tensor.
Return Value
Tensor<T>A tensor with rowCount rows and columnCount columns with ones on the diagonal specified by diagonal.
Exceptions
Argument | rowCount is less than zero. -or- columnCount is less than zero. |