Mul
mul(input, other, out=NULL)
Multiplies each element of the input input
with the scalar
other
and returns a new resulting tensor.
input
is of type FloatTensor
or DoubleTensor
, other
should be a real number, otherwise it should be an integer
Each element of the tensor input
is multiplied by the corresponding
element of the Tensor other
. The resulting tensor is returned.
The shapes of input
and other
must be
broadcastable .
Examples
if (torch_is_installed()) {
a = torch_randn(c(3))
a
torch_mul(a, 100)
a = torch_randn(c(4, 1))
a
b = torch_randn(c(1, 4))
b
torch_mul(a, b)
}
#> torch_tensor
#> -0.0004 -0.0012 0.0035 -0.0034
#> -0.0584 -0.1937 0.5756 -0.5531
#> -0.1488 -0.4936 1.4667 -1.4094
#> -0.0212 -0.0704 0.2092 -0.2010
#> [ CPUFloatType{4,4} ]