0

The %*% operator in R has it's purpose described in multiple places for example:

The R %*% operator

and here

https://www.tutorialspoint.com/r/r_operators.htm

Which states:

"This operator is used to multiply a matrix with its transpose."

What I do not understand is the calculation performed in order to go from one matrix to another using this operator, for example:

M = matrix(c(3,2,5,3,4,5),3, 2, TRUE)
M
#     [,1] [,2]
#[1,]    3    2
#[2,]    5    3
#[3,]    4    5

t(M)
#     [,1] [,2] [,3]
#[1,]    3    5    4
#[2,]    2    3    5

print ( M %*% t(M) )
#     [,1] [,2] [,3]
#[1,]   13   21   22
#[2,]   21   34   35
#[3,]   22   35   41

I've stared as this, and other matrix iterations and I can't figure out how you arrive at the result by multiplication with the transpose matrix, and I can't find an explanation anywhere. Can anyone provide an explanation please or point me in the right direction? Thanks

Roasty247
  • 679
  • 5
  • 20
  • 2
    Think wiki helps maybe https://en.wikipedia.org/wiki/Dot_product or this https://en.wikipedia.org/wiki/Matrix_multiplication – RLave Apr 16 '19 at 12:39
  • 5
    I believe it’s basic [matrix multiplication](https://en.m.wikipedia.org/wiki/Matrix_multiplication#Definition). Matrix multiplication is more than just element-wise multiplication, which might be the source of your confusion. – Wil Apr 16 '19 at 12:40
  • 2
    This seems helpful: http://matrixmultiplication.xyz/ – markus Apr 16 '19 at 12:52
  • 1
    Thanks for your comments. I didn't realise 'matrix multiplication' was a thing in itself, otherwise would have been a sensible thing to google! Visualisations were helpful thanks. – Roasty247 Apr 16 '19 at 13:13

0 Answers0