Elementwise sum of numeric or character arrays.

x %sum% y

Arguments

x

numeric or character array.

y

numeric or character array.

Value

array.

References

Guidotti E (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05

See also

Other basic arithmetic: %diff%(), %div%(), %dot%(), %inner%(), %kronecker%(), %outer%(), %prod%()

Examples

### vector 
x <- c("a+1","b+2")
x %sum% x
#> [1] "a+1 + a+1" "b+2 + b+2"

### matrix 
x <- matrix(letters[1:4], ncol = 2)
x %sum% x
#>      [,1]    [,2]   
#> [1,] "a + a" "c + c"
#> [2,] "b + b" "d + d"

### array
x <- array(letters[1:12], dim = c(2,2,3))
y <- array(1:12, dim = c(2,2,3))
x %sum% y
#> , , 1
#> 
#>      [,1]    [,2]   
#> [1,] "a + 1" "c + 3"
#> [2,] "b + 2" "d + 4"
#> 
#> , , 2
#> 
#>      [,1]    [,2]   
#> [1,] "e + 5" "g + 7"
#> [2,] "f + 6" "h + 8"
#> 
#> , , 3
#> 
#>      [,1]     [,2]    
#> [1,] "i + 9"  "k + 11"
#> [2,] "j + 10" "l + 12"
#>