beetlebug▾
/

ztcl::tensor item

Gives the number of a tensor with one element.

ztcl::tensor item TENSOR

Description

Gives the one element as a Tcl number: a double for a float dtype, and an integer for i32. An f32 element becomes the double with the same value.

Returns

A number.

Examples

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

% ztcl::tensor item [ztcl::tensor scalar 2.5]
2.5

% ztcl::tensor item [ztcl::tensor scalar 0.1]
0.10000000149011612

Errors

% set a [ztcl::tensor of {{1 2 3} {4 5 6}}]; ztcl::tensor item $a
tensor item: the tensor has 6 elements
-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.