beetlebug▾
/

ztcl::tensor where

Gives the indices of the elements that are not 0.

ztcl::tensor where TENSOR

Description

Gives the indices of the elements of a tensor of rank 1 that are not 0, in rising order. A NaN is not 0. With ge or another compare, it gives the indices of the elements that pass a test.

Returns

An i32 tensor of rank 1.

Examples

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

% ztcl::tensor where [ztcl::tensor gt [ztcl::tensor of {0.5 0.1 0.9}] 0.3]
tensor i32 2 {0 2}

Errors

% ztcl::tensor where [ztcl::tensor ones {2 2}]
tensor where: the tensor has rank 2, and the command needs rank 1
-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.