Method trace
static member trace: Tensor<'T> -> Tensor<'T>
Calculates the trace of the matrix.
Declaration
static member trace: a:Tensor<'T> -> Tensor<'T>
Parameters
Type | Name | Description |
---|---|---|
Tensor<'T> | a | A square matrix. |
Returns
Type | Description |
---|---|
Tensor<'T> | The trace of the matrix. |
Remarks
The trace is is defined by the sum of the elements on the diagonal.
The matrix must be square.
If the specified tensor has more than two dimensions, the traces along the last two dimensions are returned as a tensor.
Examples
let a = HostTensor.zeros [3L; 3L]
let b = Tensor.trace a