ztcl::tensor kernel
Makes a command that runs one expression for each element of its tensor arguments.
ztcl::tensor kernel NAME PARAMS EXPR ?OPTION ...?
Description
Makes the command NAME, which calls map with the OPTIONs, PARAMS, and EXPR and its own arguments. The options are the options of map. NAME is a proc, so a script can rename it, and info body shows the call.
Returns
The name.
Examples
Each example of this page runs after package require ztcl::tensor.
% ztcl::tensor kernel axpy {a x y} {$a * $x + $y}; axpy 2 [ztcl::tensor of {1 2}] [ztcl::tensor of {3 4}]
tensor f32 2 {5.0 8.0}
% ztcl::tensor kernel half {x} {$x / 2} -dtype f64; half [ztcl::tensor of {1 3}]
tensor f64 2 {0.5 1.5}
Errors
% ztcl::tensor kernel k {x}
wrong # args: should be "ztcl::tensor kernel name params body ?arg ...?"
-errorcode TCL WRONGARGS
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.