rray_multiply_add()
computes x * y + z
, with broadcasting.
It is more efficient than simply doing those operations in sequence.
rray_multiply_add(x, y, z)
x, y, z | A vector, matrix, array or rray. |
---|
An object of the common type of the inputs, containing the result of the multiply-add operation.
rray_multiply_add(2, 3, 5)#> [1] 11#> [,1] [,2] #> [1,] 4 5 #> [2,] 5 7 #> [3,] 6 9 #> [4,] 7 11 #> [5,] 8 13# ^ Equivalent to: x <- matrix(rep(1:5, 2), ncol = 2) y <- matrix(rep(1:2, 5), byrow = TRUE, ncol = 2) z <- matrix(3L, nrow = 5, ncol = 2) x * y + z#> [,1] [,2] #> [1,] 4 5 #> [2,] 5 7 #> [3,] 6 9 #> [4,] 7 11 #> [5,] 8 13