This operator allows to do elementwise operation of two algebraic object i.e. matrices/vectors. There is one required condition to perform such operation: at least one domension values from both objects must be the same

a %m% b

a %d% b

a %-% b

a %+% b

Arguments

a

matrix/vector

b

matrix/vector

Value

Matrix/vector

Examples

# Multiply m(1, 2, 3 | 4, 5, 6 | 7, 8, 9) %m% v(5,4,3)
#> [,1] [,2] [,3] #> [1,] 5 10 15 #> [2,] 16 20 24 #> [3,] 21 24 27
# Divide m(1, 2, 3 | 4, 5, 6 | 7, 8, 9) %d% v(5,4,3)
#> [,1] [,2] [,3] #> [1,] 0.200000 0.400000 0.6 #> [2,] 1.000000 1.250000 1.5 #> [3,] 2.333333 2.666667 3.0
# Add m(1, 2, 3 | 4, 5, 6 | 7, 8, 9) %+% v(5,4,3)
#> [,1] [,2] [,3] #> [1,] 6 7 8 #> [2,] 8 9 10 #> [3,] 10 11 12
# Subtract m(1, 2, 3 | 4, 5, 6 | 7, 8, 9) %-% v(5,4,3)
#> [,1] [,2] [,3] #> [1,] -4 -3 -2 #> [2,] 0 1 2 #> [3,] 4 5 6