beetlebug▾
/

ztcl::tensor maximum

Gives the larger of two tensors, element by element.

ztcl::tensor maximum A B

Description

Gives the larger of the elements of A and B. The shapes broadcast: they align at the right, and a dimension of size 1 repeats. A plain number for one operand is a scalar of the dtype of the other operand, and the operands need one dtype.

Returns

A tensor.

Examples

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

% ztcl::tensor maximum [ztcl::tensor of {1 5}] [ztcl::tensor of {4 2}]
tensor f32 2 {4.0 5.0}

Errors

% ztcl::tensor maximum [ztcl::tensor of {1 2 3}] [ztcl::tensor of {1 2}]
tensor: the shapes {3} and {2} do not broadcast
-errorcode ZTCL TENSOR

% ztcl::tensor maximum 1 2
tensor maximum: one operand must be a tensor
-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.