np_trace
Compute the sum of elements along the main diagonal of a 2D array, with optional offset for other diagonals.
Instructions
Return the sum along the main diagonal of the array.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| array | Yes | The input array (must be at least 2D). | |
| offset | No | The diagonal offset (default: 0, main diagonal). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |