# NOT RUN {
library(magrittr)
x <- rray(1:8, c(2, 2, 2)) %>%
rray_set_row_names(c("r1", "r2")) %>%
rray_set_col_names(c("c1", "c2"))
y <- matrix(1:2, nrow = 1)
# All arithmetic functions are applied with broadcasting
rray_add(x, y)
# And the power `+` when any underlying input
# is an rray
x + y
# If you happen to only have base R matrices/arrays
# you can use `rray_add()` or `%b+%` to get the
# broadcasting behavior
rray_add(y, matrix(1:2))
y %b+% matrix(1:2)
# }
Run the code above in your browser using DataLab