Search code examples
rmatrixmatrix-multiplication

what does %*%+ mean in matrix operations?


I read a piece of code somewhere where the following operation is performed between matrices x and y

x %*% + y

I know that %*% means matrix multiplication but what does %*% + mean? I tried it out in R and I get the same results for both.


Solution

  • Based on precedence of operators, unary minus and plus (+, -) are evaluated before %any% (including %*%). Therefore, x %*% + y is the same as x %*% (+y) (which is equal to x %*% y).