ztcl::tensor axpby
Gives A * X + B * Y for two numbers and two tensors.
ztcl::tensor axpby A X B Y
Description
Gives A times X plus B times Y in one pass, for two tensors of one dtype and one shape. A and B round to the dtype first. Each element has the bits of the two multiplies and the add as separate operations.
Returns
A tensor.
Examples
Each example of this page runs after package require ztcl::tensor.
% ztcl::tensor axpby 2 [ztcl::tensor of {1 2}] 0.5 [ztcl::tensor of {4 8}]
tensor f32 2 {4.0 8.0}
Errors
% ztcl::tensor axpby 2 [ztcl::tensor of {1 2}] 1 [ztcl::tensor of {1 2 3}]
tensor axpby: the tensors differ in dtype or shape
-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.