ztcl::tensor cumsum
Gives the running sum along the last axis.
ztcl::tensor cumsum TENSOR
Description
Gives the running sum of each row of the last axis: element i is the sum of the elements 0 to i, added in order. A sum of f32 elements adds in an f64 accumulator, as sum does, and each element of the result rounds to f32. An i32 sum wraps.
Returns
A tensor of the shape and the dtype of TENSOR.
Examples
Each example of this page runs after package require ztcl::tensor.
% ztcl::tensor cumsum [ztcl::tensor of {{1 2 3} {4 5 6}}]
tensor f32 {2 3} {1.0 3.0 6.0 4.0 9.0 15.0}
Errors
% ztcl::tensor cumsum [ztcl::tensor scalar 1]
tensor cumsum: the tensor has rank 0
-errorcode ZTCL TENSOR
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.4
- Compute cost
- A cost for each element operation by its kind (a copy, an add, a division, a math function, a multiply-add of a matmul), set so that one compute unit takes about the time of one unit of plain Tcl. docs/modules/tensor.md has the table.