ztcl::tensor perm
Makes a random order of the numbers 0 to N - 1.
ztcl::tensor perm N SEED
Description
Makes an i32 tensor of rank 1 with each number from 0 to N - 1 once, in a random order from SEED (a Fisher-Yates shuffle on splitmix64).
Returns
An i32 tensor.
Examples
Each example of this page runs after package require ztcl::tensor.
% ztcl::tensor perm 5 1
tensor i32 5 {1 0 3 4 2}
% lsort -integer [ztcl::tensor flat [ztcl::tensor perm 5 1]]
0 1 2 3 4
Errors
% ztcl::tensor perm -1 0
tensor perm: the count -1 is out of range
-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.