beetlebug▾
/

ztcl::tensor arange

Makes the tensor 0, 1, and up to N - 1.

ztcl::tensor arange N ?DTYPE?

Description

Makes a tensor of rank 1 with the elements 0 to N - 1. The default dtype is i32.

Returns

A tensor.

Examples

Each example of this page runs after package require ztcl::tensor.

% ztcl::tensor arange 4
tensor i32 4 {0 1 2 3}

% ztcl::tensor arange 3 f32
tensor f32 3 {0.0 1.0 2.0}

Errors

% ztcl::tensor arange -1
tensor arange: 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.